@cardog/api
Official TypeScript client for the Cardog API
Vehicle data, market analysis, VIN decoding, and more.
Installation
npm install @cardog/api
pnpm add @cardog/api
yarn add @cardog/api
For React hooks, also install:
npm install @tanstack/react-query
Quick Start
import { CardogClient } from "@cardog/api";
const client = new CardogClient({
apiKey: "your-api-key",
});
const vehicle = await client.vin.decode("1HGCM82633A123456");
console.log(vehicle.make, vehicle.model, vehicle.year);
const market = await client.market.overview("Toyota", "Camry", 2022);
console.log(market.medianPrice, market.totalListings);
const listings = await client.listings.search({
makes: ["Toyota"],
year: { min: 2020, max: 2024 },
price: { max: 50000 },
});
React Hooks
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { CardogClient } from "@cardog/api";
import { createHooks } from "@cardog/api/react";
const queryClient = new QueryClient();
const client = new CardogClient({ apiKey: "your-api-key" });
const { useVinDecode, useMarketOverview, useListingsSearch } = createHooks(client);
function App() {
return (
<QueryClientProvider client={queryClient}>
<VehicleLookup />
</QueryClientProvider>
);
}
function VehicleLookup() {
const { data, isLoading, error } = useVinDecode("1HGCM82633A123456");
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return (
<div>
{data?.make} {data?.model} ({data?.year})
</div>
);
}
API Reference
VIN Decoding
const vehicle = await client.vin.decode("1HGCM82633A123456");
const result = await client.vin.image(base64Image);
Market Analysis
const overview = await client.market.overview("Toyota", "Camry", 2022);
const pricing = await client.market.pricing("Honda", "Civic", 2021);
const geography = await client.market.geography("Ford", "F-150", 2023);
const trends = await client.market.trends("Tesla", "Model 3", 2022, "month");
const position = await client.market.position("listing-id");
const pulse = await client.market.pulse({
priceRangeMin: 20000,
priceRangeMax: 50000,
});
Vehicle Listings
const results = await client.listings.search({
makes: ["Toyota", "Honda"],
models: { Toyota: ["Camry", "Corolla"] },
year: { min: 2020, max: 2024 },
price: { min: 15000, max: 40000 },
odometer: { max: 50000 },
bodyStyles: ["Sedan", "SUV"],
fuelTypes: ["Gasoline", "Hybrid"],
});
const count = await client.listings.count({ makes: ["BMW"] });
const facets = await client.listings.facets({ makes: ["Mercedes-Benz"] });
const listing = await client.listings.getById("listing-id");
Safety Recalls
const recalls = await client.recalls.search({
country: "us",
makes: ["Toyota"],
models: ["RAV4"],
year: { min: 2019, max: 2023 },
});
Research & Specs
const lineup = await client.research.lineup("Toyota");
const modelYear = await client.research.modelYear("Toyota", "Camry", 2023);
const images = await client.research.images("Toyota", "Camry", 2023);
const colors = await client.research.colors("Honda", "Civic", 2024);
Fuel & Charging
const gasStations = await client.fuel.search({
lat: 43.6532,
lng: -79.3832,
radius: 10,
fuelType: "REGULAR",
});
const chargers = await client.charging.search({
lat: 43.6532,
lng: -79.3832,
radius: 25,
minPower: 50,
});
Locations
const dealers = await client.locations.search({
lat: 43.6532,
lng: -79.3832,
radius: 50,
});
const seller = await client.locations.getById("seller-id");
EPA Efficiency
const efficiency = await client.efficiency.search({
make: "Toyota",
model: "Prius",
year: 2023,
});
NHTSA Complaints
const complaints = await client.complaints.search({
make: "Ford",
model: "Explorer",
year: { min: 2020, max: 2023 },
});
Error Handling
import { CardogClient, APIError } from "@cardog/api";
try {
const data = await client.vin.decode("INVALID");
} catch (error) {
if (error instanceof APIError) {
console.log(error.status);
console.log(error.code);
console.log(error.message);
console.log(error.data);
}
}
Query Keys
For manual React Query integration:
import { queryKeys } from "@cardog/api";
const { data } = useQuery({
queryKey: queryKeys.vin.decode("1HGCM82633A123456"),
queryFn: () => client.vin.decode("1HGCM82633A123456"),
});
queryKeys.vin.decode(vin)
queryKeys.market.overview(make, model, year)
queryKeys.listings.search(params)
queryKeys.recalls.search(params)
Configuration
const client = new CardogClient({
apiKey: "your-api-key",
baseUrl: "https://api.cardog.app",
});
client.setConfig({
apiKey: "new-api-key",
});
Pricing
| Free | 100 | $0 | Testing & development |
| Pro | 10,000 | $29/mo | Small apps & side projects |
| Business | 100,000 | $199/mo | Production applications |
| Enterprise | Unlimited | Custom | High-volume integrations |
All plans include access to all API endpoints. View full pricing →
Links
Related Packages
License
MIT License - see LICENSE for details.