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.
Offset-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:
- Page 1:
/api/v1/lead/?_skip=0&_limit=100 - Page 2:
/api/v1/lead/?_skip=100&_limit=100 - Page 3:
/api/v1/lead/?_skip=200&_limit=100
The 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.
Deep Pagination
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.
Cursor-Based Pagination
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:
- Advanced Filtering API - uses
cursorand_limitin the request body - Events API - uses
_cursorand_limitquery parameters
See each endpoint's documentation for specific pagination details.