---
title: "Node.js"
description: "Official CarsXE SDK for Node.js and TypeScript."
canonical_url: "https://docs.carsxe.com/docs/sdks/node"
markdown_url: "https://docs.carsxe.com/docs/sdks/node.md"
last_updated: "1980-01-01"
x_farming_labs_generated_preamble: true
agent:
  task: "Install and use the carsxe-api Node.js client to call CarsXE API endpoints."
  outcome: "The Node.js client is installed and its documented example returns a successful CarsXE response."
  prerequisites:
    - "A valid CarsXE API key."
    - "The runtime and package tooling required by the Node.js installation steps."
  verification:
    - "Run the documented Node.js example and confirm it authenticates and returns vehicle data without an SDK or API error."
  failureModes:
    - symptom: "The Node.js client cannot install, authenticate, or complete the example request."
      resolution: "Verify the runtime version, package installation, API-key environment variable, and endpoint inputs before rerunning the example."
---

# Node.js
URL: /docs/sdks/node
LLM index: /llms.txt
Description: Official CarsXE SDK for Node.js and TypeScript.
Related: /docs/sdks, /docs/get-started

<!-- farming-labs:agent-contract:start -->
## Agent Contract

Task: Install and use the carsxe-api Node.js client to call CarsXE API endpoints.
Outcome: The Node.js client is installed and its documented example returns a successful CarsXE response.

### Prerequisites

- A valid CarsXE API key.
- The runtime and package tooling required by the Node.js installation steps.

### Verification

- Run the documented Node.js example and confirm it authenticates and returns vehicle data without an SDK or API error.

### Failure Modes

- The Node.js client cannot install, authenticate, or complete the example request. — Recovery: Verify the runtime version, package installation, API-key environment variable, and endpoint inputs before rerunning the example.
<!-- farming-labs:agent-contract:end -->

Task: Install and use the carsxe-api Node.js client to call CarsXE API endpoints.
Related: /docs/get-started#quickstart, /docs/get-started#authentication, /docs/sdks

The `carsxe-api` package is the official CarsXE client for Node.js and TypeScript.

## Installation

```bash
npm install carsxe-api
# yarn add carsxe-api
# pnpm add carsxe-api
# bun add carsxe-api
```

## Quick start

<CodeGroup title="Decode a VIN">

```ts {{ title: "TypeScript" }}
import { CarsXE } from "carsxe-api";

const carsxe = new CarsXE("YOUR_API_KEY");

const vehicle = await carsxe.specs({ vin: "WBAFR7C57CC811956" });
console.log(vehicle);
```

```js {{ title: "CommonJS" }}
const { CarsXE } = require("carsxe-api");

const carsxe = new CarsXE("YOUR_API_KEY");

carsxe
  .specs({ vin: "WBAFR7C57CC811956" })
  .then((vehicle) => console.log(vehicle))
  .catch((error) => console.error(error));
```

</CodeGroup>

The client is constructed with your API key as a positional argument. Every method takes a params object and returns a `Promise`.

## Methods

| Method | Params | Description |
|---|---|---|
| `specs(params)` | `{ vin, deepdata?, disableIntVINDecoding? }` | Decode a VIN into full vehicle specifications |
| `internationalVinDecoder(params)` | `{ vin }` | Decode a non-US international VIN |
| `marketvalue(params)` | `{ vin, state?, mileage?, condition? }` | Retail, trade-in, and auction value estimates |
| `history(params)` | `{ vin }` | Title events, salvage, and insurance records |
| `recalls(params)` | `{ vin }` | Open safety recalls by VIN |
| `lienAndTheft(params)` | `{ vin }` | Lien records and theft/salvage status |
| `platedecoder(params)` | `{ plate, country, state?, district? }` | Resolve a license plate to vehicle data |
| `images(params)` | `{ make, model, year?, trim?, color?, angle?, photoType?, size?, transparent?, license? }` | Vehicle photos by make, model, and year |
| `plateImageRecognition(params)` | `{ imageUrl }` | Extract plate info from an image URL |
| `vinOcr(params)` | `{ imageUrl }` | Extract VIN text from an image via OCR |
| `yearMakeModel(params)` | `{ year, make, model, trim? }` | Look up vehicles by year, make, and model |
| `obdcodesdecoder(params)` | `{ code }` | Decode an OBD-II diagnostic trouble code |

## Endpoint examples

Runnable examples for each method. All of them assume the `carsxe` client from [Quick start](#quick-start).

### International VIN Decoder

```ts
const intVin = await carsxe.internationalVinDecoder({
  vin: "WF0MXXGBWM8R43240",
});
console.log(intVin);
```

### Market Value

```ts
const value = await carsxe.marketvalue({
  vin: "WBAFR7C57CC811956",
});
console.log(value);
```

### Vehicle History

```ts
const history = await carsxe.history({
  vin: "WBAFR7C57CC811956",
});
console.log(history);
```

### License Plate Decoder

```ts
const plate = await carsxe.platedecoder({
  plate: "7XER187",
  state: "CA",
  country: "US",
});
console.log(plate);
```

### Vehicle Images

```ts
const imgs = await carsxe.images({
  make: "BMW",
  model: "X5",
  year: "2019",
});
console.log(imgs);
```

### Vehicle Recalls

```ts
const recalls = await carsxe.recalls({
  vin: "1C4JJXR64PW696340",
});
console.log(recalls);
```

### Plate Image Recognition

```ts
const plateImg = await carsxe.plateImageRecognition({
  imageUrl:
    "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public",
});
console.log(plateImg);
```

### VIN OCR from Image

```ts
const vinOcr = await carsxe.vinOcr({
  imageUrl:
    "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/base/images/vin-ocr/vin/public",
});
console.log(vinOcr);
```

### Year-Make-Model Search

```ts
const ymm = await carsxe.yearMakeModel({
  year: "2023",
  make: "Toyota",
  model: "Camry",
});
console.log(ymm);
```

### OBD Code Decoder

```ts
const obd = await carsxe.obdcodesdecoder({
  code: "P0115",
});
console.log(obd);
```

### Lien and Theft

```ts
const lienTheft = await carsxe.lienAndTheft({
  vin: "2C3CDXFG1FH762860",
});
console.log(lienTheft);
```

## Error handling

Methods reject on failure. Wrap calls in `try/catch`:

```ts
import { CarsXE } from "carsxe-api";

const carsxe = new CarsXE("YOUR_API_KEY");

try {
  const vehicle = await carsxe.specs({ vin: "WBAFR7C57CC811956" });
  console.log(vehicle);
} catch (error) {
  console.error("CarsXE error:", error);
}
```

## Best practices

**Create one instance and reuse it.** Construct the client once with your key and share it across your app instead of instantiating per request.

```ts
// lib/carsxe.ts
import { CarsXE } from "carsxe-api";

export const carsxe = new CarsXE(process.env.CARSXE_API_KEY as string);
```

**Store your key in an environment variable.** Never hardcode it or commit it to source control.

```bash
# .env
CARSXE_API_KEY=your_key_here
```

**TypeScript types are included.** The package ships type declarations for every method's input (`SpecsInput`, `MarketValueInput`, `PlateDecoderParams`, and so on) — no `@types` package needed.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
