Pagination

For endpoints that return several records, such as the Get Products endpoint, it is often necessary or desirable to partially retrieve the results. This is done through pagination cursors.

For each endpoint that supports pagination, the two query parameters cursor and results are supported. The corresponding response from the endpoint will contain the fields next_cursor and previous_cursor. They are used as follows:

  • results: Specifies the maximum number of results that should be returned by a given endpoint. By default, the minimum value is 10, and the maximum value is 100. Any numbers that fall outside this will use the nearest acceptable value, or otherwise return an error.

  • cursor: This is a string that internally references a specific record in the set of results that the server retrieved. By passing this parameter, the records that are returned represent those that come after that specific record. Cursors are provided by the next_cursor and previous_cursor fields in the response.

The next_cursor and previous_cursor fields can be thought of as references to pages - passing the string from next_cursor to the cursor query parameter will return the next page of results, and vice versa for the previous_cursor. If no next or previous page is available, the fields will be null instead of containing a cursor.

If interested in learning more about cursor pagination, Slack has provided a good writeup of the types of pagination and how cursor pagination works.