GET /cars — the request, in four languages
Copy-paste requests for curl, JavaScript, Python and PHP, plus how paging and sorting behave when you ask for more than one page.
curl
Everything is a GET. No request body, no content type to negotiate — if you can make an HTTP request you can call this.
curl -H "x-api-key: YOUR_KEY" \
"https://api.encar-api.com/api/cars?manufacturer=BMW&model=X5&fuel=diesel&priceTo=40000&sort=priceAsc&count=24"JavaScript
Call it from a server or an edge function, not from the browser: anything in front-end JavaScript ships your key to every visitor who opens devtools.
const params = new URLSearchParams({
manufacturer: "Hyundai",
yearFrom: "2020",
priceTo: "30000",
count: "24",
});
const res = await fetch(`https://api.encar-api.com/api/cars?${params}`, {
headers: { "x-api-key": process.env.ENCAR_API_KEY },
});
if (!res.ok) throw new Error(`encar: ${res.status}`);
const { total, results } = await res.json();Python
The same call with requests. Note the rate-limit header — reading it is cheaper than handling a 429 after the fact.
import os, requests
r = requests.get(
"https://api.encar-api.com/api/cars",
headers={"x-api-key": os.environ["ENCAR_API_KEY"]},
params={"manufacturer": "Kia", "fuel": "hybrid", "count": 50},
timeout=20,
)
r.raise_for_status()
print(r.headers.get("X-RateLimit-Remaining"), r.json()["total"])PHP
For a WordPress or Laravel back end, where most dealer sites already live.
$url = "https://api.encar-api.com/api/cars?" . http_build_query([
"manufacturer" => "Genesis",
"yearFrom" => 2021,
"count" => 24,
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["x-api-key: " . getenv("ENCAR_API_KEY")],
CURLOPT_TIMEOUT => 20,
]);
$data = json_decode(curl_exec($ch), true);Paging and sorting
page is zero-based and count caps at 500. Read total from the response to know how many pages exist — count is only how many listings came back in this one. Asking for a page past the end returns an empty results array rather than an error, so a loop that trusts the data terminates on its own.
sort takes priceAsc or priceDesc. Left out, listings come back newest first, which is what you want for a stock page and not what you want for a price comparison.
| parameter | what it accepts |
|---|---|
| manufacturer | Brand, as Encar writes it: BMW, Hyundai, Kia, Genesis, Mercedes-Benz, Audi. |
| model | Model name, e.g. X5 (G05). Partial names match, and a generation name narrows further: model=The New Carnival returns that generation alone, not the whole nameplate. |
| q | Free-text search across brand, model and badge. Aliases: keyword, search. |
| fuel | diesel · gasoline · hybrid · electric · lpg. |
| transmission | automatic · manual. |
| color | Exterior colour. |
| seats | Seat count: 5, 7, 9. Several at once as seats=7,9. The two ends are ranges, not counts — 2 means two seats or fewer and 10 means ten or more, which is how the source files them. A car's own figure comes back as details.seats from /car. |
| yearFrom / yearTo | Model year bounds, as plain years: 2018, 2024. |
| mileageFrom / mileageTo | Odometer bounds in kilometres. |
| priceFrom / priceTo | Price bounds in EUR — converted for you, not won. |
| sort | priceAsc or priceDesc. Left out, results come back newest first. |
| page | Page index, zero-based. Default 0. |
| count | Listings per page. Default 24, maximum 500. |
Questions people ask about this
Where do I put the API key?
In the x-api-key request header. Not in the query string: URLs end up in logs, browser history and shared links, and a key in a URL is a key somebody else can spend.
How many listings can one request return?
Up to 500, set with count. The default is 24, and page is zero-based. In the response, total is the number of listings matching your filters and count is how many came back in that page — paginate off total.
Get your API key
Free tier, 100 requests a day. Enter your email and the key arrives immediately, with everything you need to make the first call.
- 100 requests a day
- No credit card
- Your key never expires
Questions, or Pro and Enterprise volume? Reply straight to the key email — it reaches a person, not a form. Or message us on WhatsApp if that is quicker: +383 49 644 168
Run one of these for real
A free key is issued instantly. Paste it into any snippet above and you have live data.
Keep reading
Combine any of these on a single call. The answer carries total, page, count and results[], so you can paginate off total without a second request.
Three endpoints, one header, JSON out. Everything below is the complete reference — there is no second, paid tier of documentation.
Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, so you can see a limit coming rather than discover it.