# History endpoint

> GET /api/history/SYM returns hourly composite open interest and funding at each settlement for one perp, up to 90 days. Free, keyless and CORS-open.

```http
GET https://deskr.trade/api/history/{SYM}?days={1..90}
```

Real exchange readings only, as written by Deskr's engine. Nothing is filled in or interpolated. It's free to use. Please link to deskr.trade when you publish the data.

| Parameter | In | Default | Notes |
|---|---|---|---|
| `SYM` | path | | Perp symbol, case-insensitive (`BTC`, `eth`) |
| `days` | query | 30 | Clamped to 1–90 |

## Response

```json
{
  "sym": "BTC",
  "updated": 1795744357,
  "days": 30,
  "oi": {
    "unit": "USD notional, hourly, summed over the venues listed",
    "venues": ["okx", "binance", "bybit"],
    "points": [[1795658400, 9909720267.39], [1795662000, 9930766448.52]]
  },
  "funding": {
    "unit": "annualised fraction (0.05 = 5% a year), mean across venues that settled in the same hour",
    "venues": ["…"],
    "points": [[1795651200, 0.0412]]
  },
  "source": "https://deskr.trade/markets/btc"
}
```

`points` are `[unix_seconds, value]` pairs. Funding is an annualised **fraction**: multiply by 100 for %.

## Errors

| Status | Body | When |
|---|---|---|
| 404 | `{"error":"unknown symbol"}` | Not a perp Deskr tracks |
| 404 | `{"error":"no history for this symbol yet"}` | Newly added coin |

## Caching and CORS

`Cache-Control: public, max-age=60, s-maxage=60, stale-while-revalidate=300` and `Access-Control-Allow-Origin: *`. The data changes hourly, so poll at most once a minute.

```js title="Example"
const r = await fetch("https://deskr.trade/api/history/ETH?days=7");
const { oi, funding } = await r.json();
console.log(oi.points.at(-1), funding.points.at(-1));
```
