I have searched the API documentation and i haven't found any call that does this out of the box.
I am wondering what's the best API call for me to get the current client count.
Solved! Go to solution.
import meraki
API_KEY = '<YOURAPIKEY>'
client = meraki.DashboardAPI(API_KEY)
networks = client.organizations.getOrganizationNetworks(organizationId="<YOURORG>")
clientNum = 0
for network in networks:
try:
clients = client.networks.getNetworkClients(networkId=network['id'])
print(len(clients))
clientNum = clientNum + len(clients)
except meraki.APIError as e:
result = 'fail'
print("Total Clients", str(clientNum))
There's no ORG wide API call presently for network clients, so you'll have to cycle through each network
Replace <YOURAPIKEY> and <YOURORG>
import meraki
API_KEY = '<YOURAPIKEY>'
client = meraki.DashboardAPI(API_KEY)
networks = client.organizations.getOrganizationNetworks(organizationId="<YOURORG>")
clientNum = 0
for network in networks:
try:
clients = client.networks.getNetworkClients(networkId=network['id'])
print(len(clients))
clientNum = clientNum + len(clients)
except meraki.APIError as e:
result = 'fail'
print("Total Clients", str(clientNum))
There's no ORG wide API call presently for network clients, so you'll have to cycle through each network
Replace <YOURAPIKEY> and <YOURORG>
Building on the excellent answer by @PaulF , the Meraki GitHub "Examples" directory has an example of retrieving all clients and reporting them to CSV files.
https://github.com/meraki/dashboard-api-python/blob/main/examples/aio_org_wide_clients_v1.py
Thank you Paul for the detailed response. My specific use case is for a JavaScript implementation, but the general approach is clear enough 🙂
This may be what you're looking for.
Update ListClients · jadexing/Merakicode@cf88f7d (github.com)
Hi Jamie, thank you for the example, it will definitely help along with Paul's code.
It seems most of the Meraki API use cases are done in Python. 😅