In this method, the required page number is included as a parameter in the API request, and is incremented in each request to get the next page.
Option | Summary |
---|---|
Suppose we set the following options:
Option | Value |
---|---|
...and we send a request to get the first page of data:
The response will include the first page of data (sometimes with metadata regarding pagination). For example:
Our request for the next page of results would be:
Pagination continues until the last page, when there is no more data to return.
The page number parameter pagination method is implemented using a Patchworks pagination variable which contains the next page number:
This note is for reference only - there should never be a need to access/change this variable.
Limit parameter name
Enter the name of the query parameter to be passed into the URL to tell the receiving system the maximum number of items that the API should return in a single page of a paginated response. A commonly used name is: limit
but total
or count
are also popular.
Limit parameter path
Enter the dot notation path to the limit parameter name.
Page parameter name
Enter the name of the query parameter to be passed into the URL to tell the receiving system the required page number. A commonly used name is: page
.
Limit
Enter the number of items to be returned per page. For example: 10
.
Path to the data in the response
If required, you can add a dot notation path to an element in the payload that you would expect to contain data if the data pull has not completed. For example, if you are pulling orders, you might expect to see data in an orders
element of the response.
This is a 'belts and braces' option to handle edge cases where a system continues to send data of some type, even when there is no more required data to be pulled - so pagination would never stop. If you don't want to use this option, click the allow empty button.
Limit parameter name
limit
Page parameter name
page
Limit
10
Path to the data in the response
data