Pagination
In this guide, we will look at how to work with paginated responses when querying the FuelPrice API.
When an API response returns a list of objects, no matter the amount, pagination is supported. In paginated responses, objects are nested in a data attribute and have a total_items attribute that indicates how many items are returned in the current response.
Supported Pagination Parameters
In this example, we request page 2 of the list of cities.
- Name
limit- Type
- integer
- Description
Limit the number of items returned. Also referred to as 'limit per page'. Default: 10
- Name
page- Type
- integer
- Description
The page number to return. Can be used instead of
offset.
- Name
offset- Type
- integer
- Description
Amount of items to offset by - Cannot be used with
page.
Manual pagination using cURL
curl -G https://api.fuelprice.io/v1/cities \
-H "Authorization: Bearer {token}" \
-d page=2 \
-d limit=50
Paginated response
"data": {
"agnes-water": {
"id": "agnes-water",
"name": "Agnes Water",
"state": "qld"
},
"ayr": {
"id": "ayr",
"name": "Ayr",
"state": "qld"
},
// ...
},
"total_items": 45,
"total_pages": 9,
"current_page": 2
