Limit-offset pagination method
Overview
This method is similar to the page number parameter approach. However, instead of appending a page number to the request URL, an offset parameter is used to indicate how many results have been returned so far (i.e. the start point for required data).
This method is rather like a database search: give me 5 records starting from the 15th record.
Limit-offset options
Option | Summary |
---|---|
Limit 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 |
Offset parameter path | Enter the dot notation path for the data element in your response which contains the required offset - i.e. how many items should be skipped before the next page starts. Commonly (though not necessarily), this would be a path to a |
Limit | Enter the number of items to be returned per page. For example: |
Count parameter path | If required, enter the dot notation path for the data element in your response which contains the current count of records that have come back from the system. Commonly (though not necessarily), this would be a path to a |
Total parameter path | Enter the dot notation path for the data element in your response which contains the total number of records that will be returned in this response, so we know when to stop paginating. Commonly (though not necessarily), this would be a path to a |
Example
Suppose we set the following options:
Option | Value |
---|---|
Limit parameter path |
|
Offset parameter path |
|
Limit |
|
Count parameter path |
|
Total parameter path |
|
...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:
Requests for subsequent pages would increment the offset
value by the limit
value - for example:
...and then:
...and so on until 50 items (i.e. the total parameter path value
) are returned.
When does pagination stop?
Pagination continues until the last page, when there is no more data to return.
Special notes
The limit offset pagination method is implemented using a Patchworks pagination variable which contains the next page offset:
This note is for reference only - there should never be a need to access/change this variable.
Last updated