Enode endpoints returning collections of a specific type of resource, such as GET /vehicles, will return a paginated response. Each response will consist of a subset of the resources, called a page. To retrieve the entire collection, subsequent pages need to be fetched.
Each response includes two properties: data and pagination. The data property contains the records of the current page and the pagination property contains cursors that can be used to fetch additional pages. These cursors, before and after, are unique identifiers for specific records in the dataset that help you keep track of your position and navigate through the pages.
Copy linkQuerying a paginated API endpoint
When querying a paginated endpoint, you may provide the following pagination query parameters:
{
"pageSize": 50,
"before": "MjAyMy0wNy0xOFQxMDowODowMi4zNzNa",
"after": "MjAyMy0wNi0xNlQwOTowMzowMS4yNjJa"
}
All of these pagination query parameters are optional. If pageSize is not provided, the default page size of 50 is used. If neither before nor after are provided, the returned page will contain the first set of resources in the collection.
The before and after parameters are mutually exclusive. If both are supplied, the API will return an error.
Responses from most paginated endpoints are sorted in descending order according to when the resource was created. Hence, for a request like GET /vehicles, the most recently linked vehicles appear on the first page.
Copy linkHow to navigate through paginated API responses
The pagination property in a paginated response typically looks like this:
"pagination": {
"before": "MjAyMy0wNy0xOFQxMDowODowMi4zNzNa",
"after": "MjAyMy0wNi0xNlQwOTowMzowMS4yNjJa"
}
The pagination property provides the cursors required to fetch the next and previous pages of resources:
before contains the cursor to be used to fetch the previous page.after contains the cursor to be used to fetch the next page.
One or both cursors may be null instead of a string. This occurs when:
- You are on the first page. There are no preceding resources, so
before will now be null as otherwise it would point to an empty page. - You are on the last page. There are no subsequent resources, so
after will now be null as otherwise it would point to an empty page. - The entire collection fits on the first page. There are no preceding or subsequent resources, so both
before and after are null.
Copy linkFull example response
{
"data": [
{
"id": "0",
"vendor": "TESLA",
...
"isReachable": true
},
...
{
"id": "49",
"vendor": "TESLA",
...
"isReachable": true
}
],
"pagination": {
"before": null,
"after": "MjAyMy0wNy0xOFQxMDowNDowMi4zNzNa"
}
}
In this example, the data array includes the resource records for the current page. The pagination object provides the cursors for navigating to adjacent pages.