Skip to main content

XAPI Korea Python SDK

PyPI

Python SDK for XAPI Korea. Search used-car listings from Encar and KB ChaChaCha, retrieve prices, specifications and photos, and load available Encar inspection reports and insurance history. Supported fields can be returned in English.

XAPI Korea is independent and unofficial. It is not affiliated with or endorsed by Encar or KB ChaChaCha.

Installation

Python 3.10 or newer is required.

python -m pip install xapikorea

Development setup

python -m venv .venv
source .venv/bin/activate
python -m pip install -e .

For development, install the test and build tools:

python -m pip install -e ".[dev]"
python -m pytest
python -m build

Usage

import os

from xapikorea import XAPIKorea


with XAPIKorea(os.environ["XAPIKOREA_API_KEY"]) as client:
    account = client.me()

print(account.email, account.plan)

Search either marketplace or both, with price bounds in KRW (default) or EUR:

with XAPIKorea(os.environ["XAPIKOREA_API_KEY"]) as client:
    results = client.search(
        source="all",
        brand="hyundai",
        year_from=2022,
        price_max=20_000,
        currency="eur",
        mileage_max=80_000,
        sale_type="normal",
        limit=5,
    )

for car in results.results:
    print(car.source, car.id, car.model, car.price_eur, car.listing_url)

if results.partial:
    print("Incomplete inventory:", results.source_errors)

source defaults to encar; use kbchachacha for KB only. Always store a listing's source and id together and pass both when retrieving it:

with XAPIKorea(os.environ["XAPIKOREA_API_KEY"]) as client:
    results = client.search(source="all", sale_type="normal", limit=1)
    if results.results:
        listing = results.results[0]
        car = client.get_car(listing.id, source=listing.source)
        print(car.manufacturer, car.model, car.listing_url)
        print(*car.photos, sep="\n")
        images = client.get_images(listing.id, source=listing.source)

listing_url links to either marketplace; encar_url remains available for Encar compatibility. Prices and other listing fields may be None. Search results include sale_type and lease_rent: lease and rent amounts describe a contract transfer and must not be presented as a purchase price.

Discover supported inputs and vehicle-specific Encar variants:

with XAPIKorea(os.environ["XAPIKOREA_API_KEY"]) as client:
    filters = client.get_filters(source="encar")
    makes = client.get_makes(source="encar")
    models = client.get_models("Kia", source="encar")
    choices = client.get_trims(brand="kia", model="sportage")
    if choices.generations:
        generation = choices.generations[0]
        print(generation.label, generation.count)
        variants = client.get_trims(
            brand="kia", model="sportage", generation=generation.value,
        )

Trim discovery progresses through generation, badge_group, badge, then trim. Display each choice's label and pass its exact value back to get_trims() or search(). The filters catalog's trims are common aliases, not a guarantee that a particular model has that trim.

Count matching listings without loading a result page:

with XAPIKorea(os.environ["XAPIKOREA_API_KEY"]) as client:
    count = client.count(source="all", brand="kia", sale_type="normal")
    print(count.count, count.partial, count.source_errors)

Retrieve available Encar reports after checking the detail flags:

with XAPIKorea(os.environ["XAPIKOREA_API_KEY"]) as client:
    car = client.get_car(42662587, source="encar")
    if car.inspection_available:
        inspection = client.get_inspection(car.id, source=car.source)
        print(inspection.available, inspection.had_accident)
    if car.insurance_available:
        insurance = client.get_insurance(car.id, source=car.source)
        print(insurance.available, insurance.had_insurance_accident)
    similar = client.get_similar(car.id, source=car.source, limit=5)

Missing reports mean unknown condition. is_accident_free filters Encar's seller-declared inspection classification; insurance history is separate. sales_status="under_contract" identifies Encar's contract status. listing_status can be advertised, sold, waiting, or None. advertised and a missing status do not confirm availability to buy. The legacy is_reserved flag is separate from contract status.

Methods

Method REST endpoint
me() /v1/me
search(...) /v1/search
count(...) /v1/search/count
get_filters(source=...) /v1/filters
get_makes(source=...) /v1/makes
get_models(make, source=...) /v1/makes/{make}/models
get_trims(brand=..., model=..., ...) /v1/trims
get_car(id, source=..., lang=...) /v1/cars/{id}
get_images(id, source=...) /v1/cars/{id}/images
get_inspection(id, source=..., lang=...) /v1/cars/{id}/inspection
get_insurance(id, source=...) /v1/cars/{id}/insurance
get_similar(id, source=..., limit=..., lang=...) /v1/cars/{id}/similar

Responses use dataclasses; arrays become tuples. search() supports brand, model, year and price bounds, currency, mileage bounds, fuel, transmission, body style, domestic/import car_type, is_accident_free, sale_type, color, trim, generation, badge group, badge, sort, pagination, language and source. count() accepts the same inventory filters except body_style; it has no sort, pagination or language parameters. Comma-separated supported filters, such as brand="BMW,Audi", use OR within a field.

Marketplace behavior and pagination

  • search, count, get_filters and get_makes accept source="all". Vehicle endpoints and model discovery accept one marketplace at a time.
  • KB-only and combined searches require a brand when filtering by model. They reject trim, generation, badge_group, badge and is_accident_free (including False). Use one sale type, normal or lease; rent is unsupported. Discover colors for the chosen source.
  • Trim discovery supports Encar only. KB inspection, insurance and similar listings currently return HTTP 501.
  • Follow next_page until it is None, keeping filters, source, sort and limit unchanged. REST pages support up to 50 listings. Encar has a 12,450-result depth limit; KB-only and combined searches default to a 500-result depth limit. Narrow filters to reach more inventory.
  • Combined ModifiedDate ordering alternates sources in their own newest-first order. Numeric sorts merge sorted prefixes. Counts represent marketplace listings; a physical car listed on both marketplaces can appear twice.
  • Check partial, sources and source_errors on searches and counts. A failed source is missing inventory, and the count covers successful sources.

Configuration and errors

Use base_url to point the client at a local API:

client = XAPIKorea("enc_test_key", base_url="http://localhost:8000")

Use timeout to change the default 30-second timeout. Call close() when finished, or use the client as a context manager. Requests default to English where supported; pass lang="ko" for Korean.

HTTP errors raise APIError, exposing status_code, body and an integer retry_after when supplied. Connection errors, timeouts and malformed responses raise XAPIKoreaError; APIError is a subclass of it.

License

This project is licensed under the MIT License.

Support

For bugs and feature requests, open a GitHub issue.

Metadata

Release files for xapikorea 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xapikorea 0.2.1
File Size Uploaded Provenance Actions
xapikorea-0.2.1.tar.gz 17.5 kB With provenance Details for xapikorea-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xapikorea 0.2.1
File Interpreter ABI Platform Actions
xapikorea-0.2.1-py3-none-any.whl Python 3 none any Details for xapikorea-0.2.1-py3-none-any.whl

Total release size: 29.4 kB

Release files / xapikorea-0.2.1.tar.gz

Download URL xapikorea-0.2.1.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4ae18691f93932eae43b5b276c7c9172097f8daf9c2f738ef1fbec4f7d5967e6
BLAKE2b-256 checksum
How to use checksums
fe8f33f39b8cf5c1f91cb240a9f1d4c83bda436f86c5426f77df4852feca330f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / xapikorea-0.2.1-py3-none-any.whl

Download URL xapikorea-0.2.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85b7fea2c58e98096b0dcc7c1a8baef8779e81b7ff1aaee0edd4e3b15bba18bf
BLAKE2b-256 checksum
How to use checksums
54e4f966b83ef8007b6fd8ad20d763699061f8e28828c07431f52d09b690605e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for xapikorea 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xapikorea-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page