
A VIN alone does not tell your application what NHTSA reported for a vehicle’s frontal crash test. By the end of this guide, you can request the rating server-side, read the front fields, and handle missing ratings and US-market coverage errors without treating them as zero stars.
Request the rating by VIN
Vehicle API exposes NHTSA NCAP ratings through GET /vin/safety-ratings. Pass the VIN as the vin query parameter and authenticate with the X-API-Key header. The request returns frontal, side and rollover ratings when available, but this guide focuses on the front object.
The following request uses the documentation’s control VIN for a 2003 Honda Accord. Replace it with the VIN supplied by your application when making a real lookup; the control VIN is not the reader’s vehicle.
curl "https://vehicles-api.com/api/v1/vin/safety-ratings?vin=1HGCM82633A004352" -H "X-API-Key: YOUR_API_KEY"
Keep the API key on your server. Do not put it in browser JavaScript, a mobile client, or a public repository. Authorization Bearer also works, but the examples here consistently use X-API-Key.
NCAP ratings are limited to US-market vehicles and are matched by make, model and year. A valid non-US VIN returns HTTP 422 with error.code set to coverage_us_only for this endpoint. Worldwide VIN decoding does not imply worldwide crash-rating coverage; decoding is fullest for US-market vehicles.
Read the response envelope and frontal ratings
The official example returns this JSON envelope:
{
"status": "success",
"source": "nhtsa",
"data": {
"vin": "1HGCM82633A004352",
"coverage": "us",
"match": "partial",
"vehicle_description": "2003 Honda Accord 2-DR.",
"overall": null,
"front": {
"overall": null,
"driver": 5,
"passenger": 5
},
"side": {
"overall": null,
"driver": 5,
"passenger": 5
},
"rollover": 4,
"nhtsa_vehicle_id": 4736
}
}
The fields most relevant to a frontal-rating integration are:
statusandsourceidentify a successful response and its NHTSA source. The vehicle-specific result is underdata.vin,vehicle_description,coverageandmatchprovide context for the result. Show the description and match information alongside a rating when users need to assess what was matched.front.driverandfront.passengerare the frontal crash-test star values for the respective seating positions. In this example, both are present.front.overallis the overall frontal value when available. Here it isnull; do not calculate or substitute a value from the driver and passenger fields.overallat the top ofdatais distinct fromfront.overall. It can benullwhen NHTSA did not publish it.nhtsa_vehicle_ididentifies the NHTSA vehicle record associated with the result.sideandrollovercontain other crash-test ratings, not frontal values.
The example’s match is partial. Preserve that information rather than presenting the result as proof that a particular physical vehicle was crash-tested. The rating is matched by make, model and year; the VIN is the lookup input.
Treat a null rating as unavailable, not as zero stars, a failed test, or a value you can infer. An interface can display “Unavailable” while still showing any driver or passenger rating that is present. Keep the original numeric value available to your application rather than storing only a formatted label.
Call the endpoint with Python
This server-side example uses requests and sends the VIN with params=. Set the server’s VEHICLE_API_KEY environment variable to your API key before running it. In a deployed application, pass the user’s VIN to get_frontal_rating instead of relying on the control VIN.
import os
import requests
def get_frontal_rating(vin):
response = requests.get(
"https://vehicles-api.com/api/v1/vin/safety-ratings",
params={"vin": vin},
headers={"X-API-Key": os.environ["VEHICLE_API_KEY"]},
timeout=10,
)
try:
payload = response.json()
except requests.exceptions.JSONDecodeError as exc:
raise RuntimeError("Vehicle API returned a non-JSON response") from exc
if payload.get("status") == "error":
error = payload.get("error") or {}
code = error.get("code")
message = error.get("message")
if code == "coverage_us_only":
raise ValueError("NCAP ratings cover US-market vehicles only")
raise RuntimeError("Vehicle API error: " + str(code) + ": " + str(message))
response.raise_for_status()
if payload.get("status") != "success":
raise RuntimeError("Unexpected Vehicle API response status")
data = payload.get("data") or {}
front = data.get("front") or {}
return data, front
data, front = get_frontal_rating("1HGCM82633A004352")
print("Vehicle:", data.get("vehicle_description"))
print("Match:", data.get("match"))
print("Frontal overall:", front.get("overall"))
print("Frontal driver:", front.get("driver"))
print("Frontal passenger:", front.get("passenger"))
The code checks the error envelope before calling raise_for_status(), so it can distinguish coverage_us_only from other failures. For other API errors, it retains both error.code and error.message in the exception. Handle request timeouts and connection failures at the application boundary as well; they are not the same as a successful response with a null rating.
This is a GET request, so params= supplies its query parameter. Use json= when sending a documented JSON POST in Python; do not use it to change this safety-rating request into a POST. Consult the Documentation for current integration details.
Call the endpoint with PHP cURL
The same lookup can run in a PHP server process. This example reads the key from the environment, sets a timeout, and checks the error envelope before interpreting the rating.
<?php
$key = getenv('VEHICLE_API_KEY');
if ($key === false || $key === '') {
throw new RuntimeException('VEHICLE_API_KEY is not set');
}
$vin = '1HGCM82633A004352';
$url = 'https://vehicles-api.com/api/v1/vin/safety-ratings'
. '?' . http_build_query(['vin' => $vin]);
$curl = curl_init($url);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . $key],
CURLOPT_TIMEOUT => 10,
]);
$raw = curl_exec($curl);
if ($raw === false) {
$message = curl_error($curl);
curl_close($curl);
throw new RuntimeException('Request failed: ' . $message);
}
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
try {
$payload = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
throw new RuntimeException('Vehicle API returned a non-JSON response', 0, $exception);
}
if (($payload['status'] ?? null) === 'error') {
$code = $payload['error']['code'] ?? null;
$message = $payload['error']['message'] ?? null;
if ($code === 'coverage_us_only') {
throw new RuntimeException('NCAP ratings cover US-market vehicles only');
}
throw new RuntimeException('Vehicle API error: ' . $code . ': ' . $message);
}
if ($httpStatus < 200 || $httpStatus >= 300) {
throw new RuntimeException('Unexpected HTTP status: ' . $httpStatus);
}
if (($payload['status'] ?? null) !== 'success') {
throw new RuntimeException('Unexpected Vehicle API response status');
}
$data = $payload['data'] ?? [];
$front = $data['front'] ?? [];
echo 'Vehicle: ' . ($data['vehicle_description'] ?? 'Unavailable') . PHP_EOL;
echo 'Match: ' . ($data['match'] ?? 'Unavailable') . PHP_EOL;
echo 'Frontal overall: ' . var_export($front['overall'] ?? null, true) . PHP_EOL;
echo 'Frontal driver: ' . var_export($front['driver'] ?? null, true) . PHP_EOL;
echo 'Frontal passenger: ' . var_export($front['passenger'] ?? null, true) . PHP_EOL;
http_build_query encodes the VIN as a query parameter; it does not put the API key in the URL. The example prints nulls explicitly, so an absent value is not mistaken for a numeric rating. In an application, translate those nulls into an appropriate unavailable state for the user.
Design for coverage, errors and changing data
Separate three outcomes in your application: a successful response with ratings, a successful response with unavailable fields, and a request that failed. An error response has status, error.code and error.message; it is not a successful data object. Handle the documented coverage_us_only code explicitly and retain a general path for other error codes.
Rate limits and monthly quota are separate operational constraints. Avoid unnecessary repeat calls, monitor usage against your plan, and consult the documentation for current limits and error behavior rather than hard-coding an assumed allowance. Starter is $19 per month, and every plan has a seven-day free trial.
Cache decoded VIN information when your application repeatedly works with the same vehicle. Cache safety-rating results separately, retain their match and source context, and choose a refresh policy appropriate to your product: NHTSA data can change. Do not turn a temporary request failure into a cached “no rating” result, and do not cache a null as a numeric zero.
For dealer listings, fleet records or insurance workflows, show enough context to distinguish the matched vehicle description from a claim about an individual car’s history. Recalls, complaints and NCAP ratings are US-market data matched by make, model and year. Vehicle API is not a vehicle history report: it does not provide title, accident or ownership history.
Dutch plate data comes from RDW and never includes a VIN. A Dutch plate result therefore cannot provide a VIN to pass to this endpoint. For agent-based integrations, Vehicle API also offers an MCP server; keep the same coverage and null-handling distinctions when presenting safety results to an agent.
FAQ
Does a valid VIN guarantee a frontal crash rating?
No. NCAP coverage here is US-market only, and individual rating fields can be unavailable. A valid non-US VIN returns 422 with coverage_us_only on this endpoint.
What is the difference between overall and front.overall?
overall is the overall rating at the vehicle-data level; front.overall is the frontal overall value. Read the latter for a frontal result, and handle either field being null.
Can I average the driver and passenger stars when front.overall is null?
Do not present a calculated average as the published frontal overall rating. Show the available driver and passenger values separately and mark the overall frontal value as unavailable.
Should I call the endpoint directly from a browser?
No. Make the request from your server so the API key remains private. Return only the rating information and context your client needs.
Register to start a seven-day free trial and integrate frontal crash ratings into your server-side workflow.