Custom relative URI pagination method
Overview
Each page is denoted by the ID of the last object it holds, rather than its page. For example, if a 'page' returns 10 customers, then the ID of the last customer will be passed in the URL to get the next page.
Custom relative URI options
Option | Summary |
---|---|
Link parameter path | Enter the dot notation path for the data element in your response which contains the maximum number of items that the API should return in a single page of a paginated response. Commonly (though not necessarily), this would be a path to a |
Last ID parameter name | Enter the name of the query parameter to be passed into the URL to tell the receiving system the last record we received (so the receiving system knows where to start for the next page of data to return). A commonly used name is: |
Limit | Enter the number of items to be returned per page. For example: |
ID key | Enter the unique identifier key for each item in your data. For example, if the endpoint is pulling a list of users, this might be: |
Example
Suppose we set the following options:
Option | Value |
---|---|
Link parameter path |
|
Last ID parameter name |
|
Limit |
|
ID key |
|
The following URL will be generated to get the first page:
Notice our link parameter path (limit
) and the actual limit value (10
) at the end of the request. Our first page would look something like the example below:
When pagination runs, it will look for the last id
key in the payload, and use that as the starting point for the next request. So the request for page 2 will be:
Notice our link parameter path (limit
) and the actual limit value (10
) at the end of the request, followed by our Last ID parameter name (starting_after
) set to the last id
in the response.
A sample response for this request is below:
When does pagination stop?
Pagination continues until the the number of items in the payload is less than the limit, or the page returns an error code.
Last updated