Using Pagination in the API to Efficiently Retrieve Large Datasets
When accessing large datasets through the API, it’s essential to manage data retrieval efficiently. Pagination is a technique that divides a large dataset into smaller, manageable chunks or “pages.” This approach enhances performance and prevents overwhelming both the client and server with excessive data in a single request.
Each request retrieves a maximum of 100 records. Use the offset parameter to specify the number of records to skip before starting the return.
Query | Type | Description |
---|---|---|
offset | number | Indicates the number of records to skip |
Example Query Params:
curl --request GET \
--url 'https://api-prod-us-west-2.solinkcloud.com/v2/reports?offset=100' \
--header 'Authorization: Bearer {ACCESS_TOKEN} ' \
--header 'accept: application/json' \
--header 'x-api-key: {API_KEY}'
Here offset is set to 0, meaning retrieval starts from the first record.
Pagination in Action
To retrieve the entire dataset, loop through the data by incrementally adjusting the offset based on the set 100 limit until all records are fetched.
First Request: offset= 0 - Retrieves records 1 to 100.
Second Request: offset=100 - Retrieves records 101 to 200.
Subsequent Requests: Continue incrementing the offset by 100 until all records are retrieved.