Skip to main content

Cisco DNA Center Platform SDK

Project description

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.0

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dnacentersdk-2.11.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dnacentersdk-2.11.0-py3-none-any.whl (4.9 MB view details)

Uploaded Python 3

File details

Details for the file dnacentersdk-2.11.0.tar.gz.

File metadata

  • Download URL: dnacentersdk-2.11.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Darwin/25.2.0

File hashes

Hashes for dnacentersdk-2.11.0.tar.gz
Algorithm Hash digest
SHA256 bf7c9fdc84a73eed5d44d926b0f3c4ffec39e58b1b60a052ab39e796089d9c9e
MD5 9f996917ae1b623f3310cdc5721fc8e4
BLAKE2b-256 1ff676b0d478bd3ac57ee8be25614371b1f5d16ca29f041e29617f6c44a21941

See more details on using hashes here.

File details

Details for the file dnacentersdk-2.11.0-py3-none-any.whl.

File metadata

  • Download URL: dnacentersdk-2.11.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Darwin/25.2.0

File hashes

Hashes for dnacentersdk-2.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 721b8ef0e664125b22c6ac11b6dabe60e201e07bf9bb7b97563e64c2bba23b2a
MD5 50c4dc07d07de98387753a3a5b0137df
BLAKE2b-256 e365de7625171322464a376a526806eceb72413bdcf87c587ea0d1d6fb367658

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page