Skip to content

autoapicom/auto-api-dotnet

Repository files navigation

auto-api-client-dotnet

NuGet .NET License

.NET client for the auto-api.com car listings API — search offers, track changes and pull listing data from 8 automotive marketplaces worldwide.

Sources: encar (Korea), mobile.de, autoscout24 (Europe), che168, dongchedi, guazi (China), dubicars, dubizzle (UAE). Zero NuGet dependencies — built on HttpClient and System.Text.Json.

Installation

dotnet add package AutoApi.Client

Usage

using AutoApi;

using var client = new AutoApiClient("your-api-key", "https://api1.auto-api.com");

Get filters

var filters = await client.GetFiltersAsync("encar");

Search offers

var offers = await client.GetOffersAsync("mobilede", new OffersParams
{
    Page = 1,
    Brand = "BMW",
    YearFrom = 2020,
});

// Pagination
Console.WriteLine(offers.Meta.Page);
Console.WriteLine(offers.Meta.NextPage);

Get single offer

var offer = await client.GetOfferAsync("encar", "40427050");

Track changes

var changeId = await client.GetChangeIdAsync("encar", "2025-01-15");
var changes = await client.GetChangesAsync("encar", changeId);

// Next batch
var nextBatch = await client.GetChangesAsync("encar", changes.Meta.NextChangeId);

Get offer by URL

var info = await client.GetOfferByUrlAsync(
    "https://encar.com/dc/dc_cardetailview.do?carid=40427050");

Decode offer data

The Data property is a JsonElement because different sources return different fields. Deserialize to your own type:

foreach (var item in offers.Result)
{
    var data = item.Data.Deserialize<MyOfferData>();
    Console.WriteLine($"{data.Mark} {data.Model} {data.Year} — ${data.Price}");
}

Error handling

try
{
    var offers = await client.GetOffersAsync("encar", new OffersParams { Page = 1 });
}
catch (AuthException ex)
{
    // 401/403 — invalid API key
    Console.WriteLine($"{ex.StatusCode}: {ex.Message}");
}
catch (ApiException ex)
{
    // Any other API error
    Console.WriteLine($"{ex.StatusCode}: {ex.Message}");
    Console.WriteLine(ex.ResponseBody);
}

Supported sources

Source Platform Region
encar encar.com South Korea
mobilede mobile.de Germany
autoscout24 autoscout24.com Europe
che168 che168.com China
dongchedi dongchedi.com China
guazi guazi.com China
dubicars dubicars.com UAE
dubizzle dubizzle.com UAE

Other languages

Language Package
PHP autoapi/client
TypeScript @autoapicom/client
Python autoapicom-client
Go auto-api-go
Java auto-api-client
Ruby auto-api-client
Rust auto-api-client

Documentation

auto-api.com

About

.NET client for the auto-api.com car listings API (encar, mobile.de, autoscout24, che168 etc.)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages