# Listing and price history

Every site that listed the car, with days on lot, and each change of its advertised price.

## Endpoint

```
GET https://api.motorsdynamic.com/api/v2/history/{vin}
```

## Plan and price

| Plan | Access | Price |
| --- | --- | --- |
| Free | Yes | included in the 1,000 monthly calls |
| Growth | Yes | $0.0015 per call |
| Scale | Yes | $0.0009 per call |
| Enterprise | Yes | contract |

A call is billed when it answers 2xx. See [pricing](https://developers.motorsdynamic.com/pricing.md).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `vin` | path | string | yes | 17-character VIN (case-insensitive). |

## Example request

curl:

```bash
curl "https://api.motorsdynamic.com/api/v2/history/1HGCM82633A004352" \
  -H "x-api-key: $MD_API_KEY"
```

JavaScript:

```javascript
const res = await fetch("https://api.motorsdynamic.com/api/v2/history/1HGCM82633A004352", {
  headers: { "x-api-key": process.env.MD_API_KEY },
});
if (!res.ok) throw new Error(`${res.status} ${(await res.json()).error}`);
const data = await res.json();
console.log(data);
```

Python:

```python
import os, requests

res = requests.get(
    "https://api.motorsdynamic.com/api/v2/history/1HGCM82633A004352",
    headers={"x-api-key": os.environ["MD_API_KEY"]},
    timeout=10,
)
res.raise_for_status()
print(res.json())
```

## Response fields

| Field | Type | Description |
| --- | --- | --- |
| `meta` | object |  |
| `meta.truncated` | boolean |  |
| `data` | object |  |
| `data.vin` | string |  |
| `data.vehicle` | object |  |
| `data.vehicle.year` | integer or null |  |
| `data.vehicle.make` | string or null |  |
| `data.vehicle.model` | string or null |  |
| `data.vehicle.trim` | string or null |  |
| `data.summary` | object |  |
| `data.summary.first_seen_at` | string or null |  |
| `data.summary.days_since_first_seen` | integer or null |  |
| `data.summary.price_changes` | integer |  |
| `data.summary.first_price` | number or null |  |
| `data.summary.latest_price` | number or null |  |
| `data.summary.change` | number or null |  |
| `data.listings[]` | array of object |  |
| `data.listings[].domain_id` | integer |  |
| `data.listings[].dealer_name` | string or null |  |
| `data.listings[].status` | `active` or `removed` |  |
| `data.listings[].first_seen_at` | string or null |  |
| `data.listings[].last_seen_at` | string or null |  |
| `data.listings[].removed_at` | string or null |  |
| `data.listings[].days_on_lot` | integer or null |  |
| `data.listings[].time_to_sale_days` | integer or null |  |
| `data.listings[].current_price` | number or null |  |
| `data.prices[]` | array of object |  |
| `data.prices[].observed_at` | string |  |
| `data.prices[].domain_id` | integer or null |  |
| `data.prices[].price` | number |  |
| `data.prices[].msrp` | number or null |  |
| `data.price_terms` | object |  |
| `data.price_terms.basis` | `dealer_advertised` |  |
| `data.price_terms.estimate` | `false` |  |
| `data.price_terms.currency` | string |  |
| `data.price_terms.excludes` | string |  |

## Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_parameter` | A parameter is missing or malformed. The message names it. |
| 401 | `invalid_api_key` | The key is missing, revoked or mistyped. |
| 403 | `not_entitled` | The key may not read this dealer or source. |
| 404 | `not_found` | Nothing matches the identifier in the path. |
| 429 | `rate_limited or quota_exceeded` | Slow down (see `Retry-After`), or the Free monthly calls are used up. |
| 504 | `query_timeout` | The query passed its 4 second budget. Narrow the filters. Not billed. |

Every error has the same body: `{ "error": "<code>", "message": "..." }`. Full list: [errors](https://developers.motorsdynamic.com/docs/errors.md).
