Pagination
How to paginate through Close API results using offset-based and cursor-based pagination.
How to paginate through Close API results using offset-based and cursor-based pagination.
Close API uses two different pagination methods depending on the endpoint. Most list endpoints use offset-based pagination, while some specialized endpoints use cursor-based pagination.
Most list endpoints (e.g., /api/v1/lead/, /api/v1/contact/) use _limit and
_skip parameters to paginate through results. For example, the first three
pages for the lead resource (100 records per page) are:
/api/v1/lead/?_skip=0&_limit=100/api/v1/lead/?_skip=100&_limit=100/api/v1/lead/?_skip=200&_limit=100The response contains two fields: data containing the list of objects and
has_more, which indicates if you reached the last page.
Additionally, there is a maximum limit that can vary per resource. You will get a 400 response with an appropriate message if you exceed it.
If you’re planning to iterate through a long list of results (for example, all
leads, contacts, or activities within your organization), doing so using _skip
and _limit is going to be inefficient at best or outright impossible at worst.
Close API has a maximum _skip limit which varies per resource.
If you need to paginate for more than a few pages, update your query to return
smaller batches of objects. A popular method to do this is to use the
date_created field as a range, and make multiple requests while incrementing
or decrementing the date.
Another option for extracting a larger portion of your data out of Close efficiently is to request its export via the Export API.
Some endpoints use cursor-based pagination instead of offset-based. With cursors, you pass a cursor token from the previous response to fetch the next page of results. This avoids issues with data changing between requests.
The following endpoints use cursor-based pagination:
cursor and _limit in the request body_cursor and
_limit query parametersSee each endpoint’s documentation for specific pagination details.