Technical

Integrate an automotive API with Python, JavaScript and cURL

Published 19 March 2026 ยท 8 min read

Integrating an automotive data API into your application takes only a few minutes. In this article, we show you how to call the AutomotivAPI API using Python, JavaScript (Node.js) and cURL, with practical examples covering authentication, API calls and error handling.

Prerequisites

Before you begin, you will need:

  • An active AutomotivAPI account -- sign up here
  • Your API key (available in your client area after activation)
  • A development environment with Python 3.x, Node.js 16+ or a terminal for cURL

Authentication

All requests to the AutomotivAPI API are authenticated via a Bearer-type Authorization header. Your API key must be included in every request:

Authorization: Bearer YOUR_API_KEY

Never share your API key in public source code (GitHub, GitLab). Use environment variables to store the key securely.

Example 1: VIN decoding with cURL

cURL is the simplest tool for testing the API from a terminal:

curl -X POST https://api.automotivapi.com/v1/vin/decode \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vin": "VF1RFA00867123456"}'

The response is a JSON object containing the complete vehicle identification: make, model, trim, engine, equipment and technical data.

Example 2: License plate lookup in Python

Using Python and the requests library:

import os
import requests

API_KEY = os.environ.get("AUTOMOTIVAPI_KEY")
BASE_URL = "https://api.automotivapi.com/v1"

def lookup_plate(plate: str) -> dict:
    """Look up a vehicle by its license plate."""
    response = requests.post(
        f"{BASE_URL}/plate/lookup",
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json",
        },
        json={"plate": plate},
        timeout=10,
    )
    response.raise_for_status()
    return response.json()

# Usage example
try:
    vehicle = lookup_plate("AB-123-CD")
    print(f"Make: {vehicle['brand']}")
    print(f"Model: {vehicle['model']}")
    print(f"VIN: {vehicle['vin']}")
except requests.exceptions.HTTPError as e:
    print(f"API error: {e.response.status_code}")
except requests.exceptions.Timeout:
    print("Request timed out")

Example 3: VIN decoding in JavaScript (Node.js)

Using Node.js with the native fetch API (available since Node 18):

const API_KEY = process.env.AUTOMOTIVAPI_KEY;
const BASE_URL = 'https://api.automotivapi.com/v1';

async function decodeVin(vin) {
  const response = await fetch(`${BASE_URL}/vin/decode`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ vin }),
  });

  if (!response.ok) {
    throw new Error(`API error: ${response.status}`);
  }

  return response.json();
}

// Usage example
try {
  const vehicle = await decodeVin('VF1RFA00867123456');
  console.log(`Make: ${vehicle.brand}`);
  console.log(`Model: ${vehicle.model}`);
  console.log(`Trim: ${vehicle.trim}`);
} catch (error) {
  console.error(error.message);
}

Error handling

The API returns standard HTTP status codes. Here are the most common ones:

  • 200 -- success, the vehicle was identified
  • 400 -- invalid request (malformed VIN, incorrect plate)
  • 401 -- invalid or missing API key
  • 404 -- vehicle not found in the database
  • 429 -- rate limit exceeded
  • 500 -- internal server error

On error, the response body contains a JSON object with an error field describing the problem:

{
  "error": {
    "code": "INVALID_VIN",
    "message": "The provided VIN does not match the expected format (17 alphanumeric characters)."
  }
}

Best practices

Use environment variables

Store your API key in an environment variable (AUTOMOTIVAPI_KEY) rather than in source code. This prevents accidental leaks during a commit.

Implement retry logic

On 429 (rate limiting) or 500 (server error) responses, implement a retry with exponential backoff. Wait 1 second before the first retry, 2 seconds before the second, 4 seconds before the third, then give up.

Cache results

Vehicle data does not change frequently. If you decode the same VIN multiple times, cache the result (Redis, in-memory, local database) to save credits and improve performance.

Validate inputs

Validate the VIN format (17 alphanumeric characters, without I, O, Q) or the plate on the client side before sending the request. This avoids spending credits on requests that will always fail.

To go further, see our complete technical documentation and our article on automotive REST API architecture.

Related articles