cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
271
Views
0
Helpful
1
Replies

Get Client summary through API call

JPavonM
VIP
VIP

Hi chaps,

Does anybody know how to ask DNA-C for a wireless client summary for a specific area/building and SSID, AND for the last 30 days?

Rerporting in DNA-C is limited to last 14 days so no way to see all data from the last month that DNA-C stores.

I've raised this to TAC and used the "Make wish" to request, but in the meantime, I need to extract this data.

Any help with the python script woould be appreciated.

1 Reply 1

marce1000
VIP
VIP

 

 - Have a try with this one :


import requests

def get_wireless_client_summary(site_name, building_name, ssid_name):
api_url = "https://dnacenter.cisco.com/api/v1/network-device-group/device-groups/" + site_name + "/buildings/" + building_name + "/sites/0/clients"
headers = {
'Authorization': 'Bearer <your_token>',
'Content-Type': 'application/json'
}

params = {
'startDate': '2024-01-01',
'endDate': '2024-01-31',
'ssidName': ssid_name
}

response = requests.get(api_url, headers=headers, params=params)
if response.status_code == 200:
response_json = response.json()
print(response_json)
else:
print('Error: {}'.format(response.status_code))

if __name__ == '__main__':
# Replace with your site name, building name, and SSID name
site_name = 'Default-Site'
building_name = 'Building1'
ssid_name = 'Guest'

get_wireless_client_summary(site_name, building_name, ssid_name)

   - Replace the placeholders for site_name, building_name, and ssid_name with the actual names of your site, building, and SSID. You will also need to replace the placeholder for <your_token> with your DNA Center API token. You can get your API token from the Cisco DNA Center web UI.

 M.



-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '