GET networkClients API

Surendra
New here

GET networkClients API

My Goal is to get all clients connected to  particular VLAN. We do have more than 80 networks in our organization. I passed the netwrok id to networkClients API with disabled timespan and t0. It returns few client devices compared to Meraki Dashboard(returns clients after filter by vlan and for last day) .If I enabled timespan and adjust the seconds I am getting all the devices. I can't adjust timespan for all the networks in our organization.

 

How can i get all the client devices without adjusting timespan for individual networks. 

 

 

5 Replies 5
PhilipDAth
Kind of a big deal
Kind of a big deal

>I can't adjust timespan for all the networks in our organization.

 

If you are calling the API, why not?

sungod
Kind of a big deal

It would be best if you post the actual code/parameter values you are using, and which API version.

 

 

Edgar-VO
Building a reputation

I have some code i use :

 

def Check_WIFI_Usage(def_network_id) :

    ##############################################################
    # Browse all devices active the last day = 86400 seconds
    # Can be lots of pages... These are all clients on the network
    ##############################################################

    param = {}
    param['timespan'] = 86400

    my_clients = dashboard.clients.getNetworkClients(def_network_id,total_pages=-1,**param)

    for my_client in my_clients:

        ##############################################################
        # Get the device Policy... we check Normal and Blocked
        ##############################################################
        
        my_policy = dashboard.clients.getNetworkClientPolicy(def_network_id,my_client['id'])

        ##############################################################
        # Calculate usage
        ##############################################################
                
        user_sent = int(my_client['usage']['sent']/1024)
        user_recv = int(my_client['usage']['recv']/1024)
        user_total = int(user_sent+user_recv)

 
 
The value in my_client['vlan'] is the vlan ID you can use...
 
This will have every client within the past 24 hours.
 
 
Edgar-VO
Building a reputation

I have a small piece of code here for you which i use frequently to retrieve the network usage of client per network

timespan = 1 day
 
def Check_WIFI_Usage(def_network_id) :

    ##############################################################
    # Browse all devices active the last day = 86400 seconds
    # Can be lots of pages... These are all clients on the network
    ##############################################################

    param = {}
    param['timespan'] = 86400

    my_clients = dashboard.clients.getNetworkClients(def_network_id,total_pages=-1,**param)

    for my_client in my_clients:

        ##############################################################
        # Get the device Policy... we check Normal and Blocked
        ##############################################################
        
        my_policy = dashboard.clients.getNetworkClientPolicy(def_network_id,my_client['id'])

        ##############################################################
        # Calculate usage
        ##############################################################
                
        user_sent = int(my_client['usage']['sent']/1024)
        user_recv = int(my_client['usage']['recv']/1024)
        user_total = int(user_sent+user_recv)

 

my_client['vlan'] contains the vlan number which you can filter on

 

Hope this helps

Ed

Seshu
Meraki Employee
Meraki Employee

Hello @Surendra 

 

Here is a simple Webapp I built using Meraki Dashboard API endpoints. Here is the source code. You will find network wise clients. You can pull the source code from git and make necessary changes to gather the same at Org level. The input will be an API Key and the rest is pretty dynamic.

 

Steps to get started:

 

git clone https://github.com/Cool-Apps-Pvt-Ltd/Meraki-API-MutiOrg-Portal

cd Meraki-API-MutiOrg-Portal/

npm install

npm start

Get notified when there are additional replies to this discussion.