Cisco APIs

Tutorials on interacting with Cisco Catalyst Center, DNAC, Meraki, and ISE APIs

Cisco APIs

Cisco provides powerful APIs for automating and managing network infrastructures. This page explores how to interact with Cisco Catalyst Center, DNA Center (DNAC), Meraki, and ISE APIs using Python.

Why Use Cisco APIs?

  • Automation: Reduce manual tasks and improve efficiency.
  • Monitoring & Insights: Retrieve real-time network data.
  • Configuration Management: Modify and deploy network settings programmatically.
  • Security & Compliance: Ensure policies are enforced across devices.

1. Getting Started with Cisco APIs

Before diving into code, ensure you have the required dependencies:

pip install requests dnacentersdk meraki

Most Cisco APIs require authentication. Here’s an example of how to authenticate with Cisco DNA Center:

import requests

DNAC_URL = "https://sandboxdnac2.cisco.com"
USERNAME = "devnetuser"
PASSWORD = "Cisco123!"

# Authenticate and get a token
def get_dnac_token():
    url = f"{DNAC_URL}/dna/system/api/v1/auth/token"
    response = requests.post(url, auth=(USERNAME, PASSWORD), verify=False)
    return response.json()["Token"]

token = get_dnac_token()
print("Token:", token)

2. Cisco Catalyst Center API - Retrieve Network Devices

headers = {"X-Auth-Token": token, "Content-Type": "application/json"}
url = f"{DNAC_URL}/dna/intent/api/v1/network-device"
response = requests.get(url, headers=headers, verify=False)

for device in response.json()["response"]:
    print(f"Device: {device['hostname']} - Type: {device['type']}")

3. Meraki API - Get Organization Networks

from meraki import DashboardAPI

API_KEY = "your_meraki_api_key"
dashboard = DashboardAPI(API_KEY)

orgs = dashboard.organizations.getOrganizations()
org_id = orgs[0]["id"]
networks = dashboard.organizations.getOrganizationNetworks(org_id)

for net in networks:
    print(f"Network Name: {net['name']} - ID: {net['id']}")

4. Cisco ISE API - Get Endpoint Details

ISE_URL = "https://your-ise-server:9060"
ISE_USERNAME = "admin"
ISE_PASSWORD = "yourpassword"

def get_ise_endpoints():
    url = f"{ISE_URL}/ers/config/endpoint"
    headers = {"Accept": "application/json"}
    response = requests.get(url, auth=(ISE_USERNAME, ISE_PASSWORD), headers=headers, verify=False)
    return response.json()

endpoints = get_ise_endpoints()
print(endpoints)

5. Useful Cisco API Resources

Documentation:

Video Tutorials:


Conclusion

By leveraging Cisco APIs, you can automate configurations, retrieve critical data, and enhance network management. Explore the above scripts and integrate them into your workflows!

Start automating your Cisco network today!

All rights reserved.