Filtering and Sorting Usage Examples
The new filtering and sorting methods only exist in API versions starting with 2024-01-01
. They can be identified by the response, which returns an object with pagination data, applied filters and sorts, and the array of records in the records
attribute.
New index endpoints which accept the filter
and sort
query parameters
You may use the documented filter & operator combinations, and the documented sorts.
Get all Vehicles with a license plate containing "yz":
https://secure.fleetio.com/api/v1/vehicles?filter[license_plate][like]=yz
Get all contacts with the email matching "foo@example.com":
https://secure.fleetio.com/api/v2/contacts?filter[email][eq]=foo@example.com
Get all work orders assigned to the contact with the id 123:
https://secure.fleetio.com/api/v2/work_orders?filter[contact_id][eq]=123
Older endpoints that do not accept filter
and sort
query parameters
You can apply filters to any of our original index
endpoints.
Get all Fuel Entries since January 1, 2016:
https://secure.fleetio.com/api/v1/fuel_entries?q[created_at_gteq]=2016-01-01
Get all Submitted Inspection Forms from January 1, 2016:
https://secure.fleetio.com/api/v1/submitted_inspection_forms?q[submitted_at_gteq]=2016-01-01&q[submitted_at_lt]=2016-01-02
Get all Meter Entries where the void flag is set to true:
https://secure.fleetio.com/api/v1/meter_entries?q[void_true]=1
Get all Work Orders with status names containing the word 'priority':
https://secure.fleetio.com/api/v2/work_orders?q[work_order_status_name_cont]=priority
Get all blue Vehicles with a fuel type of Diesel, sorted by year descending:
https://secure.fleetio.com/api/v1/vehicles?q[color_eq]=blue&q[fuel_type_name_matches]=diesel&q[s]=year+desc
Want to know if the number of Freds you have working in your company is too high?
https://secure.fleetio.com/api/v1/contacts?q[first_name_eq]=Fred
The possibilities are endless!*
*Possibilities actually finite