dnacentersdk
============
*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!
.. code-block:: python
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.3.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="des")
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**
.. code-block:: python
from dnacentersdk import DNACenterAPI
with DNACenterAPI() as dnac:
devices = dnac.devices.get_device_list()
**Explicit Close**
.. code-block:: python
from dnacentersdk import DNACenterAPI
dnac = DNACenterAPI()
try:
devices = dnac.devices.get_device_list()
finally:
dnac.close()
**Automatic Cleanup via GC**
.. code-block:: python
from dnacentersdk import DNACenterAPI
def get_devices():
dnac = DNACenterAPI()
return dnac.devices.get_device_list()
devices = get_devices()
**Legacy Usage**
.. code-block:: python
from dnacentersdk import DNACenterAPI
dnac = DNACenterAPI()
devices = dnac.devices.get_device_list()
Installation
------------
**Install via pip**
.. code-block:: bash
pip install dnacentersdk
**Upgrade to the latest version**
.. code-block:: bash
pip install --upgrade dnacentersdk
Compatibility Matrix
--------------------
.. list-table::
:widths: 50 50
:header-rows: 1
* - 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.4
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.*
.. _Introduction: https://dnacentersdk.readthedocs.io/en/latest/api/intro.html
.. _Quickstart: https://dnacentersdk.readthedocs.io/en/latest/api/quickstart.html
.. _dnacentersdk: https://github.com/cisco-en-programmability/dnacentersdk
.. _issues: https://github.com/cisco-en-programmability/dnacentersdk/issues
.. _releases: https://github.com/cisco-en-programmability/dnacentersdk/releases
.. _Contributing: https://github.com/cisco-en-programmability/dnacentersdk/blob/master/docs/contributing.rst
.. _webexteamssdk: https://github.com/CiscoDevNet/webexteamssdk
.. _CHANGELOG: https://github.com/cisco-en-programmability/dnacentersdk/blob/main/CHANGELOG.md
.. _PyCharm: https://www.jetbrains.com/pycharm
Raw data
{
"_id": null,
"home_page": "https://dnacentersdk.readthedocs.io/en/latest/",
"name": "dnacentersdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "Cisco, DNA Center, SDK",
"author": "Jose Bogarin Solano",
"author_email": "jbogarin@altus.cr",
"download_url": "https://files.pythonhosted.org/packages/30/db/218f229bad1afcb37c41ea51a7798e36acf9ee9b1a69400d594fd185b4e0/dnacentersdk-2.10.4.tar.gz",
"platform": null,
"description": "dnacentersdk\n============\n\n*Work with the DNA Center APIs in native Python!*\n\n-------------------------------------------------------------------------------\n\n**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!\n\n.. code-block:: python\n\n from dnacentersdk import DNACenterAPI\n\n # Create a DNACenterAPI connection object\n dnac = DNACenterAPI(\n username=\"devnetuser\",\n password=\"Cisco123!\",\n base_url=\"https://sandboxdnac.cisco.com:443\",\n version=\"3.1.3.0\",\n verify=True\n )\n\n # Find all devices that belong to the \"Switches and Hubs\" family\n devices = dnac.devices.get_device_list(family=\"Switches and Hubs\")\n\n for device in devices.response:\n print(\"{:20s}{}\".format(device.hostname, device.upTime))\n\n # Find all tags\n all_tags = dnac.tag.get_tag(sort_by=\"name\", order=\"des\")\n demo_tags = [tag for tag in all_tags.response if \"Demo\" in tag.name]\n\n # Delete demo tags\n for tag in demo_tags:\n dnac.tag.delete_tag(tag.id)\n\n # Create a new demo tag\n demo_tag = dnac.tag.create_tag(name=\"dna Demo\")\n task = dnac.task.get_task_by_id(task_id=demo_tag.response.taskId)\n\n if not task.response.isError:\n created_tag = dnac.tag.get_tag(name=\"dna Demo\")\n updated_tag = dnac.tag.update_tag(\n id=created_tag.response[0].id,\n name=\"Updated \" + created_tag.response[0].name,\n description=\"DNA demo tag\"\n )\n print(dnac.task.get_task_by_id(task_id=updated_tag.response.taskId).response.progress)\n\n # Retrieve updated tag\n result = dnac.tag.get_tag(name=\"Updated dna Demo\")\n print(result)\n else:\n print(\"Unfortunately\", task.response.progress)\n print(\"Reason:\", task.response.failureReason)\n\n # Custom API examples\n def setup_custom():\n dnac.custom_caller.add_api(\n \"get_global_credentials\",\n lambda credential_type: dnac.custom_caller.call_api(\n \"GET\",\n \"/dna/intent/api/v1/global-credential\",\n params={\"credentialSubType\": credential_type}\n ).response\n )\n dnac.custom_caller.add_api(\n \"create_netconf_credentials\",\n lambda port: dnac.custom_caller.call_api(\n \"POST\",\n \"/dna/intent/api/v1/global-credential/netconf\",\n json=[{\"netconfPort\": port}]\n )\n )\n\n setup_custom()\n dnac.custom_caller.create_netconf_credentials(\"65533\")\n print(dnac.custom_caller.get_global_credentials(\"NETCONF\"))\n\nIntroduction\n------------\n\nCheck out the complete Introduction_\n\n**dnacentersdk handles all of this for you:**\n\n- Reads your DNA Center credentials from environment variables.\n- Reads your DNA Center API version from the `DNA_CENTER_VERSION` environment variable.\n- Handles TLS certificate verification with the `verify` parameter.\n- Enables debug mode via the `DNA_CENTER_DEBUG` environment variable.\n- Exposes all DNA Center API calls as native Python methods organized in a hierarchical tree.\n- Offers IDE auto-completion support (e.g., in `PyCharm_`).\n- Converts all JSON responses to native Python objects with dot notation access.\n- Handles rate-limiting automatically.\n- Refreshes authentication tokens when they expire.\n- Provides resource management via context managers and explicit connection cleanup.\n\nResource Management\n-------------------\n\nYou can manage the HTTP connection lifecycle in several ways:\n\n**Context Manager**\n\n.. code-block:: python\n\n from dnacentersdk import DNACenterAPI\n\n with DNACenterAPI() as dnac:\n devices = dnac.devices.get_device_list()\n\n**Explicit Close**\n\n.. code-block:: python\n\n from dnacentersdk import DNACenterAPI\n\n dnac = DNACenterAPI()\n try:\n devices = dnac.devices.get_device_list()\n finally:\n dnac.close()\n\n**Automatic Cleanup via GC**\n\n.. code-block:: python\n\n from dnacentersdk import DNACenterAPI\n\n def get_devices():\n dnac = DNACenterAPI()\n return dnac.devices.get_device_list()\n\n devices = get_devices()\n\n**Legacy Usage**\n\n.. code-block:: python\n\n from dnacentersdk import DNACenterAPI\n\n dnac = DNACenterAPI()\n devices = dnac.devices.get_device_list()\n\nInstallation\n------------\n\n**Install via pip**\n\n.. code-block:: bash\n\n pip install dnacentersdk\n\n**Upgrade to the latest version**\n\n.. code-block:: bash\n\n pip install --upgrade dnacentersdk\n\nCompatibility Matrix\n--------------------\n\n.. list-table::\n :widths: 50 50\n :header-rows: 1\n\n * - Cisco DNA Center version\n - dnacentersdk version\n * - 2.3.5.3\n - 2.6.11\n * - 2.3.7.6\n - 2.7.7\n * - 2.3.7.7\n - 2.8.6\n * - 2.3.7.9\n - 2.8.14\n * - 3.1.3.0\n - 2.10.4\n\nDocumentation\n-------------\n\nVisit: https://dnacentersdk.readthedocs.io\n\nStart with the Quickstart_ to get up and running quickly.\n\nRelease Notes\n-------------\n\nSee the releases_ page for details on features and fixes.\n\nQuestions, Support & Discussion\n-------------------------------\n\nThis is a *community-supported* project. For questions or issues, use the issues_ page.\n\nContributing\n------------\n\ndnacentersdk_ is community-driven. Feedback, suggestions, and code contributions are welcome! See the Contributing_ guide.\n\nInspiration\n-----------\n\nThis library is inspired by the webexteamssdk_ project.\n\nChangelog\n---------\n\nAll notable changes are documented in the CHANGELOG_.\n\nThe library may continue to evolve as Cisco DNA Center APIs change.\n\n*Copyright (c) 2019\u20132025 Cisco Systems.*\n\n.. _Introduction: https://dnacentersdk.readthedocs.io/en/latest/api/intro.html\n.. _Quickstart: https://dnacentersdk.readthedocs.io/en/latest/api/quickstart.html\n.. _dnacentersdk: https://github.com/cisco-en-programmability/dnacentersdk\n.. _issues: https://github.com/cisco-en-programmability/dnacentersdk/issues\n.. _releases: https://github.com/cisco-en-programmability/dnacentersdk/releases\n.. _Contributing: https://github.com/cisco-en-programmability/dnacentersdk/blob/master/docs/contributing.rst\n.. _webexteamssdk: https://github.com/CiscoDevNet/webexteamssdk\n.. _CHANGELOG: https://github.com/cisco-en-programmability/dnacentersdk/blob/main/CHANGELOG.md\n.. _PyCharm: https://www.jetbrains.com/pycharm\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Cisco DNA Center Platform SDK",
"version": "2.10.4",
"project_urls": {
"Homepage": "https://dnacentersdk.readthedocs.io/en/latest/",
"Repository": "https://github.com/cisco-en-programmability/dnacentersdk"
},
"split_keywords": [
"cisco",
" dna center",
" sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ead9a019e3d7fb2531b0f1fc05d6defeaefc31be935035cf54e2d500736dfa91",
"md5": "e3fe3e6576a46d0a148517b5ca74f7ca",
"sha256": "548952184f08393ec21ad947a3fa4135e0f219866937e4e1ff569f3a7d243520"
},
"downloads": -1,
"filename": "dnacentersdk-2.10.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e3fe3e6576a46d0a148517b5ca74f7ca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 3672795,
"upload_time": "2025-07-30T20:23:19",
"upload_time_iso_8601": "2025-07-30T20:23:19.869030Z",
"url": "https://files.pythonhosted.org/packages/ea/d9/a019e3d7fb2531b0f1fc05d6defeaefc31be935035cf54e2d500736dfa91/dnacentersdk-2.10.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "30db218f229bad1afcb37c41ea51a7798e36acf9ee9b1a69400d594fd185b4e0",
"md5": "149f95a5a1d6ef8c269fa7e321ca167d",
"sha256": "e7c23c2bb3806456fea8b7657db1b93ea74b62db834d2c7c852a1f0ce5f141f5"
},
"downloads": -1,
"filename": "dnacentersdk-2.10.4.tar.gz",
"has_sig": false,
"md5_digest": "149f95a5a1d6ef8c269fa7e321ca167d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 1514461,
"upload_time": "2025-07-30T20:23:21",
"upload_time_iso_8601": "2025-07-30T20:23:21.864609Z",
"url": "https://files.pythonhosted.org/packages/30/db/218f229bad1afcb37c41ea51a7798e36acf9ee9b1a69400d594fd185b4e0/dnacentersdk-2.10.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-30 20:23:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cisco-en-programmability",
"github_project": "dnacentersdk",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "dnacentersdk"
}