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

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.4.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.4-py3-none-any.whl (4.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dnacentersdk-2.11.4.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.4.tar.gz
Algorithm Hash digest
SHA256 b7e8fe1c1ef88a32f413ea8defc1a8302b2185425e82f4d665b055fe470a8775
MD5 4c9b60ee662a204f625476bd10041607
BLAKE2b-256 154eb4858a799fde17086699d2d1bda8ce6370d66f7a44fa2ccd812ec94dc384

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dnacentersdk-2.11.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 82153f9b3a74755ea6e3d2e9581982e8606adce6473558b52a2ed1087e23e5e4
MD5 8e503173ef5db51d62b4e8e3be669118
BLAKE2b-256 164db218583c5b6649feca16105439476d01a6d4a04fea26c11df56336b115c7

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