Today, I going to write a brief summary of the Cisco DNA Center Platform API, The main Major of the DNAC platform to access your network devices through API and integrate with other systems and add support for multi-vendors and help you to data analyze.
-- Cisco Make amazing documentation about API, you can get form Developer toolkit ( Access to DNAC-->Platform -->Developer Toolkit--> APIs)

You must have a python 3.x with the requests library Use PIP 3 to install the requests library as shown below the Summary of steps :
1- root@PlatformAPI:~# apt-get update

2- root@PlatformAPI:~# apt-get install python3-pip3

- You must import the basic authentication from requests.auth as per ( Cisco ) following this script
def get_token():
token = requests.post(
‘https://<cluster IP>/dna/system/api/v1/auth/token’,
auth=HTTPBasicAuth(
username=<username>,
password=<password>
),
headers={'content-type': 'application/json'},
verify=False,
)
data = token.json()
return data[‘Token’]<code></code>
Let's try some parameters but before we start should be you understand the HTTP message :
HTTP message has two types (Request, Response )
HTTP request message (ASCII) code and you can get more information through this link:
https://en.wikipedia.org/wiki/ASCIIMethod types are ( GET, POST, Head, Put, Delete)
- POST >>> To create resources objects.
- GET >>> To retrieve a resources.
- PUT >>> To create or replace the resources.
- Head >>> To leave the request object out of response.
- Delete >>> To delete a resources.
{{ Create sites, assign devices to them and get site health}}
POST /DNA/intent/API/v1/site Create Site
{
"type": "area",
"site": {
"area": {
"name": "string",
"parentName": "string"
},
"building": {
"name": "string",
"address": "string",
"parentName": "string",
"latitude": 0,
"longitude": 0
},
"floor": {
"name": "string",
"parentName": "string",
"rfModel": "Cubes And Walled Offices",
"width": 0,
"length": 0,
"height": 0
}
}
} |
POST /dna/system/api/v1/site/{siteId}/device Assign Device To Site
{
"device": [
{
"ip": "string"
}
]
}
and you can read more about these through this amazing link: https://developer.cisco.com/docs/dna-center/api/1-3-3-x/
*** I hope that has been informative for you and thank you ***
Mohamed Alhenawy
CCIE#60453