Skip to content

autoapicom/auto-api-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto-api-client-java

Java License

Java client for auto-api.com. Pulls car listings from 8 marketplaces — encar, mobile.de, autoscout24, che168, dongchedi, guazi, dubicars, dubizzle.

Java 11+, single dependency (Gson). Uses java.net.http.HttpClient under the hood.

Installation

Gradle

implementation 'com.autoapi:auto-api-client:1.0.0'

Maven

<dependency>
    <groupId>com.autoapi</groupId>
    <artifactId>auto-api-client</artifactId>
    <version>1.0.0</version>
</dependency>

Usage

import com.autoapi.client.AutoApiClient;
import com.autoapi.client.model.*;

AutoApiClient client = new AutoApiClient("your-api-key");

Get filters

Map<String, Object> filters = client.getFilters("encar");

Search offers

OffersResponse offers = client.getOffers("mobilede", new OffersParams()
        .page(1)
        .brand("BMW")
        .yearFrom(2020));

// Pagination
System.out.println(offers.getMeta().getPage());
System.out.println(offers.getMeta().getNextPage());

Get single offer

OffersResponse offer = client.getOffer("encar", "40427050");

Track changes

int changeId = client.getChangeId("encar", "2025-01-15");
ChangesResponse changes = client.getChanges("encar", changeId);

// Next batch
ChangesResponse nextBatch = client.getChanges("encar", changes.getMeta().getNextChangeId());

Get offer by URL

Map<String, Object> info = client.getOfferByUrl(
        "https://encar.com/dc/dc_cardetailview.do?carid=40427050");

Decode offer data

The offer data field is a Gson JsonElement — the actual fields depend on the marketplace. Deserialize to OfferData or your own class:

Gson gson = new Gson();
for (OfferItem item : offers.getResult()) {
    OfferData d = gson.fromJson(item.getData(), OfferData.class);
    System.out.printf("%s %s %s — $%s%n", d.getMark(), d.getModel(), d.getYear(), d.getPrice());
}

Error handling

import com.autoapi.client.exception.ApiException;
import com.autoapi.client.exception.AuthException;

try {
    OffersResponse offers = client.getOffers("encar", new OffersParams().page(1));
} catch (AuthException e) {
    // 401/403 — invalid API key
    System.out.println(e.getStatusCode() + ": " + e.getMessage());
} catch (ApiException e) {
    // Any other API error
    System.out.println(e.getStatusCode() + ": " + e.getMessage());
    System.out.println(e.getResponseBody());
}

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
C# AutoApi.Client
Ruby auto-api-client
Rust auto-api-client

Documentation

auto-api.com

About

Java client for auto-api.com — car listings from encar, mobile.de, autoscout24, che168, dubicars and more

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages