CarsXE Developer

Go Quickstart Guide

Get started with CarsXE's Go package to integrate comprehensive vehicle data into your Go applications.


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

For more information, see the package on pkg.go.dev.

Installation

Install the CarsXE Go package using go get:

go get -u github.com/carsxe/carsxe-go-package

Setup

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

main.go

package main
import (
	"fmt"
	"github.com/carsxe/carsxe-go-package"
)
func main() {
	// Initialize the client
	client := carsxe.New("YOUR_API_KEY_HERE")
}

Basic Usage

VIN Specifications

main.go

vin := "WBAFR7C57CC811956"
vehicle := client.Specs(map[string]string{"vin": vin})
fmt.Println(vehicle["input"].(map[string]interface{})["vin"])

International VIN Decoder

main.go

intvin := client.InternationalVINDecoder(map[string]string{
	"vin": "WF0MXXGBWM8R43240",
})
fmt.Println(intvin)

Market Value

main.go

marketvalue := client.MarketValue(map[string]string{
	"vin": "WBAFR7C57CC811956",
})
fmt.Println(marketvalue)

Vehicle History

main.go

history := client.History(map[string]string{
	"vin": "WBAFR7C57CC811956",
})
fmt.Println(history)

License Plate Decoder

main.go

decodedPlate := client.PlateDecoder(map[string]string{
	"plate":   "7XER187",
	"state":   "CA",
	"country": "US",
})
fmt.Println(decodedPlate)

Vehicle Images

main.go

images := client.Images(map[string]string{
	"make":  "BMW",
	"model": "X5",
	"year":  "2019",
})
fmt.Println(images)

Vehicle Recalls

main.go

recalls := client.Recalls(map[string]string{
	"vin": "1C4JJXR64PW696340",
})
fmt.Println(recalls)

Plate Image Recognition

main.go

plateimg := client.PlateImageRecognition(map[string]string{
	"upload_url": "https://api.carsxe.com/img/apis/plate_recognition.JPG",
})
fmt.Println(plateimg)

VIN OCR from Image

main.go

vinocr := client.VinOCR(map[string]string{
	"upload_url": "https://api.carsxe.com/img/apis/plate_recognition.JPG",
})
fmt.Println(vinocr)

main.go

yymm := client.YearMakeModel(map[string]string{
	"year":  "2012",
	"make":  "BMW",
	"model": "5 Series",
})
fmt.Println(yymm)

OBD Code Decoder

main.go

obdcode := client.ObdCodesDecoder(map[string]string{
	"code": "P0115",
})
fmt.Println(obdcode)

Error Handling

The Go client provides comprehensive error handling:

error_handling.go

package main
import (
	"fmt"
	"github.com/carsxe/carsxe-go-package"
)
func main() {
	client := carsxe.New("YOUR_API_KEY")
	// The client returns map[string]interface{} and doesn't throw errors
	// Check for error field in response
	result := client.Specs(map[string]string{
		"vin": "INVALID_VIN",
	})
	if errMsg, exists := result["error"]; exists {
		fmt.Printf("API Error: %v\n", errMsg)
	} else {
		fmt.Printf("Success: %v\n", result)
	}
}

Environment Variables

Store your API key securely using environment variables:

.env

# .env file
CARSXE_API_KEY=your_api_key_here

main.go

package main
import (
	"os"
	"github.com/joho/godotenv"
	"github.com/carsxe/carsxe-go-package"
)
func main() {
	// Load .env file
	godotenv.Load()
	client := carsxe.New(os.Getenv("CARSXE_API_KEY"))
	// Your code here
}

Available Endpoints

MethodDescription
client.Specs(map[string]string{"vin": vin})Decode VIN & get full vehicle specifications
client.InternationalVINDecoder(map[string]string{"vin": vin})Decode VIN with worldwide support
client.PlateDecoder(map[string]string{"plate": plate, "state": state, "country": country})Decode license plate info
client.MarketValue(map[string]string{"vin": vin})Estimate vehicle market value based on VIN
client.History(map[string]string{"vin": vin})Retrieve vehicle history
client.Images(map[string]string{"make": make, "model": model, "year": year})Fetch images by make, model, year, trim
client.Recalls(map[string]string{"vin": vin})Get safety recall data for a VIN
client.PlateImageRecognition(map[string]string{"upload_url": url})Read & decode plates from images
client.VinOCR(map[string]string{"upload_url": url})Extract VINs from images using OCR
client.YearMakeModel(map[string]string{"year": year, "make": make, "model": model})Query vehicle by year, make, model and trim
client.ObdCodesDecoder(map[string]string{"code": code})Decode OBD error/diagnostic codes

Start building powerful automotive applications with CarsXE's Go package!