> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graylayer.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Orderbook History API

> Historical orderbook snapshots and deltas from prediction and crypto exchanges

The Orderbook History API serves historical orderbook data — snapshots and incremental deltas — collected from Kalshi, Gemini, and Polymarket US.

**Base URL:** `http://data.graylayer.tech`

<Note>
  History begins from **March 7, 2026**. Queries with `start_ts` before this date will be clamped to the earliest available data.
</Note>

## Getting a key

API keys are issued via Discord. Join the server, go to the **Community** tab, and post a request in **#api-key-request**.

<Card title="Join the Graylayer Discord" icon="discord" href="https://discord.gg/UxGa5C4C2A" horizontal>
  Request an API key in **#api-key-request** under the Community tab.
</Card>

## Supported exchanges

| Exchange value  | Platform                            |
| --------------- | ----------------------------------- |
| `kalshi`        | Kalshi elections prediction markets |
| `gemini`        | Gemini crypto & prediction markets  |
| `polymarket_us` | Polymarket US prediction markets    |

## Authentication

All data endpoints require an `x-api-key` header:

```bash theme={null}
curl -H "x-api-key: your_key" \
  http://data.graylayer.tech/api/kalshi/tickers
```

Requests without an API key are treated as **anonymous** — rate limited per IP with access restricted to the last 1 day of data.

### API key access control

Keys can optionally restrict:

| Field                   | Description                                                                        |
| ----------------------- | ---------------------------------------------------------------------------------- |
| `requests_per_minute`   | Rate limit for this key                                                            |
| `max_data_age_days`     | How far back queries can reach. Omit = unlimited                                   |
| `ticker_prefixes`       | Restrict to tickers matching these prefixes (case-insensitive). Omit = all tickers |
| `full_history_prefixes` | Tickers matching these prefixes bypass `max_data_age_days`                         |

## Rate limiting

Uses per-minute token buckets (one limiter per key, one per IP for anonymous). Rate limiters are in-memory and reset on restart.

When exceeded:

```json theme={null}
HTTP 429 Too Many Requests
{"error": "rate limit exceeded"}
```

## Anonymous access

Requests without `x-api-key`:

* Rate limited per IP (default: 10 req/min)
* Data restricted to the last 1 day regardless of `start_ts`
* IP is read from `X-Forwarded-For` if the service is behind a proxy (`trust_proxy = true` in config)
