Filtering and Sorting
Sorting
Section titled “Sorting”Check Swagger for which fields can be sorted. For example, you can sort the models endpoint by name in either ascending or descending order:
curl -X 'GET' \ 'https://carapi.app/api/models/v2?sort=name&direction=desc' \ -H 'accept: application/json'Pagination
Section titled “Pagination”Endpoints offering pagination will indicate this in their responses. Most endpoints default to 100 results per page
but can go up to 1000 per page. This can be set using the limit query parameter.
{ "collection": { "url": "/api/trims/v2", "count": 100, "pages": 688, "total": 68754, "next": "/api/trims/v2?page=2", "prev": "", "first": "/api/trims/v2", "last": "/api/trims/v2?page=688" }, "data": []}Example:
curl -X 'GET' \ 'https://carapi.app/api/models/v2?page=2&limit=50' \ -H 'accept: application/json'Filters
Section titled “Filters”Most endpoints support basic query parameter filters to narrow down results. These filters perform exact match comparisons. These are used for fields like IDs, years, and other precise values.
Example - Filter by exact year:
curl -X 'GET' \ 'https://carapi.app/api/models/v2?year=2020' \ -H 'accept: application/json'JSON Filters
Section titled “JSON Filters”In addition to standard HTTP GET query parameters, many endpoints offer the json query parameter. This takes an
array of filter objects expressed as JSON. For example:
[ { "field": "make", "op": "in", "val": ["Ford", "Acura"] }, { "field": "year", "op": ">=", "val": 2010 }]curl -X 'GET' \ 'https://carapi.app/api/models/v2?json=[{"field":"make","op":"in","val":["Ford","Acura"]},{"field":"year","op":">=","val":2010}]' \ -H 'accept: application/json'Supported operators are =, !=, >, <, >=, <=, in, not in, like, not like,
not null, and is null. For the not null and is null operators, no val property is needed, example:
curl -X 'GET' \ 'https://carapi.app/api/engines/v2?json=[{"field":"fuel_type","op":"not null"}]' \ -H 'accept: application/json'