---
title: "Go"
description: "Official CarsXE SDK for Go."
canonical_url: "https://docs.carsxe.com/docs/sdks/go"
markdown_url: "https://docs.carsxe.com/docs/sdks/go.md"
last_updated: "1980-01-01"
x_farming_labs_generated_preamble: true
agent:
  task: "Install and call the CarsXE Go SDK for vehicle-data endpoints."
  outcome: "The Go 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 Go installation steps."
  verification:
    - "Run the documented Go example and confirm it authenticates and returns vehicle data without an SDK or API error."
  failureModes:
    - symptom: "The Go 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."
---

# Go
URL: /docs/sdks/go
LLM index: /llms.txt
Description: Official CarsXE SDK for Go.
Related: /docs/sdks, /docs/get-started

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

Task: Install and call the CarsXE Go SDK for vehicle-data endpoints.
Outcome: The Go 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 Go installation steps.

### Verification

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

### Failure Modes

- The Go 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 call the CarsXE Go SDK for vehicle-data endpoints.
Related: /docs/sdks/go, /docs/get-started, /docs/sdks

The `carsxe-go-package` module is the official CarsXE client for Go. It wraps the REST API with idiomatic methods and handles authentication. Requires Go 1.18 or later.

## Installation

```bash
go get github.com/carsxe/carsxe-go-package
```

## Quick start

```go
package main

import (
	"fmt"
	"github.com/carsxe/carsxe-go-package"
)

func main() {
	client := carsxe.New("CARSXE_API_KEY")
	vehicle := client.Specs(map[string]string{
		"vin": "WBAFR7C57CC811956",
	})
	fmt.Println(vehicle)
}
```

## Methods

### Core

| Method | Description |
|---|---|
| `Specs(params)` | Decode a 17-character VIN into full vehicle specifications |
| `MarketValue(params)` | Retail, trade-in, and auction value estimates |
| `Recalls(params)` | Open safety recalls by VIN, make, model, or year |
| `PlateDecoder(params)` | VIN lookup from a license plate (50+ countries) |
| `History(params)` | Title events, salvage, junk, and insurance records |

### Bulk recall batch

| Method | Description |
|---|---|
| `SubmitBulkRecallBatch(params)` | Submit a batch of VINs for recall lookup |
| `GetBulkRecallBatchStatus(batchId)` | Poll job status |
| `GetBulkRecallBatchResults(batchId)` | Retrieve completed results |
| `GetBulkRecallBatchDownloadUrl(batchId)` | Get a CSV download URL |

## Endpoint examples

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

### International VIN Decoder

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

### Market Value

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

### Vehicle History

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

### License Plate Decoder

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

### Vehicle Images

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

### Vehicle Recalls

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

### Plate Image Recognition

```go
plateimg := client.PlateImageRecognition(map[string]string{
	"upload_url": "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public",
})
fmt.Println(plateimg)
```

### VIN OCR from Image

```go
vinocr := client.VinOCR(map[string]string{
	"upload_url": "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public",
})
fmt.Println(vinocr)
```

### Year-Make-Model Search

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

### OBD Code Decoder

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

### Lien and Theft

```go
lienAndTheft := client.LienAndTheft(map[string]string{
	"vin": "2C3CDXFG1FH762860",
})
fmt.Println(lienAndTheft)
```

## Error handling

Methods return an error value alongside the result. Always check before using the response:

```go
vehicle, err := client.Specs(map[string]string{"vin": "WBAFR7C57CC811956"})
if err != nil {
	fmt.Fprintln(os.Stderr, "CarsXE error:", err)
	os.Exit(1)
}
fmt.Println(vehicle)
```

## Best practices

**Read the key from the environment.**

```go
apiKey := os.Getenv("CARSXE_API_KEY")
if apiKey == "" {
	log.Fatal("CARSXE_API_KEY is not set")
}
client := carsxe.New(apiKey)
```

**Create one client and reuse it.** The client manages connection pooling internally — creating a new instance per request bypasses that benefit.

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

## 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).
