Work with the DNA Center APIs in native Python!
dnacentersdk is a community-developed Python library for working with the Cisco DNA Center APIs. Our goal is to make interacting with DNA Center in Python a native and natural experience!
from dnacentersdk import DNACenterAPI
# Create a DNACenterAPI connection object
dnac = DNACenterAPI(
username="devnetuser",
password="Cisco123!",
base_url="https://sandboxdnac.cisco.com:443",
version="3.1.6.0",
verify=True
)
# Find all devices that belong to the "Switches and Hubs" family
devices = dnac.devices.get_device_list(family="Switches and Hubs")
for device in devices.response:
print("{:20s}{}".format(device.hostname, device.upTime))
# Find all tags
all_tags = dnac.tag.get_tag(sort_by="name", order="desc")
demo_tags = [tag for tag in all_tags.response if "Demo" in tag.name]
# Delete demo tags
for tag in demo_tags:
dnac.tag.delete_tag(tag.id)
# Create a new demo tag
demo_tag = dnac.tag.create_tag(name="dna Demo")
task = dnac.task.get_task_by_id(task_id=demo_tag.response.taskId)
if not task.response.isError:
created_tag = dnac.tag.get_tag(name="dna Demo")
updated_tag = dnac.tag.update_tag(
id=created_tag.response[0].id,
name="Updated " + created_tag.response[0].name,
description="DNA demo tag"
)
print(dnac.task.get_task_by_id(task_id=updated_tag.response.taskId).response.progress)
# Retrieve updated tag
result = dnac.tag.get_tag(name="Updated dna Demo")
print(result)
else:
print("Unfortunately", task.response.progress)
print("Reason:", task.response.failureReason)
# Custom API examples
def setup_custom():
dnac.custom_caller.add_api(
"get_global_credentials",
lambda credential_type: dnac.custom_caller.call_api(
"GET",
"/dna/intent/api/v1/global-credential",
params={"credentialSubType": credential_type}
).response
)
dnac.custom_caller.add_api(
"create_netconf_credentials",
lambda port: dnac.custom_caller.call_api(
"POST",
"/dna/intent/api/v1/global-credential/netconf",
json=[{"netconfPort": port}]
)
)
setup_custom()
dnac.custom_caller.create_netconf_credentials("65533")
print(dnac.custom_caller.get_global_credentials("NETCONF"))
Introduction
Check out the complete Introduction
dnacentersdk handles all of this for you:
Reads your DNA Center credentials from environment variables.
Reads your DNA Center API version from the DNA_CENTER_VERSION environment variable.
Handles TLS certificate verification with the verify parameter.
Enables debug mode via the DNA_CENTER_DEBUG environment variable.
Exposes all DNA Center API calls as native Python methods organized in a hierarchical tree.
Offers IDE auto-completion support (e.g., in PyCharm_).
Converts all JSON responses to native Python objects with dot notation access.
Handles rate-limiting automatically.
Refreshes authentication tokens when they expire.
Provides resource management via context managers and explicit connection cleanup.
Resource Management
You can manage the HTTP connection lifecycle in several ways:
Context Manager
from dnacentersdk import DNACenterAPI
with DNACenterAPI() as dnac:
devices = dnac.devices.get_device_list()
Explicit Close
from dnacentersdk import DNACenterAPI
dnac = DNACenterAPI()
try:
devices = dnac.devices.get_device_list()
finally:
dnac.close()
Automatic Cleanup via GC
from dnacentersdk import DNACenterAPI
def get_devices():
dnac = DNACenterAPI()
return dnac.devices.get_device_list()
devices = get_devices()
Legacy Usage
from dnacentersdk import DNACenterAPI
dnac = DNACenterAPI()
devices = dnac.devices.get_device_list()
Installation
Install via pip
pip install dnacentersdk
Upgrade to the latest version
pip install --upgrade dnacentersdk
Compatibility Matrix
Cisco DNA Center version |
dnacentersdk version |
|---|---|
2.3.5.3 |
2.6.11 |
2.3.7.6 |
2.7.7 |
2.3.7.7 |
2.8.6 |
2.3.7.9 |
2.8.14 |
3.1.3.0 |
2.10.6 |
3.1.6.0 |
2.11.x |
Documentation
Visit: https://dnacentersdk.readthedocs.io
Start with the Quickstart to get up and running quickly.
Release Notes
See the releases page for details on features and fixes.
Questions, Support & Discussion
This is a community-supported project. For questions or issues, use the issues page.
Contributing
dnacentersdk is community-driven. Feedback, suggestions, and code contributions are welcome! See the Contributing guide.
Inspiration
This library is inspired by the webexteamssdk project.
Changelog
All notable changes are documented in the CHANGELOG.
The library may continue to evolve as Cisco DNA Center APIs change.
Copyright (c) 2019–2025 Cisco Systems.
Metadata
Release files for dnacentersdk 2.11.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dnacentersdk-2.11.4.tar.gz | 2.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dnacentersdk-2.11.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 MB
Release files / dnacentersdk-2.11.4.tar.gz
| Download URL | dnacentersdk-2.11.4.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7e8fe1c1ef88a32f413ea8defc1a8302b2185425e82f4d665b055fe470a8775
|
|
BLAKE2b-256 checksum How to use checksums |
154eb4858a799fde17086699d2d1bda8ce6370d66f7a44fa2ccd812ec94dc384
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.11.11 Darwin/25.2.0
|
Release files / dnacentersdk-2.11.4-py3-none-any.whl
| Download URL | dnacentersdk-2.11.4-py3-none-any.whl |
|---|---|
| Size | 4.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82153f9b3a74755ea6e3d2e9581982e8606adce6473558b52a2ed1087e23e5e4
|
|
BLAKE2b-256 checksum How to use checksums |
164db218583c5b6649feca16105439476d01a6d4a04fea26c11df56336b115c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.11.11 Darwin/25.2.0
|