VIN Horsepower API for Developers

By Vehicle API
VIN Horsepower API for Developers

You need reliable horsepower from a VIN so your app can quote insurance, filter listings by performance, or surface specs to buyers. By the end of this guide you’ll decode a VIN on your server, read engine.hp, and ship production-safe error handling, timeouts, and caching with Vehicle API.

What the VIN horsepower field is and when to use it

Vehicle API exposes horsepower at data.engine.hp when you decode a 17-character VIN. It’s the engine horsepower as published by NHTSA’s vPIC. You’ll typically use engine.hp to:

Illustration: VIN Horsepower API for Developers
  • Score risk and premiums in insurance flows.
  • Drive search facets (e.g., “200+ hp”) on marketplaces.
  • Normalize specs in dealer DMS tools and appraisal UIs.
  • Feed AI agents that reason about performance trade-offs.

VIN decoding works worldwide but is fullest for US-market vehicles. US safety datasets (recalls, complaints, NCAP crash ratings) are matched by make, model, and year and are US-market only. Dutch plates come from RDW open data and never include a VIN. Vehicle API is not a vehicle history report; it does not include title, accident, or ownership history.

Endpoint, auth, and response envelope

Base URL: https://vehicles-api.com/api/v1

Endpoint for horsepower by VIN: POST /vin/decode

  • HTTP method: POST
  • Body: JSON with a vin key
  • Auth: X-API-Key: YOUR_API_KEY header (Authorization: Bearer YOUR_API_KEY also works)

Every response is wrapped in a consistent envelope:

  • status: "success" or "error"
  • source: the upstream source when successful (e.g., "nhtsa")
  • data: the decoded vehicle object when successful
  • error: present only on errors, with error.code and error.message

Nulls are expected when a source doesn’t publish a field. For example, electrification fields for a gasoline vehicle will be null. Do not special-case nulls as errors.

cURL: decode a VIN and read engine.hp

Use this server-side. Never embed your key in browser JavaScript.

curl -X POST "https://vehicles-api.com/api/v1/vin/decode" -H "X-API-Key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{"vin":"1HGCM82633A004352"}'

Official JSON example with horsepower

This is the official example for VIN 1HGCM82633A004352 (a 2003 Honda Accord, used only as a control VIN). Fields that aren’t published by NHTSA are null.

{
    "status": "success",
    "source": "nhtsa",
    "data": {
        "vin": "1HGCM82633A004352",
        "valid": true,
        "year": 2003,
        "make": "HONDA",
        "model": "Accord",
        "trim": "EX-V6",
        "body": "Coupe",
        "doors": 2,
        "vehicle_type": "PASSENGER CAR",
        "engine": {
            "cylinders": 6,
            "displacement_l": 3,
            "configuration": "V-Shaped",
            "model": "J30A4",
            "hp": 240,
            "fuel": "Gasoline"
        },
        "fuel_type": "Gasoline",
        "electrification_level": null,
        "ev_drive_unit": null,
        "battery_kwh": null,
        "charger_level": null,
        "charger_power_kw": null,
        "drive": null,
        "transmission": {
            "style": "Automatic",
            "speeds": 5
        },
        "plant": {
            "country": "UNITED STATES (USA)",
            "city": "MARYSVILLE",
            "state": "OHIO"
        },
        "manufacturer": "AMERICAN HONDA MOTOR CO., INC."
    }
}

Fields you’ll typically read:

  • status and source: check for "success" and log the upstream source.
  • data.vin and data.valid: echo back the VIN and confirm it’s a valid decode.
  • data.year, data.make, data.model, data.trim: for display and indexing.
  • data.engine.hp: horsepower for performance and pricing logic.
  • data.engine.displacement_l, data.engine.cylinders, data.engine.fuel: additional spec context.
  • data.transmission.style and data.transmission.speeds: useful in listings and filters.
  • Nulls such as electrification_level and battery_kwh: expected for gasoline cars.

Python (requests): server-side integration with timeouts and error handling

This example posts a VIN, reads engine.hp, and handles the error envelope. It also sets a timeout and demonstrates how to avoid raising on nulls.

import requests

API_URL = "https://vehicles-api.com/api/v1/vin/decode"
API_KEY = "YOUR_API_KEY"

def decode_vin_get_hp(vin: str, timeout_seconds: float = 5.0) -> int | None:
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
}
try:
resp = requests.post(API_URL, headers=headers, json={"vin": vin}, timeout=timeout_seconds)
except requests.Timeout:
# Surface a retryable condition to your caller
raise RuntimeError("VIN decode timed out")

# Always parse JSON to inspect the standard envelope
try:
payload = resp.json()
except ValueError:
raise RuntimeError(f"Unexpected response format (status {resp.status_code})")

# Handle error envelope from Vehicle API even on non-2xx
if payload.get("status") == "error":
code = payload.get("error", {}).get("code")
message = payload.get("error", {}).get("message")
raise RuntimeError(f"Vehicle API error {code}: {message}")

if payload.get("status") != "success":
raise RuntimeError(f"Vehicle API unexpected status: {payload.get('status')}")

data = payload.get("data") or {}
engine = data.get("engine") or {}
# engine.hp may be absent or null depending on source coverage
return engine.get("hp")

if __name__ == "__main__":
vin = "1HGCM82633A004352"
hp = decode_vin_get_hp(vin)
print(f"VIN {vin} horsepower: {hp}")

Notes:

  • Use json= for POST bodies so requests applies the correct Content-Type.
  • Do not ship your key in browser code. Keep this strictly server-side.
  • engine.hp can be null if not published by the source; treat null as “unknown” rather than an error.

PHP (cURL): server-side call with timeout and error envelope

This snippet posts the VIN, sets a connection and execution timeout, and checks the standard response envelope for errors.

<?php
$apiUrl = "https://vehicles-api.com/api/v1/vin/decode";
$apiKey = "YOUR_API_KEY";
$vin = "1HGCM82633A004352";

$ch = curl_init($apiUrl);
$payload = json_encode(["vin" => $vin]);

curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"X-API-Key: " . $apiKey,
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 5,
]);

$response = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
$err = curl_error($ch);
curl_close($ch);
throw new RuntimeException("cURL error: " . $err);
}
curl_close($ch);

$body = json_decode($response, true);
if ($body === null) {
throw new RuntimeException("Invalid JSON (HTTP $httpStatus): " . $response);
}

if (isset($body["status"]) && $body["status"] === "error") {
$code = $body["error"]["code"] ?? "unknown_error";
$message = $body["error"]["message"] ?? "Unknown error";
throw new RuntimeException("Vehicle API error $code: $message");
}

if (($body["status"] ?? null) !== "success") {
throw new RuntimeException("Unexpected status: " . ($body["status"] ?? "missing"));
}

$engine = $body["data"]["engine"] ?? [];
$hp = $engine["hp"] ?? null;

echo "VIN $vin horsepower: " . ($hp === null ? "unknown" : $hp) . PHP_EOL;

Production considerations: quotas, rate limits, caching, and retries

Monthly quota and rate limits apply to all plans. The exact thresholds vary by plan; consult the Documentation for current limits and guidance on backoff. Always set reasonable client-side timeouts and implement retry logic for transient network issues.

  • Caching: VIN decodes are stable for a given VIN. Cache the decoded payload (or just engine.hp) by VIN key. A long TTL is appropriate because manufacturer specs do not change for a historical VIN.
  • Idempotency: POST /vin/decode is a read action. Safe to retry when you receive network timeouts or 5xx responses, observing backoff and your rate limits.
  • Null handling: Fields not published by NHTSA (or other sources) are null. Your code should accept null for engine.hp and proceed without throwing, especially in listing or quoting flows where horsepower is optional.
  • Logging: Capture status, source, and error.code when present to diagnose issues and assist with support tickets.
  • Timeouts: Use short connect and request timeouts (for example, 5 seconds each) to protect upstream latency from cascading into your app.

Coverage notes and field behavior

VIN decoding is available worldwide. Coverage depth is fullest for US-market vehicles. The engine.hp field is returned when the upstream source provides it for that VIN. For the control VIN in the official example, engine.hp is 240. Do not infer horsepower from displacement or trim if engine.hp is null; always use the provided field when it exists.

Safety datasets—recalls, owner complaints, and NCAP crash ratings—are US-market only and matched by make + model + year (not by VIN). They are not part of the horsepower decode response. Dutch license plates are powered by RDW open data, and those lookups never include a VIN in their output.

How to use horsepower in common server workflows

  • Insurance pricing: Map engine.hp to internal risk bands. If engine.hp is null, fall back to risk rules that exclude horsepower.
  • Marketplace filters: Store engine.hp alongside year/make/model/trim in your search index; index as a numeric field for range queries.
  • Dealer appraisal: Combine engine.hp with transmission.style and cylinders to populate quick spec cards in trade-in flows.
  • Fleet policy gates: For driver assignments, reject vehicles above a horsepower threshold by checking engine.hp before assignment is finalized.
  • AI assistants: Supply engine.hp and related engine metadata (cylinders, displacement_l, fuel) as structured context for accurate responses.

MCP access for agents

If you’re building AI agents or tool-augmented apps, Vehicle API is also available as an MCP server at MCP. Use the same VIN decode capability in a toolcall-friendly interface. The underlying data, coverage, and field semantics remain the same, including engine.hp and null fields where sources do not publish values.

Security and deployment checklist

  • Keep the API key on the server. Do not embed it in client-side code or mobile apps.
  • Scope and rotate keys regularly. Store them in your secret manager or environment variables.
  • Validate inputs: accept only 17-character VINs before calling /vin/decode.
  • Respect plan limits: add lightweight caching by VIN and graceful degradation for horsepower-null cases.
  • Monitor: track success/error rates and surface error.code and error.message in dashboards.

Troubleshooting and error patterns

Vehicle API always returns the standardized envelope, even on errors. Typical patterns to handle:

  • status = "error": check error.code and error.message and map to your retry or user messaging strategy.
  • Null engine.hp: treat as unknown horsepower; continue rendering other specs without failing the request.
  • HTTP timeouts: retry with exponential backoff and budgeted attempts. Decodes are idempotent.
  • High traffic: implement local cache and request coalescing so multiple concurrent requests for the same VIN share one upstream call.

Field reference snapshot for horsepower workflows

  • data.engine.hp: integer horsepower value when provided by the source.
  • data.engine.displacement_l: engine displacement in liters (numeric).
  • data.engine.cylinders: cylinder count (numeric).
  • data.engine.configuration: engine layout (e.g., V-Shaped).
  • data.fuel_type and data.engine.fuel: fuel descriptor, keep both for consistency.
  • data.transmission.style and data.transmission.speeds: useful adjuncts for spec cards.
  • data.trim and data.body: often displayed alongside horsepower in listings.

Plan, pricing, and how to start

Vehicle API offers a Starter plan at $19/mo and every plan includes a 7-day free trial. To see current quotas, rate limits, and full endpoint docs, visit the Documentation. When you’re ready, create an account and get your API key.

FAQ

Does VIN decoding work outside the US?
Yes. VIN decoding is available worldwide, with the deepest coverage for US-market vehicles. Horsepower (engine.hp) is returned when the source publishes it.

Are recalls, complaints, or crash ratings tied to the VIN?
They are US-market only and matched by make + model + year, not by VIN. They are separate datasets and not part of the horsepower decode response.

Why is engine.hp null for some VINs?
If the upstream source does not publish horsepower for that VIN, engine.hp will be null. Handle this case as “unknown” and avoid blocking your flow.

Can I call the API from the browser?
No. Keep your API key server-side. Proxy requests through your backend and apply your own authentication and rate limiting.

How should I cache results?
Cache by VIN. Decoded specs are stable; a long TTL is appropriate. Invalidate only if you switch data sources or need to refresh formatting.

Start decoding VIN horsepower on your server in minutes. Create your account and get your 7-day free trial here: Register. For agent integrations, see MCP. Explore all endpoints and response fields in the Documentation.