Start with a working API request.
Set FITMENTCORE_API_KEY in your server environment. These examples call the vehicle-to-wheel endpoint and stop on errors rather than displaying an invalid fitment result.
Find the correct vehicle slugs
Request /api/v1/cars with your API key to list makes, then /api/v1/cars?brand=bmw to list models. Replace YOUR_MODEL_SLUG with a returned mslug. The interactive demo also shows the request for a selected vehicle.
Python needs the requests package. The JavaScript example uses Node.js 22 or later with native fetch; PHP needs the cURL extension. Run these examples on your backend, keeping keys out of browser code.
Python
import os
import requests
response = requests.get(
"https://fitmentcore.com/api/v1/fitments/by-car",
params={"bslug": "bmw", "mslug": "YOUR_MODEL_SLUG"},
headers={"X-API-Key": os.environ["FITMENTCORE_API_KEY"]},
timeout=15,
)
if response.status_code == 429:
raise RuntimeError("Quota exceeded; Retry-After: " +
response.headers.get("Retry-After", "not supplied"))
response.raise_for_status()
fitment = response.json()
print(fitment)
Node.js
const key = process.env.FITMENTCORE_API_KEY;
if (!key) throw new Error("Set FITMENTCORE_API_KEY on your backend");
const url = new URL("https://fitmentcore.com/api/v1/fitments/by-car");
url.search = new URLSearchParams({bslug: "bmw", mslug: "YOUR_MODEL_SLUG"});
const response = await fetch(url, {
headers: {"X-API-Key": key},
signal: AbortSignal.timeout(15000)
});
if (response.status === 429) {
throw new Error("Quota exceeded; Retry-After: " +
response.headers.get("Retry-After"));
}
if (!response.ok) throw new Error(`FitmentCore HTTP ${response.status}`);
const fitment = await response.json();
console.log(fitment);
PHP
<?php
$key = getenv('FITMENTCORE_API_KEY');
if (!$key) throw new RuntimeException('Set FITMENTCORE_API_KEY on your backend');
$query = http_build_query(['bslug' => 'bmw', 'mslug' => 'YOUR_MODEL_SLUG']);
$retryAfter = null;
$ch = curl_init('https://fitmentcore.com/api/v1/fitments/by-car?' . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . $key],
CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$retryAfter) {
if (stripos($line, 'Retry-After:') === 0) {
$retryAfter = trim(substr($line, 12));
}
return strlen($line);
},
]);
$body = curl_exec($ch);
if ($body === false) throw new RuntimeException(curl_error($ch));
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status === 429) {
throw new RuntimeException('Quota exceeded; Retry-After: ' . $retryAfter);
}
if ($status >= 400) throw new RuntimeException('FitmentCore HTTP ' . $status);
$fitment = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
Handle responses deliberately
- 400: check request parameters.
- 401 or 403: review your key, company access and IP allowance.
- 404: check the selected make, generation and slugs.
- 429: respect Retry-After; do not retry continuously.
- Timeout or 5xx: apply bounded retries with backoff in your integration.
Cache selector data and agree a fitment cache lifetime. Check published data updates for changes that affect your results. Map returned dimensions to your own inventory; an empty result is not a server failure.
Full API documentation