I am trying to get the current clients connected in an organization

Solved
omaralrafei
Here to help

I am trying to get the current clients connected in an organization

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.

1 Accepted Solution
PaulF
Meraki Employee
Meraki Employee

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>

View solution in original post

5 Replies 5
PaulF
Meraki Employee
Meraki Employee

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>

PhilipDAth
Kind of a big deal
Kind of a big deal

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 🙂

Jamieinbox
Getting noticed

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

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.