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
constcarsxe=newCarsXE("YOUR_API_KEY_HERE");For TypeScript:
import { CarsXE } from"carsxe-api";
constcarsxe=newCarsXE("YOUR_API_KEY_HERE");constvin='WBAFR7C57CC811956';
carsxe
.specs({ vin })
.then((vehicle) => console.log(vehicle.input.vin))
.catch((error) => console.error(error));Or using async/await:
asyncfunctiondecodeVIN() {
try {
constvehicle=await carsxe.specs({
vin: 'WBAFR7C57CC811956'
});
console.log(vehicle.input.vin);
} catch (error) {
console.error("Error:", error);
}
}
decodeVIN();asyncfunctiondecodeInternationalVIN() {
try {
constintVin=await carsxe.internationalVinDecoder({
vin: 'WF0MXXGBWM8R43240'
});
console.log(intVin);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctiongetMarketValue() {
try {
constvalue=await carsxe.marketvalue({
vin: 'WBAFR7C57CC811956'
});
console.log(value);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctiongetVehicleHistory() {
try {
consthistory=await carsxe.history({
vin: 'WBAFR7C57CC811956'
});
console.log(history);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctiondecodePlate() {
try {
constplate=await carsxe.platedecoder({
plate: '7XER187',
state: 'CA',
country: 'US'
});
console.log(plate);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctiongetVehicleImages() {
try {
constimgs=await carsxe.images({
make: 'BMW',
model: 'X5',
year: '2019'
});
console.log(imgs);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctioncheckRecalls() {
try {
constrecalls=await carsxe.recalls({
vin: '1C4JJXR64PW696340'
});
console.log(recalls);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctionrecognizePlateFromImage() {
try {
constplateImg=await carsxe.plateImageRecognition({
imageUrl: 'https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public'
});
console.log(plateImg);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctionextractVINFromImage() {
try {
constvinOcr=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);
}
}asyncfunctionsearchByYearMakeModel() {
try {
constymm=await carsxe.yearMakeModel({
year: '2023',
make: 'Toyota',
model: 'Camry'
});
console.log(ymm);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctiondecodeOBDCode() {
try {
constobd=await carsxe.obdcodesdecoder({
code: 'P0115'
});
console.log(obd);
} catch (error) {
console.error("Error:", error);
}
}asyncfunctiongetLienAndTheft() {
try {
constlienTheft=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!