When requesting a large data set from the Fleetio API, the data set is returned in chunks, instead of all at once. This is a common pattern for API's that allow them to return query results rapidly and without putting unnecessary strain on the database. Each chunk of results is called a page.
In Fleetio, paging is used for all index actions. The current page size is set to 100, but it is subject to change at any moment, 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.
|X-Pagination-Limit||The per page limit. Currently 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, simply 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 there is no
page parameter, it 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 simply return an empty result set.