Legacy v1
Python SDK
Last updated:
Official Python SDK for the Cardog v1 API.
Docs for the previous API generation. v1 endpoints keep working, but new work should target v2. See v2 Quickstart.
The official Python SDK for the Cardog API. Supports Python 3.8+.
Installation
pip install cardog
# or
poetry add cardogQuick Start
from cardog import Cardog
client = Cardog(api_key="your-api-key")
# Decode a VIN
vehicle = client.vin.decode("1HGCM82633A123456")
print(f"{vehicle.make} {vehicle.model} {vehicle.year}")Configuration
from cardog import Cardog
client = Cardog(
api_key="your-api-key",
base_url="https://api.cardog.app", # Optional
timeout=30.0, # Optional, in seconds
)VIN Decoding
# Full decode with specs
result = client.vin.decode("1HGCM82633A123456")
print(result.make) # "Honda"
print(result.model) # "Accord"
print(result.year) # 2003
print(result.engine) # "3.0L V6"
print(result.transmission) # "Automatic"Listings Search
listings = client.listings.search(
make="Toyota",
model="Camry",
year_min=2020,
price_max=30000,
limit=20,
)
for listing in listings.data:
print(f"{listing.title} - ${listing.price}")Recalls
# Get recalls for a specific vehicle
recalls = client.recalls.by_vin("1HGCM82633A123456")
# Or search by make/model/year
toyota_recalls = client.recalls.search(
make="Toyota",
model="Camry",
year=2020,
)Async Support
import asyncio
from cardog import AsyncCardog
async def main():
client = AsyncCardog(api_key="your-api-key")
vehicle = await client.vin.decode("1HGCM82633A123456")
print(vehicle.make)
asyncio.run(main())Error Handling
from cardog import Cardog, CardogError
client = Cardog(api_key="your-api-key")
try:
result = client.vin.decode("INVALID")
except CardogError as e:
print(f"Error {e.code}: {e.message}")Type Hints
The SDK includes full type hints for IDE support:
from cardog import Cardog
from cardog.types import Vehicle, Listing
def display_vehicle(vehicle: Vehicle) -> None:
# Full autocomplete in your IDE
print(vehicle.make)Source Code
The SDK is open source: github.com/cardog-ai/cardog-python
Was this helpful?