Skip to content

Commit b78bf6f

Browse files
committed
Official EnCarAPI Python client — Encar API / Korean car data API
Key-gated REST client for encarapi.com (Encar.com listings, specs, prices). catalog(), nav(), vehicle(). Requires an EnCarAPI key (https://encarapi.com).
0 parents  commit b78bf6f

7 files changed

Lines changed: 254 additions & 0 deletions

File tree

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__pycache__/
2+
*.py[cod]
3+
*.egg-info/
4+
dist/
5+
build/
6+
.venv/
7+
venv/
8+
.env
9+
.env.local
10+
.DS_Store

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
MIT License
2+
3+
Copyright (c) 2026 EnCarAPI (encarapi.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
Note: This MIT license covers the client library only. Access to the EnCarAPI
24+
service and its data requires a valid API key and is subject to the terms at
25+
https://encarapi.com.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# EnCarAPI — Python client for the Encar API (Korean car data)
2+
3+
Official **Python client** for the [EnCarAPI](https://encarapi.com) — a REST **Encar API** /
4+
**Korean Car API** that gives you real-time Korean used-car data from **Encar.com**:
5+
vehicle listings, photos, full specifications, options, price history and dealer info.
6+
7+
Built for car exporters, dealers and platforms that need reliable **Korean car data**
8+
without scraping, proxies or geo-blocks.
9+
10+
> 🔑 **An EnCarAPI key is required.** The API and its data are a paid service.
11+
> Get a key (5-day trial available) at **[encarapi.com](https://encarapi.com)**.
12+
13+
## Install
14+
15+
```bash
16+
pip install git+https://github.com/ThatMojo/encarapi-python.git
17+
```
18+
19+
(A PyPI release — `pip install encarapi` — is coming soon.)
20+
21+
## Quick start
22+
23+
```python
24+
from encarapi import EnCarAPI
25+
26+
# Get your key at https://encarapi.com
27+
client = EnCarAPI("YOUR_API_KEY") # or set ENCARAPI_KEY in your environment
28+
29+
# Search & filter the Korean car catalog (Encar.com listings)
30+
cars = client.catalog(count=True)
31+
32+
# Filter facets (brands, models, counts)
33+
facets = client.nav()
34+
35+
# Full detail for one vehicle: specs, options, inspection, price
36+
detail = client.vehicle("12345678")
37+
```
38+
39+
Without a valid key every call raises a clear error pointing you to
40+
[encarapi.com](https://encarapi.com) — there's no free data here, just a clean client
41+
for the paid API.
42+
43+
## Why EnCarAPI?
44+
45+
- **Real-time Encar.com data** — listings, photos, specs, options, price history.
46+
- **Korean → English** field mapping handled for you.
47+
- **One REST API** instead of brittle scrapers, proxies and bot defenses.
48+
- **Plans from €149/month**, with a 5-day trial.
49+
50+
## Methods
51+
52+
| Method | Endpoint | Description |
53+
|---|---|---|
54+
| `client.catalog(**params)` | `GET /api/catalog` | Search & filter Korean car listings |
55+
| `client.nav(**params)` | `GET /api/nav` | Filter facets / navigation metadata |
56+
| `client.vehicle(id)` | `GET /api/vehicle/:id` | Full per-vehicle detail |
57+
58+
## Links
59+
60+
- 🌐 Website & pricing: **https://encarapi.com**
61+
- 📖 API documentation: **https://encarapi.com/documentation**
62+
- 📦 Node.js client: **https://github.com/ThatMojo/encarapi-node**
63+
64+
## License
65+
66+
MIT for this client library. Use of the EnCarAPI service itself requires a valid API
67+
key and is subject to the EnCarAPI terms at [encarapi.com](https://encarapi.com).
68+
69+
---
70+
71+
*Keywords: Encar API, Encar.com API, Korean Car API, Korea car API, Korean used car
72+
data, Korean car data API, car export Korea, vehicle data API, Encar data.*

encarapi/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Official Python client for the EnCarAPI — Korean car data API (Encar.com).
2+
3+
Get an API key at https://encarapi.com (a key is required).
4+
"""
5+
from .client import EnCarAPI, EnCarAPIError, MissingApiKeyError
6+
7+
__version__ = "0.1.0"
8+
__all__ = ["EnCarAPI", "EnCarAPIError", "MissingApiKeyError", "__version__"]

encarapi/client.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""Official Python client for the EnCarAPI — Korean car data API (Encar.com)."""
2+
from __future__ import annotations
3+
4+
import os
5+
from typing import Any, Dict, Optional
6+
7+
import requests
8+
9+
__all__ = ["EnCarAPI", "EnCarAPIError", "MissingApiKeyError"]
10+
11+
DEFAULT_BASE_URL = "https://api.encarapi.com"
12+
SIGNUP_URL = "https://encarapi.com"
13+
14+
15+
class EnCarAPIError(Exception):
16+
"""Raised when the EnCarAPI returns an error response."""
17+
18+
19+
class MissingApiKeyError(EnCarAPIError):
20+
"""Raised when no API key is provided."""
21+
22+
23+
class EnCarAPI:
24+
"""Client for the EnCarAPI Korean car data API.
25+
26+
An EnCarAPI key is **required**. Get one (5-day trial available) at
27+
https://encarapi.com — the API and its data are not free.
28+
29+
from encarapi import EnCarAPI
30+
31+
client = EnCarAPI("YOUR_API_KEY") # or set ENCARAPI_KEY in the environment
32+
cars = client.catalog(count=True)
33+
detail = client.vehicle("12345678")
34+
"""
35+
36+
def __init__(
37+
self,
38+
api_key: Optional[str] = None,
39+
*,
40+
base_url: str = DEFAULT_BASE_URL,
41+
timeout: float = 30.0,
42+
) -> None:
43+
api_key = api_key or os.environ.get("ENCARAPI_KEY")
44+
if not api_key:
45+
raise MissingApiKeyError(
46+
"An EnCarAPI key is required. Pass it as EnCarAPI('YOUR_KEY') or set "
47+
f"the ENCARAPI_KEY environment variable. Get a key at {SIGNUP_URL}"
48+
)
49+
self.api_key = api_key
50+
self.base_url = base_url.rstrip("/")
51+
self.timeout = timeout
52+
self._session = requests.Session()
53+
self._session.headers.update(
54+
{"x-api-key": api_key, "Accept": "application/json"}
55+
)
56+
57+
# -- low level -------------------------------------------------------
58+
def _get(self, path: str, params: Optional[Dict[str, Any]] = None) -> Any:
59+
resp = self._session.get(
60+
f"{self.base_url}{path}", params=params, timeout=self.timeout
61+
)
62+
if resp.status_code == 401 or resp.status_code == 403:
63+
raise EnCarAPIError(
64+
f"EnCarAPI rejected the request ({resp.status_code}). "
65+
f"Check your key or subscription at {SIGNUP_URL}. Body: {resp.text[:300]}"
66+
)
67+
if not resp.ok:
68+
raise EnCarAPIError(f"EnCarAPI error {resp.status_code}: {resp.text[:300]}")
69+
return resp.json()
70+
71+
# -- endpoints -------------------------------------------------------
72+
def catalog(self, **params: Any) -> Any:
73+
"""Search & filter the Korean car catalog (Encar.com listings)."""
74+
return self._get("/api/catalog", params or None)
75+
76+
def nav(self, **params: Any) -> Any:
77+
"""Filter facets / navigation metadata (brands, models, counts)."""
78+
return self._get("/api/nav", params or None)
79+
80+
def vehicle(self, vehicle_id: str) -> Any:
81+
"""Full detail for one vehicle: specs, options, inspection, price."""
82+
return self._get(f"/api/vehicle/{vehicle_id}")

examples/quickstart.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""EnCarAPI Python quickstart. Get a key at https://encarapi.com"""
2+
import os
3+
4+
from encarapi import EnCarAPI
5+
6+
client = EnCarAPI(os.environ["ENCARAPI_KEY"]) # required
7+
8+
# Newest listings (count=True returns the total available)
9+
catalog = client.catalog(count=True)
10+
print("catalog keys:", list(catalog)[:5] if hasattr(catalog, "__iter__") else catalog)
11+
12+
# Filter facets
13+
facets = client.nav()
14+
print("facets:", str(facets)[:200])
15+
16+
# One vehicle's full detail
17+
# detail = client.vehicle("12345678")
18+
# print(detail)

pyproject.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "encarapi"
7+
version = "0.1.0"
8+
description = "Official Python client for the EnCarAPI — Korean car data API (Encar.com listings, specs, prices)."
9+
readme = "README.md"
10+
requires-python = ">=3.8"
11+
license = { text = "MIT" }
12+
authors = [{ name = "EnCarAPI", email = "support@encarapi.com" }]
13+
keywords = [
14+
"encar",
15+
"encar api",
16+
"encar.com",
17+
"korean car api",
18+
"korea car api",
19+
"korean used car data",
20+
"korean car data",
21+
"car export korea",
22+
"vehicle data api",
23+
]
24+
classifiers = [
25+
"Development Status :: 4 - Beta",
26+
"Intended Audience :: Developers",
27+
"License :: OSI Approved :: MIT License",
28+
"Programming Language :: Python :: 3",
29+
"Topic :: Software Development :: Libraries :: Python Modules",
30+
]
31+
dependencies = ["requests>=2.20"]
32+
33+
[project.urls]
34+
Homepage = "https://encarapi.com"
35+
Documentation = "https://encarapi.com/documentation"
36+
Source = "https://github.com/ThatMojo/encarapi-python"
37+
38+
[tool.hatch.build.targets.wheel]
39+
packages = ["encarapi"]

0 commit comments

Comments
 (0)