Ever needed to quickly identify a vehicle's VIN from an image? Whether it's for verifying vehicle details or tracking, the VIN OCR API allows you to extract the VIN from an image (either a URL or base64 string) using optical character recognition (OCR) and computer vision. This API is capable of recognizing VINs from a wide range of vehicles, ensuring accurate and detailed vehicle information retrieval.

---

<Row>
  <Col>

    This endpoint allows you to retrieve a vehicle's VIN.

    ## Required attributes

    <Properties>
      <Property name="key" type="string">
        Your CarsXE API key.
      </Property>
      <Property name="image_url" type="string">
        JSON body field containing a URL to an image or the base64 string of the image.
      </Property>
    </Properties>

    ---

    ## Response attributes

    <Properties>
      <Property name="success" type="boolean">
        Whether the algorithm has been able to successfully analyze the VIN from the image.
      </Property>
      <Property name="vin" type="string">
        The extracted VIN number from the image.
      </Property>
      <Property name="confidence" type="number">
        The confidence score, which is a probability value (between 0 and 1) indicating how certain the algorithm is that the extracted VIN is correct.
      </Property>
      <Property name="message" type="string">
        String detailing error if any.
      </Property>
    </Properties>

    <FAQ faqs={[{question: "Is the VIN OCR API included in the free trial?", answer: <>Yes! The VIN OCR API is included in the 7-day free trial. For more information, visit our <a href='/pricing'>pricing</a> page.</>}]} hidePadding />

  </Col>
  <Col sticky>
  
    <CodeGroup title="Request" tag="POST" label="/v1/vinocr">

    ```bash
    curl --location 'https://api.carsxe.com/v1/vinocr?key=CARSXE_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{"image_url": "https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png"}'
    ```

    ```js
    import { CarsXE } from "carsxe-api";
    const carsxe = new CarsXE("CARSXE_API_KEY");
    const imageUrl = "https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png";
    try {
      const vinOcr = await carsxe.vinOcr({ imageUrl });
      console.log(vinOcr);
    } catch (error) {
      console.error(error);
    }
    ```

    ```python
    import asyncio
    from carsxe_api import CarsXE

    carsxe = CarsXE('CARSXE_API_KEY')
    image_url = 'https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png'

    try:
        vin_ocr = asyncio.run(carsxe.vin_ocr({"upload_url": image_url}))
        print(vin_ocr)
    except Exception as e:
        print(f"Error: {e}")
    ```

    ```php
    <?php
    require_once __DIR__ . '/vendor/autoload.php';
    use CarsxeDeveloper\Carsxe\Carsxe;

    $API_KEY = 'CARSXE_API_KEY';
    $carsxe = new Carsxe($API_KEY);
    $imageUrl = 'https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png';

    try {
        $vinOcr = $carsxe->vinOcr(['upload_url' => $imageUrl]);
        print_r($vinOcr);
    } catch (Exception $error) {
        echo "Error: " . $error->getMessage();
    }
    ```

    ```ruby
    require 'carsxe'

    API_KEY = 'CARSXE_API_KEY'
    carsxe = Carsxe::CarsXE.new(api_key: API_KEY)
    image_url = 'https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png'

    begin
      vin_ocr = carsxe.vin_ocr('upload_url' => image_url)
      puts vin_ocr
    rescue StandardError => error
      puts "Error: #{error.message}"
    end
    ```

    ```go
    package main

    import (
    	"fmt"
    	"github.com/carsxe/carsxe-go-package"
    )

    func main() {
    	client := carsxe.New("CARSXE_API_KEY")
    	imageUrl := "https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png"
    	vinOcr := client.VinOCR(map[string]string{"upload_url": imageUrl})
    	fmt.Println(vinOcr)
    }
    ```

    ```java
    import io.github.carsxe.CarsXE;
    import java.util.Map;

    public class Main {
        public static void main(String[] args) {
            CarsXE carsxe = new CarsXE("CARSXE_API_KEY");
            String imageUrl = "https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png";
            try {
                Map<String, Object> vinOcr = carsxe.vinOcr(imageUrl);
                System.out.println(vinOcr);
            } catch (Exception e) {
                System.err.println("Error: " + e.getMessage());
            }
        }
    }
    ```

    ```swift
    import carsxe

    let carsxe = CarsXE(apiKey: "CARSXE_API_KEY")
    let imageUrl = "https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png"

    do {
        let vinOcr = try carsxe.vinOCR(imageUrl: imageUrl)
        print(vinOcr)
    } catch {
        print("Error: \(error)")
    }
    ```

    ```csharp
    using carsxe;
    using System;
    using System.Threading.Tasks;

    class Program
    {
        static async Task Main(string[] args)
        {
            string API_KEY = "CARSXE_API_KEY";
            CarsXE carsxe = new CarsXE(API_KEY);
            string imageUrl = "https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png";
            try
            {
                var vinOcr = await carsxe.VinOcr(imageUrl);
                Console.WriteLine(vinOcr);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
    }
    ```
    </CodeGroup>

    <CodeGroup title="Response">
    ```json showLineNumbers {{ title: 'Response' }}
    {
      "success": true,
      "vin": "JHLRD77874C026456",
      "box": {
          "xmin": 257,
          "xmax": 1673,
          "ymin": 635,
          "ymax": 793
      },
      "confidence": 0.9834251403808594,
      "candidates": [
          {
              "vin": "JHLRD77874C026456",
              "confidence": 0.9834251403808594,
              "box": {
                  "xmin": 257,
                  "xmax": 1673,
                  "ymin": 635,
                  "ymax": 793
              }
          }
      ]
    }
    ```
    </CodeGroup>

  </Col>
</Row>
