---
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"
---

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

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 |

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