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

# Quickstart

> Mint a key, list resolved markets, pull orderbook history. Under two minutes.

A self-contained walk-through. By the end you'll have a Python script
that pulls the last 50 resolved BTC 5m markets, downloads each one's
orderbook history, and writes them to disk as JSON.

## 1. Mint a key

<Steps>
  <Step title="Sign in">
    Sign in at [polyquantlab.com/signin](https://polyquantlab.com/signin).
    The free tier is enough to follow this guide (5 req/min · 500 req/day).
  </Step>

  <Step title="Open API keys">
    Go to [Dashboard → API keys](https://polyquantlab.com/dashboard/api-keys).
  </Step>

  <Step title="Create a key">
    Click **Create key**, give it a label (e.g. `quickstart-laptop`).
    The full token is shown **once** — copy it now.
  </Step>
</Steps>

<Warning>
  Tokens start with `pql_live_` and are 48 characters. They can't be
  recovered — if you lose one, revoke it and mint a new one.
</Warning>

## 2. First call

```bash theme={null}
export POLYQUANTLAB_API_KEY="pql_live_…your-key…"

curl -s https://api.polyquantlab.com/v1/markets/resolved \
  -G --data-urlencode "ticker=BTC" \
  --data-urlencode "event_type=5m" \
  --data-urlencode "limit=3" \
  -H "Authorization: Bearer $POLYQUANTLAB_API_KEY" | jq '.markets[0]'
```

Expected — a single resolved market:

```json theme={null}
{
  "market_id": "0x198001cb01bbcd740a20f949a984f5eb479b6b951d7124f556a6ccef3ae815b9",
  "ticker": "BTC",
  "event_type": "5m",
  "resolution_at": "2026-05-28T02:45:00+00:00",
  "resolved_at": "2026-05-28T02:45:16+00:00",
  "resolution_outcome": "Down",
  "strike_price": 67890.12,
  "question": "Bitcoin Up or Down — May 28, 2:40AM-2:45AM ET"
}
```

## 3. Pull orderbook history

```python theme={null}
import os, asyncio, json
import httpx

BASE = "https://api.polyquantlab.com"
KEY = os.environ["POLYQUANTLAB_API_KEY"]
HDRS = {"Authorization": f"Bearer {KEY}"}

async def main():
    async with httpx.AsyncClient(timeout=30) as c:
        # 1. Get 50 most recent resolved BTC 5m markets.
        r = await c.get(
            f"{BASE}/v1/markets/resolved",
            params={"ticker": "BTC", "event_type": "5m", "limit": 50},
            headers=HDRS,
        )
        r.raise_for_status()
        markets = r.json()["markets"]
        print(f"got {len(markets)} markets")

        # 2. For each one, fetch its full orderbook snapshot stream.
        for m in markets:
            r = await c.get(
                f"{BASE}/v1/markets/{m['market_id']}/orderbook",
                params={"limit": 100_000},
                headers=HDRS,
            )
            r.raise_for_status()
            snaps = r.json().get("snapshots", [])
            out = f"./data/{m['market_id'][:12]}.json"
            os.makedirs("./data", exist_ok=True)
            with open(out, "w") as f:
                json.dump(snaps, f)
            print(f"  {m['market_id'][:12]} → {len(snaps)} snapshots")

asyncio.run(main())
```

## 4. Next steps

<CardGroup cols={2}>
  <Card title="Walk the book" icon="footprints" href="/docs/concepts/walk-the-book">
    Convert the snapshot stream into realistic partial fills.
  </Card>

  <Card title="Run a server-side backtest" icon="play" href="/docs/api-reference/backtest/run">
    Skip the local pull entirely — POST a strategy spec and we backtest
    against the same data on our side.
  </Card>

  <Card title="Stream live snapshots" icon="radio" href="/docs/websocket">
    Subscribe to the WebSocket for sub-second pushes instead of polling.
  </Card>

  <Card title="Browse the live audit" icon="shield-check" href="/docs/api-reference/arb/audit-aggregate">
    Same audit numbers the dashboard renders — public, unedited.
  </Card>
</CardGroup>
