The CarsXE Node.js SDK provides a simple and powerful way to integrate vehicle data into your JavaScript and TypeScript applications. This guide will help you get started quickly.

For more information, see the <a href="https://www.npmjs.com/package/carsxe-api" target="\_blank" style={{textDecoration: 'underline'}}>package on npm</a>.

## Installation

Install the CarsXE Node.js package using npm or yarn:

`npm install carsxe-api`

or

`yarn add carsxe-api`

## Setup

First, import the CarsXE client and initialize it with your API key:

<CodeGroup title="decode.js">
```javascript
const { CarsXE } = require("carsxe-api");
// Initialize the client
const carsxe = new CarsXE("YOUR_API_KEY_HERE");
```
</CodeGroup>

For TypeScript:

<CodeGroup title="decode.ts">
```typescript
import { CarsXE } from "carsxe-api";
const carsxe = new CarsXE("YOUR_API_KEY_HERE");
```
</CodeGroup>

## Basic Usage

### VIN Specifications

<CodeGroup title="decode.js">
```javascript
const vin = 'WBAFR7C57CC811956';
carsxe
  .specs({ vin })
  .then((vehicle) => console.log(vehicle.input.vin))
  .catch((error) => console.error(error));
```
</CodeGroup>

Or using async/await:

<CodeGroup title="decode.js">
```javascript
async function decodeVIN() {
  try {
    const vehicle = await carsxe.specs({
      vin: 'WBAFR7C57CC811956'
    });
    console.log(vehicle.input.vin);
  } catch (error) {
    console.error("Error:", error);
  }
}
decodeVIN();
```
</CodeGroup>

### International VIN Decoder

<CodeGroup title="decode.js">
```javascript
async function decodeInternationalVIN() {
  try {
    const intVin = await carsxe.internationalVinDecoder({
      vin: 'WF0MXXGBWM8R43240'
    });
    console.log(intVin);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### Market Value

<CodeGroup title="decode.js">
```javascript
async function getMarketValue() {
  try {
    const value = await carsxe.marketvalue({
      vin: 'WBAFR7C57CC811956'
    });
    console.log(value);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### Vehicle History

<CodeGroup title="decode.js">
```javascript
async function getVehicleHistory() {
  try {
    const history = await carsxe.history({
      vin: 'WBAFR7C57CC811956'
    });
    console.log(history);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### License Plate Decoder

<CodeGroup title="decode.js">
```javascript
async function decodePlate() {
  try {
    const plate = await carsxe.platedecoder({
      plate: '7XER187',
      state: 'CA',
      country: 'US'
    });
    console.log(plate);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### Vehicle Images

<CodeGroup title="decode.js">
```javascript
async function getVehicleImages() {
  try {
    const imgs = await carsxe.images({
      make: 'BMW',
      model: 'X5',
      year: '2019'
    });
    console.log(imgs);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### Vehicle Recalls

<CodeGroup title="decode.js">
```javascript
async function checkRecalls() {
  try {
    const recalls = await carsxe.recalls({
      vin: '1C4JJXR64PW696340'
    });
    console.log(recalls);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### Plate Image Recognition

<CodeGroup title="decode.js">
```javascript
async function recognizePlateFromImage() {
  try {
    const plateImg = await carsxe.plateImageRecognition({
      imageUrl: 'https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public'
    });
    console.log(plateImg);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### VIN OCR from Image

<CodeGroup title="decode.js">
```javascript
async function extractVINFromImage() {
  try {
    const vinOcr = await carsxe.vinOcr({
      imageUrl: 'https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png'
    });
    console.log(vinOcr);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### Year-Make-Model Search

<CodeGroup title="decode.js">
```javascript
async function searchByYearMakeModel() {
  try {
    const ymm = await carsxe.yearMakeModel({
      year: '2023',
      make: 'Toyota',
      model: 'Camry'
    });
    console.log(ymm);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### OBD Code Decoder

<CodeGroup title="decode.js">
```javascript
async function decodeOBDCode() {
  try {
    const obd = await carsxe.obdcodesdecoder({
      code: 'P0115'
    });
    console.log(obd);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

### Lien and Theft

<CodeGroup title="decode.js">
```javascript
async function getLienAndTheft() {
  try {
    const lienTheft = await carsxe.lienAndTheft({
      vin: '2C3CDXFG1FH762860'
    });
    console.log(lienTheft);
  } catch (error) {
    console.error("Error:", error);
  }
}
```
</CodeGroup>

Start building powerful automotive applications with CarsXE's Node.js SDK!
