Pagination
The Fleetio API returns data set in pages, instead of all at once. This common API pattern allows us to efficiently return query results without putting unnecessary strain on our resources.
In Fleetio, all index
actions return paginated responses. Each page will contain up to 100
items—this number may change though, so don't code yourself into a wall by hardcoding 100
as the expected page size. Fleetio returns four response headers along with the result set to help you work with the paginated data.
Header | Description |
---|---|
X-Pagination-Limit | The per page limit. Set to 100 but subject to change at any time. |
X-Pagination-Current-Page | The current page. Defaults to 1 . |
X-Pagination-Total-Pages | The total number of pages in the result set. Use this along with |
X-Pagination-Total-Count | The total number of records in the result set (across all pages). |
To retrieve data for a specific page, specify the page
query parameter as in the example below.
# Get the second page of results for the vehicles index action.
curl \
--header "Authorization: Token YOUR_API_KEY" \
--header "Account-Token: YOUR_ACCOUNT_TOKEN" \
"https://secure.fleetio.com/api/v1/vehicles?page=2"
Pages start at 1
. If the request does not include a page
parameter, the server will return the first page of results. If the page
parameter is less than 1
, it will also return the first page of results. If the page
parameter is greater than Pagination-Total-Pages
, it will return an empty result set.