Pagination

In this guide, we will look at how to work with paginated responses when querying the SaaS Custom Domains API. By default, all responses limit results to 20 per page.

When an API response returns a list of objects, no matter the amount, pagination is supported. In paginated responses, objects are nested in a data attribute and have a pagination attribute that holds the information about what page has been returned and the number of items in the collection. You can use the page query parameter to browse pages — pages start from 1.

Example

In this example, we request the second page of our upstreams. As a result, we get a list of 20 upstreams.

  • Name
    page
    Type
    integer
    Description

    The page number to return. Defaults to 1.

Manual pagination using cURL

curl -G https://app.saascustomdomains.com/api/v1/accounts/:account_uuid/upstreams \
  -H "Authorization: Bearer {token}" \
  -d page=2

Paginated response

{
  "records": [
    {
      "uuid": "upstream_21",
      // ...
    },
    {
      "uuid": "upstream_22"
      // ...
    },
    // ...
    {
      "uuid": "upstream_40"
      // ...
    },
  ],
  "pagination": {
    "page": 2,
    "count": 237
  }
}