Python Client
Official Python SDK for Carapis API with full type safety and async support.
📦 Download
Extract the archive and include the generated client in your Python project.
Quick Start
from encar_public import Client
# Initialize
client = Client(
base_url="https://api2.carapis.com",
headers={"X-API-Key": "your-api-key"}
)
# Get vehicles
response = client.vehicles.list(limit=10)
vehicles = response.data.results
for vehicle in vehicles:
print(f"{vehicle.brand.name} {vehicle.vehicle_model.name}")
API Examples
List Vehicles
# Basic
response = client.vehicles.list()
# With filters
response = client.vehicles.list(
brand="hyundai",
year=2020,
limit=20,
page=1
)
Get Single Vehicle
vehicle = client.vehicles.retrieve(vehicle_id="12345")
print(f"Price: {vehicle.price} 만원")
Error Handling
from encar_public import APIError
try:
response = client.vehicles.list()
except APIError as e:
print(f"Error: {e.message}")
Async Support
import asyncio
from encar_public import AsyncClient
async def get_vehicles():
client = AsyncClient(
base_url="https://api2.carapis.com",
headers={"X-API-Key": "your-api-key"}
)
response = await client.vehicles.list(limit=10)
return response.data.results
# Usage
vehicles = asyncio.run(get_vehicles())
Features
- ✅ Type-safe with Pydantic models
- ✅ Async/await support
- ✅ Full API coverage
- ✅ Auto-generated from OpenAPI
- ✅ Comprehensive error handling
Environment Variables
import os
from encar_public import Client
client = Client(
base_url=os.getenv("CARAPIS_BASE_URL", "https://api2.carapis.com"),
headers={"X-API-Key": os.getenv("CARAPIS_API_KEY")}
)
Support
- Documentation: API Reference
- GitHub: carapis-python-client
- Issues: GitHub Issues
License
Part of the Carapis ecosystem. See LICENSE for details.