Skip to content

Filtering and 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:

Terminal window
curl -X 'GET' \
'https://carapi.app/api/models/v2?sort=name&direction=desc' \
-H 'accept: application/json'

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:

Terminal window
curl -X 'GET' \
'https://carapi.app/api/models/v2?page=2&limit=50' \
-H 'accept: application/json'

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:

Terminal window
curl -X 'GET' \
'https://carapi.app/api/models/v2?year=2020' \
-H 'accept: application/json'

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
}
]
Terminal window
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:

Terminal window
curl -X 'GET' \
'https://carapi.app/api/engines/v2?json=[{"field":"fuel_type","op":"not null"}]' \
-H 'accept: application/json'