Skip to main content

Filtering and Sorting Results

The Fleetio API supports query parameters for both filtering and sorting results from index endpoints.

Filtering

We use the q[] parameter to differentiate filters from regular parameters.

For example, to only return Vehicles with model year 2018 or later:

https://secure.fleetio.com/api/v1/vehicles?q[year_gteq]=2018

You can provide more than one filter to a request. The server will combine the filters using a logical AND operator. It does not support the OR operation. The best solution for this is to send several requests.

Sorting

We treat sorting as just another q[] wrapped predicate, q[s].

For example, to sort Vehicles by year in descending order:

https://secure.fleetio.com/api/v1/vehicles?q[s]=year+desc

Predicate Reference

PredicateDescriptionExample
eqEquals. Case sensitive.q[id_eq]=321
matchesField should match the given value. Similar to SQL's LIKE operator. Case insensitive.q[license_plate_matches]=wx123yz
ltLess than.q[started_at_lt]=2023-01-01
lteqLess than or equal to.q[completed_at_lteq]=2023-01-31
gtGreater than.q[discount_percentage_gt]=10
gteqGreater than or equal to.q[total_amount_gteq]=500
contContains. Used for matching partial strings.q[license_plate_cont]=23y
in_sEqual to an item in a list. Similar to SQL's IN operator. Accepts a string of comma separated values. Case sensitive.q[color_in_s]=Yellow,Green
trueBoolean operator for true. Accepts 1 as a value.q[secondary_meter_true]=1
falseBoolean operator for false. Accepts 1 as a value.q[secondary_meter_false]=1
presentNot null and not a blank string. Accepts 1 as a value.q[vin_present]=1
nullIs null. Accepts 1 as a value.q[vin_null]=1
sUsed for sorting.
Accepts attribute, attribute+asc, or attribute+desc as a value.
Defaults to asc if only attribute is passed.
q[s]=created_at+desc

Please see our Filtering and Sorting guides to learn more.