Pagination
To ensure the Chargetrip API remains performant and responsive, pagination is used to limit the amount of data returned in list queries within a single request.
Supported pagination types
Currently, two pagination types 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 existing list queries. These operations will eventually be deprecated and replaced by cursor-based versions.
Cursor-based pagination
Cursor pagination allows you to define the starting point of each request using a unique identifier - the cursor - to fetch the next set of results. Moreover, 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 starting cursor to fetch the next set of results. For the first page, omit this argument or set it tonull. For the subsequent pages, use thepage_info.end_cursorvalue returned in the previous request.
Limits: The value of first cannot exceed 100, except for the getRouteStationsWithAmenities query, which is limited to 10. If these limits are exceeded, 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 improve the developer experience, the edges layer found in the standard Relay pattern is omitted, and the 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 whether more results are available after the current page. |
| page_info.has_previous_page Boolean | Indicates whether 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. Set the after argument with this value 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 relies on relative positioning to navigate a dataset. It uses the page parameter to skip a set number of records and the size parameter to return a fixed window of results.
Arguments
size(Integer): The number of items to receive per page.page(Integer): The page number to fetch. To fetch the first page, omit this argument or set it to 0.
Limits:
The size is limited to 100. If the size argument exceeds this limit, 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 a list of data results directly, 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" } ] }}