Skip to main content

Pagination

To ensure efficient data retrieval and manageability, the Emogg REST API implements cursor-based pagination for all endpoints that return lists of data. This system allows clients to fetch subsets of data, making it easier to handle large datasets and improve the responsiveness of applications using the API.

Requests

Clients can control pagination through two query parameters:

ParameterTypeDescription
limitnumberDetermines the number of items per page. Accepts values between 1 and 100. If not specified, it defaults to 10.
offsetnumberSpecifies the starting point for the data returned, effectively controlling the page being accessed. Defaults to 0.

Example

Here's how you might request the second page of sessions, assuming you want 10 sessions per page:

curl -X GET "https://api.emogg.com/v1/sessions?limit=10&offset=10" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Responses

The JSON response for any paginated endpoint will include four key fields:

FieldTypeDescription
hasMoreboolA boolean indicating whether there are additional pages of data available after the current page.
dataarrayAn array containing the data for the current page.
offsetnumberThe index of the first item on the current page, relative to the full dataset. This effectively indicates how many items precede the current page.
limitnumberThe maximum number of items returned in each page. This can be set by the client and defaults to 10.

Example

This is an example response for the previous request:

{
"hasMore": true,
"data": [
{
// Session object
},
// Additional session objects
],
"limit": 10,
"offset": 10
}

Tips

Adjusting page size

If you're dealing with rate limits or fetching large amounts of data but want to minimize the number of requests, consider increasing the limit to its maximum. Conversely, for quicker responses, a smaller limit may be preferable.

Handling large offsets

For performance reasons, directly accessing very high offset values (e.g., in the thousands) may be slower. Consider alternative strategies for such cases, like filtering by date or other attributes if supported by the API.