Pagination

In this guide, we will look at how to work with paginated responses when querying the Collctiv API. By default, all responses limit results to ten. However, you can go as high as 100 by adding a limit 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 and have a has_more attribute that indicates whether you have reached the end of the last page. You can use the page query parameter to browse pages.

Example using cursors

In this example, we request the second page. As a result, we get a list of three users and can tell by the has_more attribute that we have reached the end of the resultset.

  • Name
    page
    Type
    number
    Description

    The number of the page you wish to fetch starting at 1

  • Name
    limit
    Type
    integer
    Description

    Limit the number of items returned.

Manual pagination using cURL

curl -G https://api.collctiv.com/v1/users \
  -H "Authorization: Bearer {token}" \
  -d page=2 \
  -d limit=3

Paginated response

{
  "has_more": false,
  "data": [
    {
      "id": "WAz8eIbvDR60rouK",
      // ...
    },
    {
      "id": "hSIhXBhNe8X1d8Et"
      // ...
    },
    {
      "id": "fbwYwpi9C2ybt6Yb"
      // ...
    },
  ]
}

Was this page helpful?