Skip to main content

Pagination

When calling a list method which returns multiple results, such as GET /v1/customers, it is common that not all the results will be returned in one page and you will need to paginate to retrieve all the results. Metronome provides two URL parameters on all list endpoints that help with this.

  • limit - The limit parameter can be used to customize how many results are returned per page. If you want to make a quick API call to inspect the response format, you could set limit=1, but if you want to try to load many results with as few API calls as possible, you could set limit=50. For performance reasons, limit is capped at 100.
  • next_page - Allows the client to provide a next_page cursor from a prior request to fetch the next set of results.

When a set of results are returned, the response will optionally contain a next_page field. If this is present, it should be sent along in the query on the next request to fetch the next set of results.

Example‚Äč

GET /v1/customers?limit=10
{
"data": [
{
"id": 1
},
{
"id": 2
},
// ...
]
// The next_page cursor that can be passed in the URL to get the next
// set of results.
"next_page": "0c34b75b47491b73db66d46737d9a87"
}

Given the above response, you can provide the next_page cursor with the next request.

GET /v1/customers?limit=10&next_page=0c34b75b47491b73db66d46737d9a87
{
"data": [
{
"id": 3
}
],
// Since no next_page value was returned, this is the last page of results.
"next_page": null
}