CarsXE Developer

Java Quickstart Guide

Get started with CarsXE's Java SDK to integrate comprehensive vehicle data into your Java applications.


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

For more information, see the package on Maven Central.

Installation

Maven

Add the following dependency to your pom.xml:

pom.xml

<dependency>
  <groupId>io.github.carsxe</groupId>
  <artifactId>carsxe</artifactId>
  <version>1.0.3</version>
</dependency>

Setup

Initialize the CarsXE object with your API key:

Main.java

import io.github.carsxe.CarsXE;
public class Main {
    public static void main(String[] args) {
        // Initialize the CarsXE object
        CarsXE carsxe = new CarsXE("YOUR_API_KEY_HERE");
    }
}

Basic Usage

VIN Specifications

Main.java

import io.github.carsxe.CarsXE;
import java.util.Map;
import java.util.HashMap;
public class Main {
    public static void main(String[] args) {
        CarsXE carsxe = new CarsXE("YOUR_API_KEY_HERE");
        Map<String, String> params = new HashMap<>();
        params.put("vin", "WBAFR7C57CC811956");
        Map<String, Object> specs = carsxe.specs(params);
        System.out.println(specs);
    }
}

International VIN Decoder

Main.java

Map<String, String> params = new HashMap<>();
params.put("vin", "WF0MXXGBWM8R43240");
Map<String, Object> internationalVin = carsxe.internationalVinDecoder(params);
System.out.println(internationalVin);

Market Value

Main.java

Map<String, String> params = new HashMap<>();
params.put("vin", "WBAFR7C57CC811956");
Map<String, Object> marketValue = carsxe.marketvalue(params);
System.out.println(marketValue);

Vehicle History

Main.java

Map<String, String> params = new HashMap<>();
params.put("vin", "WBAFR7C57CC811956");
Map<String, Object> history = carsxe.history(params);
System.out.println(history);

License Plate Decoder

Main.java

Map<String, String> params = new HashMap<>();
params.put("plate", "7XER187");
params.put("state", "CA");
params.put("country", "US");
Map<String, Object> plateInfo = carsxe.platedecoder(params);
System.out.println(plateInfo);

Vehicle Images

Main.java

Map<String, String> params = new HashMap<>();
params.put("make", "BMW");
params.put("model", "X5");
params.put("year", "2019");
Map<String, Object> images = carsxe.images(params);
System.out.println(images);

Vehicle Recalls

Main.java

Map<String, String> params = new HashMap<>();
params.put("vin", "1C4JJXR64PW696340");
Map<String, Object> recalls = carsxe.recalls(params);
System.out.println(recalls);

Plate Image Recognition

Main.java

String imageUrl = "https://api.carsxe.com/img/apis/plate_recognition.JPG";
Map<String, Object> plateRecognition = carsxe.plateImageRecognition(imageUrl);
System.out.println(plateRecognition);

VIN OCR from Image

Main.java

String imageUrl = "https://user-images.githubusercontent.com/5663423/30922082-64edb4fa-a3a8-11e7-873e-3fbcdce8ea3a.png";
Map<String, Object> vinOcr = carsxe.vinOcr(imageUrl);
System.out.println(vinOcr);

Main.java

Map<String, String> params = new HashMap<>();
params.put("year", "2023");
params.put("make", "Toyota");
params.put("model", "Camry");
Map<String, Object> ymm = carsxe.yearMakeModel(params);
System.out.println(ymm);

OBD Code Decoder

Main.java

Map<String, String> params = new HashMap<>();
params.put("code", "P0115");
Map<String, Object> obdCodes = carsxe.obdcodesdecoder(params);
System.out.println(obdCodes);

Error Handling

The SDK provides comprehensive error handling:

ErrorHandling.java

import io.github.carsxe.CarsXE;
import java.util.Map;
import java.util.HashMap;
public class ErrorHandling {
    public static void main(String[] args) {
        CarsXE carsxe = new CarsXE("YOUR_API_KEY_HERE");
        try {
            Map<String, String> params = new HashMap<>();
            params.put("vin", "INVALID_VIN");
            Map<String, Object> result = carsxe.specs(params);
            System.out.println(result);
        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

Environment Variables

Store your API key securely using environment variables:

.env

# .env file
CARSXE_API_KEY=your_api_key_here

Main.java

import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;
import io.github.carsxe.CarsXE;
public class Main {
    public static void main(String[] args) {
        Properties props = new Properties();
        try {
            props.load(new FileInputStream(".env"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        String apiKey = props.getProperty("CARSXE_API_KEY");
        CarsXE carsxe = new CarsXE(apiKey);
    }
}

Available Endpoints

MethodDescription
carsxe.specs(params)Decode VIN & get full vehicle specifications
carsxe.internationalVinDecoder(params)Decode VIN with worldwide support
carsxe.platedecoder(params)Decode license plate info
carsxe.marketvalue(params)Estimate vehicle market value based on VIN
carsxe.history(params)Retrieve vehicle history
carsxe.images(params)Fetch images by make, model, year, trim
carsxe.recalls(params)Get safety recall data for a VIN
carsxe.plateImageRecognition(imageUrl)Read & decode plates from images
carsxe.vinOcr(imageUrl)Extract VINs from images using OCR
carsxe.yearMakeModel(params)Query vehicle by year, make, model and trim
carsxe.obdcodesdecoder(params)Decode OBD error/diagnostic codes

Start building powerful automotive applications with CarsXE's Java SDK!