Pagination in Search APIs

Find out how to return specific results from a collection returned in a response

Overview

When using methods allowing search for multiple records from the library (Search APIs), the maximum number of records that can be retrieved in a single response is 100. The total number of records matching the search criteria supplied in the request to a method will be returned in the X-Total-Count value of the response.

Search APIs can return paginated results using the limit and offset values available in the request. A paginated request returns a portion of the total set of results based on the numeric limit specified and a numeric offset value that specifies the number of records to skip before returning results. To retrieve a specific number of records, set a Limit value that specifies the number of records to return. To retrieve a specific number of records starting from a specific record in the collection, set a limit that specifies the number of records to return, and a numeric offset value that specifies how many records to skip before including results in the response.

For example, if you set the limit query parameter to 10 and the search results returned in a response contains 20 objects, the first call will return information about the first 10 objects. To return the next portion of results, in the next request to this method, set an offset value of 10. This will skip the first 10 records and return results from this point onwards up to the specified limit.

The maximum (and default) page size returned is 100 results.

Examples

To fetch just the first 10 contracts

GET /api/v1/contracts?limit=10

To fetch the next 10 contracts...

GET /api/v1/contracts?limit=10&offset=10

To see the total item count while fetching a page of contracts, using the JavaScript fetch API

const response = await fetch('/api/v1/contracts'); // First 100 contracts...
const totalCount = response.header['X-Total-Count']