Skip to main content

Community-developed Python CLI companion for the DNA Center SDK

Project description

Command Line Interface for Cisco DNA Center APIs.

dnacentercli is a CLI built for working with the DNA Center APIs.


To install dnacentercli, you will need to have python and pip installed. After you can enter the following command:

$ pip install dnacentercli

The project has a few dependencies:

Note: dnacentercli works starting from python 3

What is DNA Center?

“A better way to control your network. Cisco DNA Center is the network management and command center for Cisco DNA, your intent-based network for the enterprise.”

Visit the official DNA Center website for more information.


The DNA Center CLI depends and actively uses the DNA Center SDK. They, however, have some differences in their usage.

API Version

Cisco DNA Center SDK wraps DNA Center APIs (versions: 1.2.10 and 1.3.0), using the version parameter to control which API version to use.

DNA Center CLI does it by separating the versions by the –dna-version or -v option.


DNA Center SDK creates a DNACenterAPI “Connection Object” defaults to pulling from environment variables and config values. The same happens for the DNA Center CLI.

You can ask for help using --help and see the list of options and commands available on your selected version:

$ dnacentercli -v '1.2.10' --help


To avoid getting errors like the following:

> HTTPSConnectionPool(host='', port=443):
Max retries exceeded with url: /dna/system/api/v1/auth/token (Caused by SSLError
(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate
verify failed: self signed certificate in certificate chain (_ssl.c:1076)')))

Include the verify option and set it to False: --verify False

Access to DNA Center APIs

You need to authenticate for accessing other DNA Center APIs, such as Clients, Networks or PnP.

You can ask for specific API help using --help after the previous command options, which will list the endpoints (as commands):

$ dnacentercli -v '1.2.10' --base_url --verify False networks --help

Making API Calls

Each DNA Center SDK API Call parameter is a DNA Center CLI option.

The following call using the dnacentersdk

from dnacentersdk import DNACenterAPI
api = DNACenterAPI(username="devnetuser",

api.networks.get_overall_network_healt(timestamp='1568008500000', headers={'__runsync': True})

is the same as

$ dnacentercli -v '1.2.10' --username devnetuser --password Cisco123! \
> --base_url --verify True \
> networks get-overall-network-health \
> --timestamp "1568008500000" --headers '{"__runsync": true}'


There are differences across platforms about JSON strings.

On *nix based systems and command lines, the following is a valid JSON string representation:

$ dnacentercli -v '1.2.10' networks get-overall-network-health \
--timestamp "1568008500000" --headers '{"__runsync": true}'

On Windows and its command lines, the following is the valid JSON string representation:

dnacentercli -v '1.2.10' networks get-overall-network-health ^
--timestamp "1568008500000" --headers '{\"__runsync\": true}'

Be careful.

Multiple Options

There are some cases where the parameter type is a list. To record all the values, you have to provide the parameter multiple times.

For example:

$ dnacentercli -v '1.2.10' devices add-device --ipaddress '' --ipaddress ''


To activate the beep when the spinner finishes (or the API call ends), add the --beep option to your API Call. The --beep option is a boolean flag if present is on otherwise is off.

Pretty Print

To pretty-print the JSON response add the option -pp or --pretty_print INTEGER to your API Call, where the INTEGER is the indentation.

Both the debug and the JSON response of the API call are streamed to the Standard Output (stdout).

For example:

$ dnacentercli -v '1.2.10' devices get-device-list --family 'Unified AP' --hostname 'T1-9' -pp 2
  "response": [
      "apManagerInterfaceIp": "",
      "associatedWlcIp": "",
      "bootDateTime": null,
      "collectionInterval": "NA",
      "collectionStatus": "Managed",
      "errorCode": "null",
      "errorDescription": null,
      "family": "Unified AP",
      "hostname": "T1-9",
      "memorySize": "NA",
      "platformId": "AIR-AP1141N-A-K9",
      "reachabilityFailureReason": "NA",
      "reachabilityStatus": "Reachable",
      "role": "ACCESS",
      "roleSource": "AUTO",
      "serialNumber": "1140K0009",
      "snmpContact": "",
      "snmpLocation": "default-location",
      "softwareType": null,
      "tagCount": "0",
      "tunnelUdpPort": "16666",
      "type": "Cisco 1140 Unified Access Point",
      "upTime": "195days 11:11:32.270",
      "waasDeviceMode": null
  "version": "1.0"


All DNA Center SDK exceptions are streamed to the Standard Error (stderr). Before exiting the program, it will print the traceback (limited to 1 element), the exception name and its description.

Copyright (c) 2019 Cisco and/or its affiliates.

Project details

Download files

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

Source Distribution

dnacentercli-2.0.0.tar.gz (518.3 kB view hashes)

Uploaded source

Built Distribution

dnacentercli-2.0.0-py3-none-any.whl (255.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page