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

# C#
URL: /docs/sdks/csharp
LLM index: /llms.txt
Description: Official CarsXE SDK for C# and .NET.
Related: /docs/sdks, /docs/get-started

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

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

### Verification

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

### Failure Modes

- The C# 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 C#/.NET SDK for vehicle-data endpoints.
Related: /docs/sdks/csharp, /docs/get-started, /docs/sdks

The `carsxe` NuGet package is the official CarsXE client for C# and .NET. It wraps the REST API with async methods and handles authentication. Requires .NET 6 or later.

## Installation

```bash
dotnet add package carsxe
```

Or via the NuGet Package Manager in Visual Studio: search for `carsxe`.

## Quick start

```csharp
using carsxe;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        CarsXE carsxe = new CarsXE(Environment.GetEnvironmentVariable("CARSXE_API_KEY")!);

        try
        {
            var vehicle = await carsxe.Specs(new Dictionary<string, string>
            {
                { "vin", "WBAFR7C57CC811956" },
            });
            Console.WriteLine(vehicle);
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
}
```

## 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 `carsxe` instance from [Quick start](#quick-start) and run inside an `async` method.

### International VIN Decoder

```csharp
var intvin = await carsxe.InternationalVinDecoder(new Dictionary<string, string>
{
    { "vin", "WF0MXXGBWM8R43240" },
});
Console.WriteLine(intvin);
```

### Market Value

```csharp
var marketvalue = await carsxe.MarketValue(new Dictionary<string, string>
{
    { "vin", "WBAFR7C57CC811956" },
});
Console.WriteLine(marketvalue);
```

### Vehicle History

```csharp
var history = await carsxe.History(new Dictionary<string, string>
{
    { "vin", "WBAFR7C57CC811956" },
});
Console.WriteLine(history);
```

### License Plate Decoder

```csharp
var decodedPlate = await carsxe.PlateDecoder(new Dictionary<string, string>
{
    { "plate", "7XER187" },
    { "state", "CA" },
    { "country", "US" },
});
Console.WriteLine(decodedPlate);
```

### Vehicle Images

```csharp
var images = await carsxe.Images(new Dictionary<string, string>
{
    { "make", "BMW" },
    { "model", "X5" },
    { "year", "2019" },
});
Console.WriteLine(images);
```

### Vehicle Recalls

```csharp
var recalls = await carsxe.Recalls(new Dictionary<string, string>
{
    { "vin", "1C4JJXR64PW696340" },
});
Console.WriteLine(recalls);
```

### Plate Image Recognition

Takes the image URL directly rather than a dictionary.

```csharp
var plateimg = await carsxe.PlateImageRecognition(
    "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public"
);
Console.WriteLine(plateimg);
```

### VIN OCR from Image

```csharp
var vinocr = await carsxe.VinOcr(
    "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public"
);
Console.WriteLine(vinocr);
```

### Year-Make-Model Search

```csharp
var yymm = await carsxe.YearMakeModel(new Dictionary<string, string>
{
    { "year", "2012" },
    { "make", "BMW" },
    { "model", "5 Series" },
});
Console.WriteLine(yymm);
```

### OBD Code Decoder

```csharp
var obdcode = await carsxe.ObdCodesDecoder(new Dictionary<string, string>
{
    { "code", "P0115" },
});
Console.WriteLine(obdcode);
```

### Lien and Theft

```csharp
var lienAndTheft = await carsxe.LienAndTheft(new Dictionary<string, string>
{
    { "vin", "2C3CDXFG1FH762860" },
});
Console.WriteLine(lienAndTheft);
```

## Error handling

Methods throw `Exception` on API errors. Wrap calls in a `try/catch` block:

```csharp
try
{
    var vehicle = await carsxe.Specs(new Dictionary<string, string> { { "vin", vin } });
    Console.WriteLine(vehicle);
}
catch (Exception ex)
{
    Console.WriteLine($"CarsXE error: {ex.Message}");
}
```

## Best practices

**Store your key in environment variables or .NET User Secrets** for local development:

```bash
# .NET User Secrets (local dev)
dotnet user-secrets set "CARSXE_API_KEY" "your_key_here"
```

**Create one instance and reuse it.** All methods are async — don't create a new `CarsXE` instance per request.

**In ASP.NET Core**, register the client as a singleton via dependency injection:

```csharp
// Program.cs
builder.Services.AddSingleton(new CarsXE(
    builder.Configuration["CARSXE_API_KEY"]!
));
```

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