Get started with CarsXE's Node.js SDK to integrate comprehensive vehicle data into your JavaScript and TypeScript applications.
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 package on npm.
Install the CarsXE Node.js package using npm or yarn:
npm install carsxe-api
or
yarn add carsxe-api
First, import the CarsXE client and initialize it with your API key:
const { CarsXE } = require("carsxe-api");
// Initialize the client
const carsxe = new CarsXE("YOUR_API_KEY_HERE");For TypeScript:
import { CarsXE } from "carsxe-api";
const carsxe = new CarsXE("YOUR_API_KEY_HERE");const vin = 'WBAFR7C57CC811956';
carsxe
.specs({ vin })
.then((vehicle) => console.log(vehicle.input.vin))
.catch((error) => console.error(error));Or using async/await:
async function decodeVIN() {
try {
const vehicle = await carsxe.specs({
vin: 'WBAFR7C57CC811956'
});
console.log(vehicle.input.vin);
} catch (error) {
console.error("Error:", error);
}
}
decodeVIN();async function decodeInternationalVIN() {
try {
const intVin = await carsxe.internationalVinDecoder({
vin: 'WF0MXXGBWM8R43240'
});
console.log(intVin);
} catch (error) {
console.error("Error:", error);
}
}async function getMarketValue() {
try {
const value = await carsxe.marketvalue({
vin: 'WBAFR7C57CC811956'
});
console.log(value);
} catch (error) {
console.error("Error:", error);
}
}async function getVehicleHistory() {
try {
const history = await carsxe.history({
vin: 'WBAFR7C57CC811956'
});
console.log(history);
} catch (error) {
console.error("Error:", error);
}
}async function decodePlate() {
try {
const plate = await carsxe.platedecoder({
plate: '7XER187',
state: 'CA',
country: 'US'
});
console.log(plate);
} catch (error) {
console.error("Error:", error);
}
}async function getVehicleImages() {
try {
const imgs = await carsxe.images({
make: 'BMW',
model: 'X5',
year: '2019'
});
console.log(imgs);
} catch (error) {
console.error("Error:", error);
}
}async function checkRecalls() {
try {
const recalls = await carsxe.recalls({
vin: '1C4JJXR64PW696340'
});
console.log(recalls);
} catch (error) {
console.error("Error:", error);
}
}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);
}
}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);
}
}async function searchByYearMakeModel() {
try {
const ymm = await carsxe.yearMakeModel({
year: '2023',
make: 'Toyota',
model: 'Camry'
});
console.log(ymm);
} catch (error) {
console.error("Error:", error);
}
}async function decodeOBDCode() {
try {
const obd = await carsxe.obdcodesdecoder({
code: 'P0115'
});
console.log(obd);
} catch (error) {
console.error("Error:", error);
}
}async function getLienAndTheft() {
try {
const lienTheft = await carsxe.lienAndTheft({
vin: '2C3CDXFG1FH762860'
});
console.log(lienTheft);
} catch (error) {
console.error("Error:", error);
}
}Start building powerful automotive applications with CarsXE's Node.js SDK!