Pagination

In this guide, we will look at how to work with paginated responses when querying the OneCal API. By default, all list responses limit results to 100. However, you can change this by adding a pageSize query parameter to your requests.

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. To know whether or not there are more pages, pageSize * pageNumber should be less than or equal to the total property.

Example using query parameters

In this example, we request the second page of memberships with a page size of 10.

  • Name
    pageSize
    Type
    integer
    Description

    The number of items to return per page.

  • Name
    page
    Type
    integer
    Description

    The page number to return.

Manual pagination using cURL

curl -G https://app.onecal.io/api/v1/memberships?pageSize=10&page=2 \
  -H "x-api-key: {API KEY}"

Paginated response

{
  "total": 100,
  "pageSize": 10,
  "pageNumber": 2,
  "data": [
    {
      "id": "cm7f3cfb000000clbc8pk5qtr",
      // ...
    },
    {
      "id": "cm7f3cijk00010clbbz0kdt2h"
      // ...
    },
    {
      "id": "cm7f3clnq00020clbg09q9fj7"
      // ...
    }
  ]
}

Was this page helpful?