contract 2026-10-05
Conventions

Responses & pagination

The response envelope, caching and conditional requests, compression, pagination aliases, and rate-limit headers.

Response envelope

Every successful response is {success: true, data, pagination?} plus the four metadata fields below. Everything the endpoint says about its subject is under data; a list is always data.items and a single car is data.vehicle; the paging numbers are under pagination. API v1 shows the shape in full.

FieldTypeMeaning
contract_versionstringSchema contract, currently 2026-10-05.
request_idstringCorrelation id, also returned in X-Request-ID.
server_timetimestampUTC ISO-8601 response time.
data_updated_attimestampRoute-provided data timestamp; defaults to server_time when no data timestamp is supplied. It is not a guaranteed source refresh time.

You may send your own X-Request-ID (up to 80 characters) and it will be echoed back.

json
{
  "success": true,
  "data": { "items": [ /* … */ ] },
  "pagination": { "total": 18342, "limit": 24, "offset": 0, "next_cursor": "eyJvIjoyNCwibCI6MjR9" },
  "contract_version": "2026-10-05",
  "request_id": "0f2c1b9e-4a77-4c31-9a0b-6d2f0a1c8e55",
  "server_time": "2026-08-19T09:41:02Z",
  "data_updated_at": "2026-08-19T06:00:00Z"
}

Freshness and missing values

SignalMeaningClient behavior
server_time / data_updated_atResponse time and route metadata; data_updated_at can default to server_time.Do not use these alone to claim that the source was just checked.
first_seen_at, last_seen_at, last_available_at, last_changed_atStored observations and changes to this listing, where available and permitted.Use alongside updated_at; inventory refresh, detail enrichment and image processing are separate.
live_price.fetched_atWhen the overlay bid was read, as an ISO-8601 timestamp.Display its age. It may be reused within the live-price TTL.
details_pending / live_price_pendingDetail enrichment or a bid refresh is still running.Render known card data and use a bounded delayed follow-up; do not create a tight polling loop.
Missing field / null / empty arrayA permission, missing source evidence, or incomplete enrichment can affect availability.Keep unknown distinct from zero, false, accident-free, and no service history.

Caching

Read routes can return X-Cache: HIT, MISS, or STALE. Facet and catalog responses cache for about 600 seconds; shallow search pages cache for about 300 seconds. Deep search pages (offset > 5000) are intentionally not cached, and a response carrying a refreshed live price drops its max-age to the live-price TTL.

Conditional requests: send the ETag back

Store the ETag from a response and put it in If-None-Match on the next request for the same URL. If nothing changed you get 304 Not Modified with no body — keep using the copy you already hold. A client polling the same search page every few minutes replaces a multi-megabyte download with an empty response for as long as the results hold still.

http
GET /api/v1/vehicles?site=openlane&limit=100 HTTP/1.1
X-API-Key: your_key
If-None-Match: W/"6f1c0a9d8e..."

HTTP/1.1 304 Not Modified
ETag: W/"6f1c0a9d8e..."

/api/v1/vehicles gained an ETag in contract 2026-08-19; the facet and catalog routes already had one. ETags are weak (W/"…") across the API by design, so one tag stays valid whether or not the body came back compressed. Compare them as opaque strings and echo them back exactly as received — do not strip the W/ prefix or the quotes.

Keep cached bodies and ETags scoped to the full request URL and API-key identity. Never reuse one customer’s response for another key: source and field grants can differ. A 304 has no JSON body, so retain the previously cached body and do not call response.json() on it.

Ask for compression

Send Accept-Encoding: gzip and any response over 2 KB comes back gzipped — on the order of an eighth of the bytes on a full 100-row search page. Below that threshold responses are sent uncompressed, where the header overhead would outweigh the saving. Most HTTP clients negotiate this and decompress transparently; a few (notably PHP Guzzle in certain configurations) have to be told to.

php
// Guzzle: decode_content is what turns "Accept-Encoding: gzip" into a decoded body.
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.thecarapi.com',
    'headers'  => ['X-API-Key' => getenv('THECARAPI_KEY')],
    'decode_content' => 'gzip',
]);

Pagination

ParameterMeaning
limit / page_sizePage size. Max 100; larger values are clamped down, not rejected. limit=0 or a negative value is a 400. Do not send both aliases.
offsetZero-based row offset. Do not combine with page.
pageOne-based page number; maps to offset = (page - 1) * limit. page=0 is a 400.
paginationEvery paginated response carries total, limit, offset, page, page_size, total_pages, max_page and next_cursor under pagination. A number the endpoint does not compute is null.
pagination.total / pagination.total_pagesNull when totals are suppressed.
pagination.max_pageDeepest reachable page under the current depth policy.
cursor / pagination.next_cursorEvery paginated response carries pagination.next_cursor. Send it back as cursor — on its own, with the same filters — to read the next page, and stop when it is null.
include_totalSet false to skip counting. Cheaper on large result sets.

Paging with a cursor

The simplest way through a result set: read pagination.next_cursor from each response, send it back as cursor, and repeat until it is null. There is no page arithmetic and no total needed to know when to stop. A cursor already carries the position and the page size, so it is sent without limit, page_size, offset or page — combining them is a 400 — and a value that is not a cursor is a 400 with code: invalid_cursor. offset and page keep working exactly as before.

python
params = {"brand": "bmw", "limit": 100}
while True:
    page = requests.get(f"{BASE}/api/v1/vehicles", params=params, headers=HEADERS).json()
    handle(page["data"]["items"])
    if not page["pagination"]["next_cursor"]:
        break
    # The cursor replaces limit/offset; the filters stay.
    params = {"brand": "bmw", "cursor": page["pagination"]["next_cursor"]}
A cursor marks a position in the result order, as an offset does. Inventory that changes while you page can move a row across a page boundary, so deduplicate on site + id when mirroring.

Default page size is 100 on /api/v1/vehicles and 50 everywhere else (catalog, /api/v1/list-vehicles, /api/v1/top-offers, /api/v1/classifieds/listings). limit is capped at 100 across the API — larger values are clamped down rather than rejected.

Depth policy

  • No offset cap. /api/v1/vehicles and /api/v1/list-vehicles page to any depth, filtered or not, so max_page on those responses is simply total_pages. A very deep filtered search is answered from a compact index where it can be; where it cannot, it is subject to the safety timeout and may come back 503 asking you to narrow it. Pages past offset 5000 are also not cached, so they cost more.
  • Capped at offset 5000. /api/v1/catalog/*, /api/v1/top-offers and /api/v1/classifieds/listings. A deeper page is a 400 naming the limit; narrow the result set instead.

The live cap is published as data.limits.max_offset by GET /api/v1/contract, alongside data.limits.max_limit. Read those rather than hardcoding them.

Rate limits

Managed keys can carry fixed-window quotas on any of four periods: minute, hour, day, month. Windows are fixed, not sliding — a "60 per minute" key may send 60 requests at 12:00:59 and 60 more at 12:01:00. That boundary burst is expected.

For accounts opened from 21 November 2026, most calls cost one request, a call to /api/v1/archive/* or /api/v1/classifieds/archive costs five, and every three photos loaded from the signed image links in our responses cost one. Each package also carries a daily limit of a tenth of its monthly requests, counted per UTC day: a 200,000-request package allows 20,000 a day, Unlimited full 300,000. A request past it is a 429 with code: quota_exceeded and a Retry-After that runs to the next UTC midnight.

A key can also be issued with no quota, and then none of the rate-limit headers are sent — their absence means "unlimited", not "limit reached". When a key does carry quotas, every request reports the window with the least headroom left, which is the one that will bite you next. All configured windows are checked before any is charged, so a request rejected by the day limit does not also spend a minute of your minute allowance.

A quota breach returns 429 with X-RateLimit-Remaining: 0, names the window it broke ({"success": false, "error": "Rate limit exceeded (1000 per hour)"}), and includes Retry-After — honour it rather than backing off on a schedule of your own. /api/v1/facets costs one request against your quota however many dimensions you ask for, which is the cheapest way to build a filter sidebar.

javascript
async function call(url, init = {}) {
  for (let attempt = 0; attempt < 4; attempt++) {
    const res = await fetch(url, init);

    if (res.status === 429 || res.status >= 500) {
      const wait = Number(res.headers.get("Retry-After") ?? 2 ** attempt);
      await new Promise((r) => setTimeout(r, wait * 1000));
      continue;
    }

    // 4xx other than 429 is a bug in the request. Retrying cannot fix it.
    if (!res.ok && res.status < 500) {
      throw new Error(`${res.status} ${await res.text()} (request ${res.headers.get("X-Request-ID")})`);
    }
    return res;
  }
  throw new Error("giving up after 4 attempts");
}
Retry 429, 503 and 5xx. Never retry 400, 401, 403 or 404.