get full org inventory with curl api


get full org inventory with curl api

I am trying to pull a full inventory using curl I am only getting 1000 of 2750 devices in our inventory. I am completely new to scripting and API.


Here is what I am doing so far...

/usr/bin/curl -L -H 'X-Cisco-Meraki-API-Key: [API KEY]' -H 'Content-Type: application/json' -X GET '[org id[/inventoryDevices' | jq ".[] | [.serial, .mac, .model, .orderNumber, .claimedAt] | @CSV" | sed -e 's/"//g' | tr -d '\\' > test.csv


I am getting all of the values of each line, but it stops at 1000. How do I get the full inventory?

2 Replies 2
Kind of a big deal
Kind of a big deal

In the documentation, you'll see that it returns 1000 entries "per page".!get-organization-inventory-devices 


On the first call you'll get a token (sorry, not sure what it is in the header, but take a look) and then you call it again with the startingAfter parameter, and you get the next 1,000 entries.  Repeat until you have everything.


This will be a bit manual to do with curl ... Python would be a better bet.  The Python SDK does the pagination for you so you can ignore this.!python/meraki-dashboard-api-python-library 

Thanks for the reply. I planned to learn python. I thought this would be a quick ash script. Not turning out that way. lol When I run the


/usr/bin/curl -L -H 'X-Cisco-Meraki-API-Key: [key]' -H 'Content-Type: application/json' -X GET '[org ID]/inventoryDevices?perPage=1000&startingAfter=0;rel=first' > curl-test


I just get the data in json format. There is no header info with any tokens.

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.