@cardog/api 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +327 -0
- package/cardog-icon.png +0 -0
- package/dist/index.d.mts +1591 -0
- package/dist/index.d.ts +1591 -0
- package/dist/index.js +2245 -0
- package/dist/index.mjs +2208 -0
- package/dist/react/index.d.mts +91 -0
- package/dist/react/index.d.ts +91 -0
- package/dist/react/index.js +1967 -0
- package/dist/react/index.mjs +1964 -0
- package/package.json +94 -0
package/README.md
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# @cardog/api
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="./cardog-icon.png" alt="Cardog" width="120" height="120" style="border-radius: 24px;">
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<strong>Official TypeScript client for the Cardog API</strong><br>
|
|
9
|
+
Vehicle data, market analysis, VIN decoding, and more.
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<br>
|
|
13
|
+
|
|
14
|
+
<div align="center">
|
|
15
|
+
|
|
16
|
+
[](https://www.npmjs.com/package/@cardog/api)
|
|
17
|
+
[](https://www.npmjs.com/package/@cardog/api)
|
|
18
|
+
[](https://www.typescriptlang.org/)
|
|
19
|
+
[](https://opensource.org/licenses/MIT)
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div align="center">
|
|
24
|
+
|
|
25
|
+
[Documentation](https://docs.cardog.app) · [Get API Key](https://cardog.app) · [Pricing](https://cardog.app/pricing)
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @cardog/api
|
|
35
|
+
# or
|
|
36
|
+
pnpm add @cardog/api
|
|
37
|
+
# or
|
|
38
|
+
yarn add @cardog/api
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For React hooks, also install:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install @tanstack/react-query
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { CardogClient } from "@cardog/api";
|
|
51
|
+
|
|
52
|
+
const client = new CardogClient({
|
|
53
|
+
apiKey: "your-api-key", // Get one at https://cardog.app
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Decode a VIN
|
|
57
|
+
const vehicle = await client.vin.decode("1HGCM82633A123456");
|
|
58
|
+
console.log(vehicle.make, vehicle.model, vehicle.year);
|
|
59
|
+
// Honda Accord 2003
|
|
60
|
+
|
|
61
|
+
// Get market analysis
|
|
62
|
+
const market = await client.market.overview("Toyota", "Camry", 2022);
|
|
63
|
+
console.log(market.medianPrice, market.totalListings);
|
|
64
|
+
|
|
65
|
+
// Search listings
|
|
66
|
+
const listings = await client.listings.search({
|
|
67
|
+
makes: ["Toyota"],
|
|
68
|
+
year: { min: 2020, max: 2024 },
|
|
69
|
+
price: { max: 50000 },
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## React Hooks
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
77
|
+
import { CardogClient } from "@cardog/api";
|
|
78
|
+
import { createHooks } from "@cardog/api/react";
|
|
79
|
+
|
|
80
|
+
const queryClient = new QueryClient();
|
|
81
|
+
const client = new CardogClient({ apiKey: "your-api-key" });
|
|
82
|
+
const { useVinDecode, useMarketOverview, useListingsSearch } = createHooks(client);
|
|
83
|
+
|
|
84
|
+
function App() {
|
|
85
|
+
return (
|
|
86
|
+
<QueryClientProvider client={queryClient}>
|
|
87
|
+
<VehicleLookup />
|
|
88
|
+
</QueryClientProvider>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function VehicleLookup() {
|
|
93
|
+
const { data, isLoading, error } = useVinDecode("1HGCM82633A123456");
|
|
94
|
+
|
|
95
|
+
if (isLoading) return <div>Loading...</div>;
|
|
96
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div>
|
|
100
|
+
{data?.make} {data?.model} ({data?.year})
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## API Reference
|
|
107
|
+
|
|
108
|
+
### VIN Decoding
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Decode a VIN
|
|
112
|
+
const vehicle = await client.vin.decode("1HGCM82633A123456");
|
|
113
|
+
|
|
114
|
+
// Decode from image (base64)
|
|
115
|
+
const result = await client.vin.image(base64Image);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Market Analysis
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Market overview for a specific vehicle
|
|
122
|
+
const overview = await client.market.overview("Toyota", "Camry", 2022);
|
|
123
|
+
|
|
124
|
+
// Price distribution
|
|
125
|
+
const pricing = await client.market.pricing("Honda", "Civic", 2021);
|
|
126
|
+
|
|
127
|
+
// Geographic breakdown
|
|
128
|
+
const geography = await client.market.geography("Ford", "F-150", 2023);
|
|
129
|
+
|
|
130
|
+
// Market trends over time
|
|
131
|
+
const trends = await client.market.trends("Tesla", "Model 3", 2022, "month");
|
|
132
|
+
|
|
133
|
+
// Listing market position
|
|
134
|
+
const position = await client.market.position("listing-id");
|
|
135
|
+
|
|
136
|
+
// Overall market pulse
|
|
137
|
+
const pulse = await client.market.pulse({
|
|
138
|
+
priceRangeMin: 20000,
|
|
139
|
+
priceRangeMax: 50000,
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Vehicle Listings
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
// Search listings with filters
|
|
147
|
+
const results = await client.listings.search({
|
|
148
|
+
makes: ["Toyota", "Honda"],
|
|
149
|
+
models: { Toyota: ["Camry", "Corolla"] },
|
|
150
|
+
year: { min: 2020, max: 2024 },
|
|
151
|
+
price: { min: 15000, max: 40000 },
|
|
152
|
+
odometer: { max: 50000 },
|
|
153
|
+
bodyStyles: ["Sedan", "SUV"],
|
|
154
|
+
fuelTypes: ["Gasoline", "Hybrid"],
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Get listing count
|
|
158
|
+
const count = await client.listings.count({ makes: ["BMW"] });
|
|
159
|
+
|
|
160
|
+
// Get facets for filtering UI
|
|
161
|
+
const facets = await client.listings.facets({ makes: ["Mercedes-Benz"] });
|
|
162
|
+
|
|
163
|
+
// Get specific listing
|
|
164
|
+
const listing = await client.listings.getById("listing-id");
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Safety Recalls
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// Search recalls
|
|
171
|
+
const recalls = await client.recalls.search({
|
|
172
|
+
country: "us", // or "ca" for Canada
|
|
173
|
+
makes: ["Toyota"],
|
|
174
|
+
models: ["RAV4"],
|
|
175
|
+
year: { min: 2019, max: 2023 },
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Research & Specs
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// Get vehicle lineup for a make
|
|
183
|
+
const lineup = await client.research.lineup("Toyota");
|
|
184
|
+
|
|
185
|
+
// Get model year details
|
|
186
|
+
const modelYear = await client.research.modelYear("Toyota", "Camry", 2023);
|
|
187
|
+
|
|
188
|
+
// Get vehicle images
|
|
189
|
+
const images = await client.research.images("Toyota", "Camry", 2023);
|
|
190
|
+
|
|
191
|
+
// Get available colors
|
|
192
|
+
const colors = await client.research.colors("Honda", "Civic", 2024);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Fuel & Charging
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// Find gas stations
|
|
199
|
+
const gasStations = await client.fuel.search({
|
|
200
|
+
lat: 43.6532,
|
|
201
|
+
lng: -79.3832,
|
|
202
|
+
radius: 10,
|
|
203
|
+
fuelType: "REGULAR",
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// Find EV charging stations
|
|
207
|
+
const chargers = await client.charging.search({
|
|
208
|
+
lat: 43.6532,
|
|
209
|
+
lng: -79.3832,
|
|
210
|
+
radius: 25,
|
|
211
|
+
minPower: 50, // kW
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Locations
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// Search dealer/seller locations
|
|
219
|
+
const dealers = await client.locations.search({
|
|
220
|
+
lat: 43.6532,
|
|
221
|
+
lng: -79.3832,
|
|
222
|
+
radius: 50,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// Get seller details
|
|
226
|
+
const seller = await client.locations.getById("seller-id");
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### EPA Efficiency
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
// Search EPA fuel economy data
|
|
233
|
+
const efficiency = await client.efficiency.search({
|
|
234
|
+
make: "Toyota",
|
|
235
|
+
model: "Prius",
|
|
236
|
+
year: 2023,
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### NHTSA Complaints
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
// Search vehicle complaints
|
|
244
|
+
const complaints = await client.complaints.search({
|
|
245
|
+
make: "Ford",
|
|
246
|
+
model: "Explorer",
|
|
247
|
+
year: { min: 2020, max: 2023 },
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Error Handling
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
import { CardogClient, APIError } from "@cardog/api";
|
|
255
|
+
|
|
256
|
+
try {
|
|
257
|
+
const data = await client.vin.decode("INVALID");
|
|
258
|
+
} catch (error) {
|
|
259
|
+
if (error instanceof APIError) {
|
|
260
|
+
console.log(error.status); // HTTP status code
|
|
261
|
+
console.log(error.code); // Error code (e.g., "INVALID_VIN")
|
|
262
|
+
console.log(error.message); // Human-readable message
|
|
263
|
+
console.log(error.data); // Additional error details
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Query Keys
|
|
269
|
+
|
|
270
|
+
For manual React Query integration:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import { queryKeys } from "@cardog/api";
|
|
274
|
+
|
|
275
|
+
// Use in custom queries
|
|
276
|
+
const { data } = useQuery({
|
|
277
|
+
queryKey: queryKeys.vin.decode("1HGCM82633A123456"),
|
|
278
|
+
queryFn: () => client.vin.decode("1HGCM82633A123456"),
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Available key factories
|
|
282
|
+
queryKeys.vin.decode(vin)
|
|
283
|
+
queryKeys.market.overview(make, model, year)
|
|
284
|
+
queryKeys.listings.search(params)
|
|
285
|
+
queryKeys.recalls.search(params)
|
|
286
|
+
// ... and more
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Configuration
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
const client = new CardogClient({
|
|
293
|
+
apiKey: "your-api-key",
|
|
294
|
+
baseUrl: "https://api.cardog.io", // Default
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Update config at runtime
|
|
298
|
+
client.setConfig({
|
|
299
|
+
apiKey: "new-api-key",
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Pricing
|
|
304
|
+
|
|
305
|
+
| Plan | Requests/mo | Price | Best For |
|
|
306
|
+
|------|-------------|-------|----------|
|
|
307
|
+
| **Free** | 100 | $0 | Testing & development |
|
|
308
|
+
| **Pro** | 10,000 | $29/mo | Small apps & side projects |
|
|
309
|
+
| **Business** | 100,000 | $199/mo | Production applications |
|
|
310
|
+
| **Enterprise** | Unlimited | Custom | High-volume integrations |
|
|
311
|
+
|
|
312
|
+
All plans include access to all API endpoints. [View full pricing →](https://cardog.app/pricing)
|
|
313
|
+
|
|
314
|
+
## Links
|
|
315
|
+
|
|
316
|
+
- [API Documentation](https://docs.cardog.app)
|
|
317
|
+
- [Get API Key](https://cardog.app)
|
|
318
|
+
- [Pricing](https://cardog.app/pricing)
|
|
319
|
+
- [GitHub Issues](https://github.com/cardog-ai/cardog-api/issues)
|
|
320
|
+
|
|
321
|
+
## Related Packages
|
|
322
|
+
|
|
323
|
+
- [`@cardog/corgi`](https://www.npmjs.com/package/@cardog/corgi) - Offline VIN decoder (no API key needed)
|
|
324
|
+
|
|
325
|
+
## License
|
|
326
|
+
|
|
327
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
package/cardog-icon.png
ADDED
|
Binary file
|