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

# GET /v1/markets/:id/book

> Live L2 orderbook aggregated by price level.

Returns the current order book for both sides (or a specific side) of a market, aggregated by price level with order count and unique-maker count per level.

## Endpoint

```
GET /v1/markets/:id/book
```

## Query parameters

| Param    | Type | Default | Description                   |
| -------- | ---- | ------- | ----------------------------- |
| `side`   | int  | both    | `0` = Yes only, `1` = No only |
| `levels` | int  | 30      | Depth per side (max 200)      |

## Response

```json theme={null}
{
  "outcome_id": 0,
  "as_of": { "us": 1777745652310639, "iso": "...", "relative": "0s ago" },
  "levels_per_side": 5,
  "sides": [
    {
      "side_index": 0,
      "label": "Yes",
      "coin": "#0",
      "best_bid": "0.6478",
      "best_ask": "0.60673",
      "bids": [
        { "price": "0.6478", "size": "100.0", "orders": 1, "makers": 1 }
      ],
      "asks": [
        { "price": "0.60673", "size": "41.0",  "orders": 1, "makers": 1 },
        { "price": "0.60923", "size": "80.0",  "orders": 1, "makers": 1 },
        { "price": "0.6168",  "size": "56.0",  "orders": 1, "makers": 1 }
      ]
    },
    { "side_index": 1, "label": "No", "coin": "#1", "best_bid": "...", "best_ask": "...", "bids": [...], "asks": [...] }
  ]
}
```

| Field            | Description                                    |
| ---------------- | ---------------------------------------------- |
| `as_of`          | Timestamp the book snapshot was computed       |
| `bids[]`         | Sorted descending by price (highest bid first) |
| `asks[]`         | Sorted ascending by price (lowest ask first)   |
| `bids[i].price`  | Limit price of the level (USDH per share)      |
| `bids[i].size`   | Total resting size at this level               |
| `bids[i].orders` | Number of distinct orders at this level        |
| `bids[i].makers` | Number of distinct wallets providing this size |

## Use cases

* **Live orderbook display**: render the book directly.
* **Spread + depth analytics**: `best_ask - best_bid`, sum sizes across N levels.
* **Liquidity quality**: high `makers`/`orders` ratio = many real makers vs few large limit orders.

## Examples

<CodeGroup>
  ```bash curl theme={null}
  curl -H "X-API-Key: hip4_live_..." \
    "https://hip4.polynode.dev/api/v1/markets/0/book?levels=10"
  ```

  ```javascript JavaScript theme={null}
  const r = await fetch(
    'https://hip4.polynode.dev/api/v1/markets/0/book?side=0&levels=20',
    { headers: { 'X-API-Key': key } }
  ).then(r => r.json())

  const yes = r.sides[0]
  const spread = parseFloat(yes.best_ask) - parseFloat(yes.best_bid)
  console.log(`Yes spread: $${spread.toFixed(5)}`)
  ```
</CodeGroup>

## Notes

* For historical book reconstruction at any past timestamp see `/v1/markets/:id/book/at/:ts` (coming soon).
* Edge-cached for 1 second.
