Not getting full results when running API's

mrheavydee95
Comes here often

Not getting full results when running API's

 I'm having issues getting all the results when running API calls when I run them via the developer site and Postman.  When I run "Get Organization Devices" its not displaying all devices (2100+).  I tried the per-page param to 50 (max) and I'm still missing data.  Any suggestions?  

7 Replies 7
sungod
Head in the Cloud

The call https://developer.cisco.com/meraki/api-v1/get-organization-devices/ has a default (and maximum) per-page limit of 1,000. If you set it to 50 you'll only get 50 per page.

 

If there are more devices than will fit onto the page, you need to make further calls (following the pagination handling rules) to get the remaining page(s) of data.

 

With 2,100 devices it'll be at least 3 pages of data.

 

If you use the Python library it can handle pagination for you, otherwise you'd need to arrange it yourself.

 

Python library: https://github.com/meraki/dashboard-api-python

 

Pagination: https://developer.cisco.com/meraki/api-v1/pagination/

 

Thanks for the quick reply sungod. 

 

I looked into the Pagination but the only 2 categories it shows for the startingafter parameter are "Timestamps" and "Interger IDs".  The endpoint is showing that its looking for a string.  Any idea what they're looking for?

The values needed to navigate subsequent pages are in the link headers returned by the call.

 

It's explained in the documentation page I linked, look at the 'Example' section.

 

I.e. you need to select/parse the link headers, or take the easy way out and just use the Python Library 😀

 

I'm sure once it would be easier once I figure out Python Library (which I never used before).  I'm getting SSL errors when trying to run it with Python.

 

As a tip, I've found Google Bard good at writing Python scripts to use the Meraki API.  I'm now at the point where if I need to create something, I start with Google Bard and take it from there.  It's just a faster way to develop.

 

https://bard.google.com/

 

If you are running on Windows and getting SSL problems this thread might help...

 

https://community.meraki.com/t5/Developers-APIs/SSL-error-in-python/m-p/186146

 

I don't use it on Windows, but others do, so probably someone else can help you if the above thread doesn't resolve it.

 

I appreciate everyone's response to this thread.   

 

I tried the link you sent over sungod, I did the following and I'm still getting a cert error:

-  exported the cert from the portal and saved it locally

-  ran the verify command (verify="c:\temp\nameofcert.crt")

 

I even tried verify=False which still gave me the same SSL Cert error.  

Get notified when there are additional replies to this discussion.