Page number parameter pagination method

Overview

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.

Page number parameter options

Option
Summary

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.

Example

Suppose we set the following options:

Option
Value

Limit parameter name

limit

Page parameter name

page

Limit

10

Path to the data in the response

data

...and we send a request to get the first page of data:

GET https://my.shop/api/customers?limit=10&page=1

The response will include the first page of data (sometimes with metadata regarding pagination). For example:

{
  "data": [
    {"id": 1, "name": "Alice"},
    {"id": 2, "name": "Bob"},
    {"id": 3, "name": "Charlie"},
    {"id": 4, "name": "Lyn"},
    {"id": 5, "name": "John"},
    {"id": 6, "name": "Gordon"},
    {"id": 7, "name": "Izzy"},
    {"id": 8, "name": "Mike"},
    {"id": 9, "name": "Ralph"},
    {"id": 10, "name": "Rex"}
  ],
  "meta": {
    "totalItems": "150",
    "itemsPerPage": "10"
  }
}

Our request for the next page of results would be:

GET https://my.shop/api/customers?limit=10&page=2

When does pagination stop?

Pagination continues until the last page, when there is no more data to return.

Special notes

The page number parameter pagination method is implemented using a Patchworks pagination variable which contains the next page number:

<PageNo>[[pagination.page]]</PageNo>

This note is for reference only - there should never be a need to access/change this variable.

Last updated