Pagination in Postman

Here to help

Pagination in Postman


Anyone solved pagination in postman?

Meraki Employee
Meraki Employee

What problem does postman has with pagination?


Example, if you run - organizations/:organizationId/networks

It gives you 1000 networks and I haven't found any way to handle the next pages with 1000 more. 

in python its no problem - but just dont know how to activate it or fix it in postman

Meraki Employee
Meraki Employee

In the response headers, you will find a "link" field specifying the links to the first, last, next, and previous "pages".



Here to help

Yes, i understand this - but is it possible to load the rest inside the postman call so the list will be complete?


Meraki Employee
Meraki Employee

I have a pagination solution 🙂

There is not really an easy way to do this with Postman natively, but I created a script you can add to your Collection "Tests". It will perform some magic on every API request by extracting the link string in the header.

I posted a copy of the script in my github for now.



Example showing the usage with {{endingBefore}} environment variable via this script





This script is designed to handle pagination in APIs by extracting the necessary information from the Link header of the HTTP response. It then sets the startingAfter and endingBefore environment variables in Postman which can be used as query parameters for subsequent API calls to navigate through paginated data.

How to Use:

  1. Add this script to the "Tests" section of your Postman request or to the entire collection.
  2. Make an initial API call to an endpoint that supports pagination.
    1. /networks/:networkId/events?productType=wireless&perPage=3
  3. If the response contains a Link header with pagination links, the script will parse it and set the startingAfter or endingBefore environment variables.
  4. Use one of these environment variables in your Postman collection as a query parameter for the remaining pagination calls.
    1. /networks/:networkId/events?productType=wireless&perPage=3&endingBefore={{endingBefore}}
  5. Keep hitting "Send" until you've reached the end of the pages

Script Details:

The script primarily consists of a function parseLinkHeader that processes the Link header from the HTTP response, and a main block that checks for the presence of the Link header, extracts the pagination links, and sets the environment variables.

Example of script in the Tests sectionExample of script in the Tests section



Let me know if this works for you. If it this seems like a doable solution, we could possibly add it to the Meraki collection by default. 

That seems to work like a charm, just tested it on getOrganizationNetworks

It gets the last networkID of the 1000 networks, and set the startingAfter to the ID L_xxxxxxxxxxxx107400


Ending before is set to the FIRST network of the second call, is that correct? (Didnt use endingBefore)

Very good work! Thx

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.