Meraki API - Get Organization Clients Search - Only return 3 networks

Solved
Luke01
Here to help

Meraki API - Get Organization Clients Search - Only return 3 networks

We have a custom app that uses the Meraki API v1 (Get Organization Clients Search).  When we make API call, there seems to be missing items (e.g. "networks") inside the "records" array.  My laptop has connected to 4 networks, in last week, but I always only see 3 "network" item max inside the "records" array.  Does anyone have extra details about the REST endpoint?

 

1) What is the logic when building the "records" array?

2) Is there a limit of items that can be returned inside the "records" array?

3) What is purpose with query param "perPage"?  When I changed it, nothing happens.

3) Is there any additional query params that are not documented on the website?

Get Organization Clients Search - Meraki Dashboard API v1 - Cisco Meraki Developer Hub

 

My end goal to retrieve all networks that a specific client has connected in the past.

 

When I connected to 4 or more devices, the API response only contains a max of 3 "records" items.  I would have expected 4 network items

 

@RaphaelL @AutomationDude  @API - Get Org client Search

1 Accepted Solution
sungod
Kind of a big deal

Note that the API call documentation says...

 

A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.

 

The link headers fro the first call will have the link to the next call in them, this includes the appropriate token needed, you can just take the link that is for the next page and do a get, or you can parse the link to extract the token value then use it to build your next request.

 

If you look at the explanation here https://developer.cisco.com/meraki/api-v1/pagination/#example it shows the link headers fro the initial call, and then how to use the 'next' link to get the next page of data and so on. You can see the parameter names and correct token values there for the first/next/last pages...

 

<https://api.meraki.com/api/v1/networks/N_1234/bluetoothClients?perPage=5&startingAfter=0>; rel=first,
<https://api.meraki.com/api/v1/networks/N_1234/bluetoothClients?perPage=5&startingAfter=105>; rel=next,
<https://api.meraki.com/api/v1/networks/N_1234/bluetoothClients?perPage=5&endingBefore=0>; rel=last

 

 

 

View solution in original post

8 Replies 8
Luke01
Here to help

Is there another API that I can call, by using the client MAC and find the Network ID that the client is currently connected?

sungod
Kind of a big deal

You can iterate through networks with https://developer.cisco.com/meraki/api-v1/get-network-clients/ and specify the MAC of the client.

 

This would be an alternate way of finding out which networks have seen a client, you can specify the lookback period up to 31 days ago.

Luke01
Here to help

When I was using API v0, that was the way I found the currently connected client.  I was happy that API v1 had search client.  It made my customer app much faster.  I will keep the iteration as last resort.  thx

@sungod 

sungod
Kind of a big deal

perPage sets how many records per page are returned, if there are more records than can fit on the page then further calls must be made to get the page(s) of remaining data, see https://developer.cisco.com/meraki/api-v1/pagination/  If you use the Meraki Python library it will handle the page processing for you.

 

I've not tried this call, but client history is not kept forever, as the call has no from-to settings it presumably returns whatever is available up to some limit, perhaps it's 3, but Meraki would need to confirm, if you don't get the answer here I'd try opening a support case requesting the details of any limits.

 

If the list of client MACs you are interested in is fixed, a workaround would be do the query regularly, daily for instance, and build up a long term history.

 

General thoughts...

 

Do any of the networks have Client Privacy set to expire data after a time? It can be set as short as 1 day (I think this may only be a config option on EU hosted orgs).

 

Devices using MAC randomisation will also limit their visibility.

 

There're details on retention times for different info here... https://documentation.meraki.com/General_Administration/Privacy_and_Security/Cloud_Data_Retention_Po... ...it doesn't look like client info would be deleted within a week, so probably not the cause of what you are seeing.

 

Luke01
Here to help

Our customer desktop app is .NET framework.  The API mentioned perPage is default 5, how only 3 records items are returned, even when I try to change the perPage value.

sungod
Kind of a big deal

perPage is the maximum number of results that may be returned per page.

 

For the API call you mention, I'd expect the result to be at most one of the structure below. The way the call is documented I can't see how it would return more than one. The list of clients is within the records[] element of the structure, which would not be paginated, i.e. the value of perPage makes no difference.

 

{
    "clientId": "k74272e",
    "mac": "22:33:44:55:66:77",
    "manufacturer": "Apple",
    "records": [
        {
            "network": {
                "id": "N_24329156",
                "organizationId": "2930418",
                "name": "Main Office",
                "timeZone": "America/Los_Angeles",
                "tags": [ "tag1", "tag2" ],
                "productTypes": [
                    "appliance",
                    "switch",
                    "wireless"
                ],
                "enrollmentString": "my-enrollment-string",
                "notes": "Additional description of the network",
                "isBoundToConfigTemplate": false
            },
            "description": "Miles's phone",
            "os": "iOS",
            "user": "milesmeraki",
            "ip": "1.2.3.4",
            "ip6": "2001:db8:3c4d:15::1",
            "firstSeen": 1518365681,
            "lastSeen": 1526087474,
            "vlan": "255",
            "switchport": null,
            "wirelessCapabilities": "802.11ac - 2.4 and 5 GHz",
            "smInstalled": true,
            "ssid": "My SSID",
            "clientVpnConnections": [
                {
                    "remoteIp": "1.2.3.4",
                    "connectedAt": 1522613355,
                    "disconnectedAt": 1522613360
                }
            ],
            "lldp": [
                [
                    "System name",
                    "Some system name"
                ],
                [
                    "System description",
                    "Some system description"
                ],
                [ "Port ID", "1" ],
                [
                    "Chassis ID",
                    "00:18:0a:00:00:00"
                ],
                [
                    "Port description",
                    "eth0"
                ],
                [
                    "System capabilities",
                    "Two-port MAC Relay"
                ]
            ],
            "cdp": null,
            "status": "Online"
        }
    ]
}

 

Luke01
Here to help

@sungod 

 

Thanks for all the info.  Yes, the issue is related to pagination with the API endpoint. 

 

My .NET custom app calls the REST API to gather the information needed.   I will have to use "startingAfter" OR "endingBefore" to get more networks in response from the endpoint ?  Should I use epoch timestamp?  The doc talks about ID token, but I have no idea what that token would be.

 

I can’t figure out how to do pagination, without using the Meraki Python library.  Any tips or help would be great.  I know I am very close to solution, just need to find the last piece of puzzle.

sungod
Kind of a big deal

Note that the API call documentation says...

 

A token used by the server to indicate the start of the page. Often this is a timestamp or an ID but it is not limited to those. This parameter should not be defined by client applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.

 

The link headers fro the first call will have the link to the next call in them, this includes the appropriate token needed, you can just take the link that is for the next page and do a get, or you can parse the link to extract the token value then use it to build your next request.

 

If you look at the explanation here https://developer.cisco.com/meraki/api-v1/pagination/#example it shows the link headers fro the initial call, and then how to use the 'next' link to get the next page of data and so on. You can see the parameter names and correct token values there for the first/next/last pages...

 

<https://api.meraki.com/api/v1/networks/N_1234/bluetoothClients?perPage=5&startingAfter=0>; rel=first,
<https://api.meraki.com/api/v1/networks/N_1234/bluetoothClients?perPage=5&startingAfter=105>; rel=next,
<https://api.meraki.com/api/v1/networks/N_1234/bluetoothClients?perPage=5&endingBefore=0>; rel=last

 

 

 

Get notified when there are additional replies to this discussion.