Side Crash Rating API for Developers

By Vehicle API
Side Crash Rating API for Developers

A VIN alone does not tell your application which side-crash stars NHTSA published for the matching vehicle. By the end of this guide, you can request those ratings from a server, read the side fields, and handle partial matches, missing ratings, and US-only coverage without presenting unavailable data as a score.

Request the safety ratings

Vehicle API exposes side-crash ratings through GET /vin/safety-ratings. Pass the VIN in the vin query parameter and authenticate with the X-API-Key header. The endpoint returns NHTSA New Car Assessment Program (NCAP) ratings when a matching US-market vehicle and published ratings are available.

Illustration: Side Crash Rating API for Developers

The following complete request uses the documented control VIN. It represents a 2003 Honda Accord, not the vehicle a reader happens to be looking up; replace it with the VIN supplied to your server when integrating the request into an application.

curl "https://vehicles-api.com/api/v1/vin/safety-ratings?vin=1HGCM82633A004352" -H "X-API-Key: YOUR_API_KEY"

Run this from a trusted environment after replacing YOUR_API_KEY with your key. Vehicle API also accepts Bearer authentication, but the examples here use X-API-Key consistently. Never put the key in browser code: have the browser call your own server, and let that server call Vehicle API.

The Documentation is the reference for the current API behavior, including account limits and errors beyond those illustrated here.

Read the response before displaying a rating

This is the official response example for the request above:

{
    "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
    }
}

Successful responses use an envelope with status, source, and data. Here, status is success and source is nhtsa. Read the rating from data.side, rather than treating the envelope itself as the rating.

  • side.driver and side.passenger are the published side-crash star values for the driver and passenger positions. In this example, each is 5.
  • side.overall is the overall side rating. It is null in the example; display it as unavailable rather than calculating a replacement from the position-specific values.
  • vehicle_description describes the matched NHTSA vehicle. Show it alongside the rating so a user can see what the result represents.
  • coverage identifies the US coverage in this response, while match is partial. Preserve that match information instead of presenting the result as an exact identification of an individual car.
  • nhtsa_vehicle_id identifies the NHTSA vehicle record. Retain it with the description if your application needs to trace the rating back to the matched record.

The response also contains an overall rating, frontal ratings, and a rollover rating. They are separate from side; in particular, do not substitute front.overall or the top-level overall for a missing side rating. An overall value can be null when NHTSA did not publish it, and a successful response does not mean every rating field has a value.

The numbers are stars, not percentages or crash probabilities. A missing value is not zero stars, and it is not evidence that a vehicle failed a test. Keep missing values distinct from actual numeric ratings in storage, business logic, and the user interface.

Call the endpoint from your server

Both examples below use the same documented VIN and endpoint. Set the VEHICLE_API_KEY environment variable on the server to your API key before running either example. For a real lookup, pass a user-supplied VIN into the server-side function instead of relying on the control VIN.

The request is a GET, so Python uses params= for the VIN. The PHP example builds the equivalent query string. Both set a timeout, inspect error.code in an error envelope, and treat missing side values as unavailable.

Python with requests

import os
import sys

import requests

def show_side_rating(vin):
api_key = os.environ.get("VEHICLE_API_KEY")
if not api_key:
raise RuntimeError("Set VEHICLE_API_KEY on the server")

response = requests.get(
"https://vehicles-api.com/api/v1/vin/safety-ratings",
params=dict(vin=vin),
headers=dict(X_API_Key=api_key),
timeout=5,
)

# requests needs the hyphens in the actual HTTP header name.
# Set it explicitly rather than sending X_API_Key.

Use the following complete version to send the exact header name and handle the response:

import os
import sys

import requests

def show_side_rating(vin):
api_key = os.environ.get("VEHICLE_API_KEY")
if not api_key:
raise RuntimeError("Set VEHICLE_API_KEY on the server")

response = requests.get(
"https://vehicles-api.com/api/v1/vin/safety-ratings",
params=dict(vin=vin),
headers=dict([("X-API-Key", api_key)]),
timeout=5,
)

try:
payload = response.json()
except ValueError:
raise RuntimeError("Vehicle API returned a non-JSON response")

if payload.get("status") == "error":
error = payload.get("error") or dict()
code = error.get("code")
message = error.get("message")
if code == "coverage_us_only":
print("NCAP ratings are available for US-market vehicles only.")
else:
print("Vehicle API error:", code, message)
return

response.raise_for_status()
if payload.get("status") != "success":
raise RuntimeError("Unexpected response status")

data = payload.get("data") or dict()
side = data.get("side") or dict()

print("Source:", payload.get("source"))
print("Matched vehicle:", data.get("vehicle_description"))
print("Match:", data.get("match"))
for field in ("overall", "driver", "passenger"):
value = side.get(field)
print("Side", field + ":", value if value is not None else "unavailable")

try:
show_side_rating("1HGCM82633A004352")
except (requests.RequestException, RuntimeError) as exc:
print("Lookup failed:", exc, file=sys.stderr)
sys.exit(1)

Checking the envelope before calling raise_for_status() lets the application recognize coverage_us_only from a JSON error response. The HTTP status still matters: a non-success HTTP response that does not have the expected error envelope should not be treated as a successful lookup. In a production service, map these outcomes to your own application’s error handling rather than printing them.

PHP with cURL

<?php

function showSideRating(string $vin): void
{
$apiKey = getenv('VEHICLE_API_KEY');
if ($apiKey === false || $apiKey === '') {
throw new RuntimeException('Set VEHICLE_API_KEY on the server');
}

$query = http_build_query(['vin' => $vin]);
$url = 'https://vehicles-api.com/api/v1/vin/safety-ratings?' . $query;
$handle = curl_init($url);

curl_setopt_array($handle, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . $apiKey],
CURLOPT_TIMEOUT => 5,
]);

$body = curl_exec($handle);
if ($body === false) {
$message = curl_error($handle);
curl_close($handle);
throw new RuntimeException('Request failed: ' . $message);
}

$httpStatus = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

$payload = json_decode($body, true, 512, JSON_THROW_ON_ERROR);

if (($payload['status'] ?? null) === 'error') {
$error = $payload['error'] ?? [];
$code = $error['code'] ?? null;
$message = $error['message'] ?? null;

if ($code === 'coverage_us_only') {
echo "NCAP ratings are available for US-market vehicles only.\n";
} else {
echo 'Vehicle API error: ' . ($code ?? 'unknown')
. ' ' . ($message ?? '') . "\n";
}
return;
}

if ($httpStatus < 200 || $httpStatus >= 300) {
throw new RuntimeException('Unexpected HTTP status: ' . $httpStatus);
}
if (($payload['status'] ?? null) !== 'success') {
throw new RuntimeException('Unexpected response status');
}

$data = $payload['data'] ?? [];
$side = $data['side'] ?? [];

echo 'Source: ' . ($payload['source'] ?? 'unavailable') . "\n";
echo 'Matched vehicle: ' . ($data['vehicle_description'] ?? 'unavailable') . "\n";
echo 'Match: ' . ($data['match'] ?? 'unavailable') . "\n";

foreach (['overall', 'driver', 'passenger'] as $field) {
$value = $side[$field] ?? null;
echo 'Side ' . $field . ': ' . ($value ?? 'unavailable') . "\n";
}
}

try {
showSideRating('1HGCM82633A004352');
} catch (Throwable $error) {
error_log('Lookup failed: ' . $error->getMessage());
exit(1);
}

The PHP sample decodes JSON into associative arrays and uses null coalescing for fields that may be absent or null. It does not turn a missing value into a score. Keep the key in server configuration, and avoid logging request headers or exposing upstream credentials in an error returned to a browser.

Handle coverage, errors, and repeat lookups

NCAP ratings are US-market only and are matched by make, model, and year. A valid non-US VIN returns HTTP 422 with error.code set to coverage_us_only on this endpoint. Treat that as a coverage outcome, not as proof that the VIN is invalid or as a reason to retry the same request immediately.

VIN decoding has broader coverage: it works worldwide, with the fullest information for US-market vehicles. That distinction matters when a decode succeeds but a safety-rating lookup cannot return US NCAP data. Recalls and owner complaints are also US-market only and matched by make, model, and year; a safety-rating match is not an individual vehicle’s service record.

Vehicle API can also use Dutch plates from RDW open data, but Dutch plate results never include a VIN. Do not assume a plate response supplies the VIN needed for this request. More broadly, this rating lookup is not a vehicle history report: it does not provide title, accident, or ownership history.

On an error response, inspect both error.code and error.message within the error envelope. Use the code for application decisions and the message for diagnosis where appropriate. Handle timeouts, connection failures, non-JSON responses, and unexpected HTTP statuses separately from a valid API error; none should be rendered as an empty or zero-star rating.

Rate limits and monthly quota are separate operational constraints. Check the current limits for your account and plan in the documentation, monitor usage, and avoid assuming a particular allowance or retry interval. When an error indicates a limit or quota issue, surface an actionable state to your application rather than immediately repeating the same request in a tight loop.

Cache decoded VIN data when your application repeatedly looks up the same vehicle. Keep the decoded data separate from the NCAP result: a decode and a rating have different coverage and matching semantics. If you cache the rating response too, retain its source, match, vehicle description, and null values, and choose a refresh policy appropriate for your application as NHTSA publishes new data.

For agent-based workflows, Vehicle API also provides an MCP server. Apply the same interpretation rules in an agent’s output: identify the matched vehicle, distinguish driver and passenger side ratings, and state when an overall value is unavailable.

FAQ

Does a successful VIN decode guarantee a side-crash rating?

No. Decoding works worldwide, but NCAP ratings are limited to US-market vehicles and depend on the make, model, and year match and available published data. Handle missing rating fields even after a successful response.

Can I average the driver and passenger values when side overall is null?

Do not present an average as NHTSA’s overall side rating. Display the published position-specific stars separately and mark the overall value as unavailable.

What does a partial match mean for my display?

The example reports match: partial. Show that information and the returned vehicle_description with the ratings so users can assess the matched record; do not label it as a confirmed rating for the individual car.

What should I do with a coverage error?

For coverage_us_only, tell the user that this endpoint’s NCAP coverage is US-market only. Preserve the distinction between a coverage restriction and a network, authentication, or other API error.

To integrate side-crash ratings, Register and start the 7-day free trial. Every plan includes the trial; Starter is $19 per month.