Pagination
To ensure Chargetrip API remains performant and responsive, pagination is used to limit the amount of information that can be returned in list queries within a single request.
Supported pagination types
Currently, two types of pagination are used across the API.
- Cursor-based (New): Chargetrip's new pagination standard. All newly developed list queries will implement this pagination type.
- Offset-based (Legacy): Chargetrip's legacy pagination standard, still used in most of the existing list queries. These operations will eventually be deprecated and replaced by cursor-based versions.
Cursor-based pagination
Cursor pagination lets you define the starting point of each request via a unique identifier - cursor - for fetching the next set of results. Furthermore, the response format for this method differs from the legacy offset-based approach.
Arguments
first(Integer): The number of items to return.after(String): The cursor frompage_info.end_cursorreturned in the previous request. To fetch the first page, omit or set this argument tonull.
Limits: first is limited to 100, except for the getRouteStationsWithAmenities query, which is limited to 10 items. If the first argument exceeds these limits, an error is returned.
Example cursor-based pagination request / vehicleModels query
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
// First requestvehicleModels(first: 12) { total_count page_info { has_next_page has_previous_page start_cursor end_cursor } nodes { name } } // Following requestsvehicleModels(first: 12 ,after:"eyJwYWdlIjoyfQ==" ) { total_count page_info { has_next_page has_previous_page start_cursor end_cursor } nodes { name } }
Output
The cursor-based response format is inspired by Relay's Connection Pattern, providing both the data (nodes) and the metadata (page_info) required for subsequent requests. To provide a better developer experience, the "edges" layer found in the standard Relay pattern is omitted, and data is returned directly through the nodes array.
| Field | Description |
|---|---|
| nodes Array | List of the actual data objects returned for the current page. |
| total_count Integer | Total number of items available in the entire dataset matching the query. |
| page_info.has_next_page Boolean | Indicates if more results are available after the current page. |
| page_info.has_previous_page Boolean | Indicates if more results are available before the current page. |
| page_info.start_cursor String | The cursor of the first node in the nodes list. |
| page_info.end_cursor String | The cursor of the last node in the nodes list. Use this as the after argument in your next query. |
Example cursor-based pagination response / vehicleModels query
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
//vehicleModels(first: 2 ,after:"eyJwYWdlIjoxfQ==" ){ "data": { "vehicleModels": { "total_count": 510, "page_info": { "has_next_page": true, "has_previous_page": false, "start_cursor": "eyJwYWdlIjoxfQ==", "end_cursor": "eyJwYWdlIjoyfQ==" }, "nodes": [ { "name": "500e" }, { "name": "600e" } ] } }}
Offset-based pagination (Legacy)
Offset-based pagination uses page as an offset to determine the starting point of data to fetch and a size to limit the number of results returned.
Arguments
size(Integer): The number of items to receive per page.page(Integer): The page number to fetch. To fetch the first page, omit or set this argument to 0.
Limits:
The size is limited to 100. If the size argument exceeds these limits, an error is returned.
Example offset-based pagination request / vehiclesList query
- 01
- 02
- 03
- 04
- 05
- 06
vehicleList(size: 2, page: 2) { id region purpose type }
Output
The response returns directly a list of data results, limited by the size value.
Example offset-based pagination response / vehiclesList query
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
vehicleList(size: 2, page: 2){ "data": { "vehicleList": [ { "id": "6731c0d20e68fb49fcfcfc43", "region": [ "EU" ], "purpose": "passenger", "type": "car" }, { "id": "6707980511eb0435fbf01724", "region": [ "NA", "AS" ], "purpose": "passenger", "type": "car" } ] }}