Back to Home

Code Examples

Copy-paste ready code snippets to integrate YugoVIN into your application in seconds.

Decode a Single VIN
curl -X GET "https://api.yugovin.com/api/v1/decode/1HGBH41JXMN109186" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json"

Basic VIN decode request. Replace your_api_key with your actual API key from the dashboard.

Batch Decode Multiple VINs
curl -X POST "https://api.yugovin.com/api/v1/batch-decode" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "vins": [
      "1HGBH41JXMN109186",
      "5UXWX7C5XBA123456",
      "WVWZZZ3CZWE123456"
    ]
  }'

Decode up to 100 VINs in a single request. Each VIN is decoded in parallel for maximum speed.

Validate a VIN
curl -X GET "https://api.yugovin.com/api/v1/validate/1HGBH41JXMN109186" \
  -H "X-API-Key: your_api_key"

Validate VIN format and check digit without a full decode. Fast and lightweight.

Decode a Single VIN
import requests

API_KEY = "your_api_key"
VIN = "1HGBH41JXMN109186"

response = requests.get(
    f"https://api.yugovin.com/api/v1/decode/{VIN}",
    headers={"X-API-Key": API_KEY}
)

data = response.json()

if data["success"]:
    vehicle = data["data"]
    print(f"Vehicle: {vehicle['year']} {vehicle['make']} {vehicle['model']}")
    print(f"Engine: {vehicle.get('engine_cylinders', 'N/A')} cylinder {vehicle.get('fuel_type', 'N/A')}")
else:
    print(f"Error: {data['message']}")
Batch Decode with Error Handling
import requests
from typing import List, Dict

API_KEY = "your_api_key"

def batch_decode(vins: List[str]) -> Dict:
    """Decode multiple VINs in a single API call."""
    response = requests.post(
        "https://api.yugovin.com/api/v1/batch-decode",
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        },
        json={"vins": vins}
    )
    response.raise_for_status()
    return response.json()

# Example usage
vins = [
    "1HGBH41JXMN109186",
    "5UXWX7C5XBA123456",
    "WVWZZZ3CZWE123456"
]

result = batch_decode(vins)

for vehicle in result.get("data", []):
    if vehicle.get("success"):
        v = vehicle["data"]
        print(f"{vehicle['vin']}: {v['year']} {v['make']} {v['model']}")
    else:
        print(f"{vehicle['vin']}: Error - {vehicle.get('error', 'Unknown')}")
Async with aiohttp
import aiohttp
import asyncio

API_KEY = "your_api_key"

async def decode_vin(session: aiohttp.ClientSession, vin: str) -> dict:
    """Decode a single VIN asynchronously."""
    async with session.get(
        f"https://api.yugovin.com/api/v1/decode/{vin}",
        headers={"X-API-Key": API_KEY}
    ) as response:
        return await response.json()

async def decode_many(vins: list) -> list:
    """Decode multiple VINs concurrently."""
    async with aiohttp.ClientSession() as session:
        tasks = [decode_vin(session, vin) for vin in vins]
        return await asyncio.gather(*tasks)

# Usage
vins = ["1HGBH41JXMN109186", "5UXWX7C5XBA123456"]
results = asyncio.run(decode_many(vins))

for result in results:
    if result["success"]:
        v = result["data"]
        print(f"{v['vin']}: {v['year']} {v['make']} {v['model']}")
Decode with Fetch API
const API_KEY = 'your_api_key';
const VIN = '1HGBH41JXMN109186';

async function decodeVIN(vin) {
  const response = await fetch(
    `https://api.yugovin.com/api/v1/decode/${vin}`,
    {
      headers: {
        'X-API-Key': API_KEY,
        'Content-Type': 'application/json'
      }
    }
  );

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

  return response.json();
}

// Usage
decodeVIN(VIN)
  .then(data => {
    if (data.success) {
      const vehicle = data.data;
      console.log(`${vehicle.year} ${vehicle.make} ${vehicle.model}`);
    }
  })
  .catch(error => console.error('Error:', error));
Batch Decode with Axios
import axios from 'axios';

const api = axios.create({
  baseURL: 'https://api.yugovin.com/api/v1',
  headers: {
    'X-API-Key': 'your_api_key',
    'Content-Type': 'application/json'
  }
});

async function batchDecode(vins) {
  try {
    const { data } = await api.post('/batch-decode', { vins });
    return data;
  } catch (error) {
    console.error('Batch decode failed:', error.response?.data || error.message);
    throw error;
  }
}

// Usage
const vins = [
  '1HGBH41JXMN109186',
  '5UXWX7C5XBA123456',
  'WVWZZZ3CZWE123456'
];

batchDecode(vins).then(result => {
  result.data.forEach(vehicle => {
    if (vehicle.success) {
      const v = vehicle.data;
      console.log(`${vehicle.vin}: ${v.year} ${v.make} ${v.model}`);
    }
  });
});
Node.js with TypeScript
interface VehicleData {
  vin: string;
  year: number;
  make: string;
  model: string;
  manufacturer?: string;
  vehicle_type?: string;
  body_class?: string;
  engine_cylinders?: number;
  fuel_type?: string;
}

interface DecodeResponse {
  success: boolean;
  data: VehicleData;
  decode_source: string;
}

async function decodeVIN(vin: string): Promise<DecodeResponse> {
  const response = await fetch(
    `https://api.yugovin.com/api/v1/decode/${vin}`,
    {
      headers: {
        'X-API-Key': process.env.YUGOVIN_API_KEY!,
        'Content-Type': 'application/json'
      }
    }
  );

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

  return response.json();
}

// Usage
const result = await decodeVIN('1HGBH41JXMN109186');
console.log(`Decoded: ${result.data.year} ${result.data.make} ${result.data.model}`);
Decode with net/http
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

const apiKey = "your_api_key"

type VehicleData struct {
    VIN       string `json:"vin"`
    Year      int    `json:"year"`
    Make      string `json:"make"`
    Model     string `json:"model"`
    FuelType  string `json:"fuel_type,omitempty"`
}

type DecodeResponse struct {
    Success bool        `json:"success"`
    Data    VehicleData `json:"data"`
}

func decodeVIN(vin string) (*DecodeResponse, error) {
    url := fmt.Sprintf("https://api.yugovin.com/api/v1/decode/%s", vin)

    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        return nil, err
    }

    req.Header.Set("X-API-Key", apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()

    var result DecodeResponse
    if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
        return nil, err
    }

    return &result, nil
}

func main() {
    result, err := decodeVIN("1HGBH41JXMN109186")
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }

    if result.Success {
        v := result.Data
        fmt.Printf("%d %s %s\n", v.Year, v.Make, v.Model)
    }
}
Concurrent Batch Decode
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

type BatchRequest struct {
    VINs []string `json:"vins"`
}

func batchDecode(vins []string) error {
    payload := BatchRequest{VINs: vins}
    body, err := json.Marshal(payload)
    if err != nil {
        return err
    }

    req, err := http.NewRequest(
        "POST",
        "https://api.yugovin.com/api/v1/batch-decode",
        bytes.NewBuffer(body),
    )
    if err != nil {
        return err
    }

    req.Header.Set("X-API-Key", "your_api_key")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return err
    }
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)

    fmt.Printf("Batch result: %+v\n", result)
    return nil
}

func main() {
    vins := []string{
        "1HGBH41JXMN109186",
        "5UXWX7C5XBA123456",
    }
    batchDecode(vins)
}
Decode with cURL
<?php

$apiKey = 'your_api_key';
$vin = '1HGBH41JXMN109186';

function decodeVIN(string $vin, string $apiKey): array {
    $ch = curl_init();

    curl_setopt_array($ch, [
        CURLOPT_URL => "https://api.yugovin.com/api/v1/decode/{$vin}",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            "X-API-Key: {$apiKey}",
            "Content-Type: application/json"
        ]
    ]);

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($httpCode !== 200) {
        throw new Exception("API returned HTTP {$httpCode}");
    }

    return json_decode($response, true);
}

// Usage
try {
    $result = decodeVIN($vin, $apiKey);

    if ($result['success']) {
        $vehicle = $result['data'];
        echo "{$vehicle['year']} {$vehicle['make']} {$vehicle['model']}\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
With Guzzle HTTP Client
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new Client([
    'base_uri' => 'https://api.yugovin.com/api/v1/',
    'headers' => [
        'X-API-Key' => 'your_api_key',
        'Content-Type' => 'application/json'
    ]
]);

// Single decode
try {
    $response = $client->get('decode/1HGBH41JXMN109186');
    $data = json_decode($response->getBody(), true);

    if ($data['success']) {
        $vehicle = $data['data'];
        echo "{$vehicle['year']} {$vehicle['make']} {$vehicle['model']}\n";
    }
} catch (RequestException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

// Batch decode
$vins = [
    '1HGBH41JXMN109186',
    '5UXWX7C5XBA123456'
];

$response = $client->post('batch-decode', [
    'json' => ['vins' => $vins]
]);

$result = json_decode($response->getBody(), true);
foreach ($result['data'] as $vehicle) {
    if ($vehicle['success']) {
        $v = $vehicle['data'];
        echo "{$vehicle['vin']}: {$v['year']} {$v['make']} {$v['model']}\n";
    }
}
Decode with Net::HTTP
require 'net/http'
require 'json'
require 'uri'

API_KEY = 'your_api_key'

def decode_vin(vin)
  uri = URI("https://api.yugovin.com/api/v1/decode/#{vin}")

  request = Net::HTTP::Get.new(uri)
  request['X-API-Key'] = API_KEY
  request['Content-Type'] = 'application/json'

  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end

  JSON.parse(response.body)
end

# Usage
result = decode_vin('1HGBH41JXMN109186')

if result['success']
  vehicle = result['data']
  puts "#{vehicle['year']} #{vehicle['make']} #{vehicle['model']}"
else
  puts "Error: #{result['message']}"
end
With HTTParty Gem
# gem install httparty

require 'httparty'

class YugoVINClient
  include HTTParty
  base_uri 'https://api.yugovin.com/api/v1'

  def initialize(api_key)
    @headers = {
      'X-API-Key' => api_key,
      'Content-Type' => 'application/json'
    }
  end

  def decode(vin)
    self.class.get("/decode/#{vin}", headers: @headers)
  end

  def batch_decode(vins)
    self.class.post(
      '/batch-decode',
      headers: @headers,
      body: { vins: vins }.to_json
    )
  end
end

# Usage
client = YugoVINClient.new('your_api_key')

# Single decode
result = client.decode('1HGBH41JXMN109186')
if result['success']
  v = result['data']
  puts "#{v['year']} #{v['make']} #{v['model']}"
end

# Batch decode
vins = ['1HGBH41JXMN109186', '5UXWX7C5XBA123456']
batch_result = client.batch_decode(vins)
batch_result['data'].each do |vehicle|
  if vehicle['success']
    v = vehicle['data']
    puts "#{vehicle['vin']}: #{v['year']} #{v['make']} #{v['model']}"
  end
end

Ready to Start Building?

Get your API key and integrate YugoVIN in minutes.