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

# Order Book Stream

This stream provides the order book for a single **contract**, including implied volatility
on the ask side. Subscribe with the `publicOrderBook` subscription. Updates arrive as
`publicOrderBookDelta` messages, and you can request a full snapshot at any time with
`emitPublicOrderBook`.

<Note>
  For `publicOrderBookDelta` messages, `quantity` is the absolute size at that price level.
  A `quantity` of `0` means the level should be removed from your local book.
</Note>

Upon subscription to this stream, you will receive `publicOrderBookDelta` messages whenever
the order book changes:

```json theme={null}
{
  "resultType": "publicOrderBookDelta",
  "market": "BTC-10JUL26-55000-C",
  "data": {
    "market": "BTC-10JUL26-55000-C",
    "orders": [
      { "orderType": "buy", "price": "6700", "quantity": "0" }
    ],
    "bestBid": { "price": "7204.26", "size": "4" },
    "bestAsk": { "price": "7210.97", "size": "3" },
    "statusCode": 200,
    "ts": 1783351516417
  }
}
```

| Field                           | Type   | Required | Description                                                                                            |
| ------------------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------ |
| `resultType`                    | string | Yes      | `publicOrderBookDelta`                                                                                 |
| `market`                        | string | Yes      | Contract name                                                                                          |
| `data.market`                   | string | Yes      | Contract name                                                                                          |
| `data.orders`                   | array  | Yes      | Changed price levels                                                                                   |
| `data.orders[].orderType`       | string | Yes      | Side: `buy` or `sell`                                                                                  |
| `data.orders[].price`           | string | Yes      | Price level                                                                                            |
| `data.orders[].quantity`        | string | Yes      | New absolute size at the level; `0` removes the level                                                  |
| `data.orders[].iv`              | string | No       | Implied volatility at the level (present on the ask side)                                              |
| `data.bestBid` / `data.bestAsk` | object | No       | Updated top-of-book summary (`price`, `size`, and `iv` on the ask side); omitted if that side is empty |
| `data.statusCode`               | number | Yes      | `200`                                                                                                  |
| `data.ts`                       | number | Yes      | Timestamp (ms since epoch)                                                                             |

### Order Book Snapshot Request

Request a full order book snapshot with `emitPublicOrderBook`, which returns a
`publicOrderBook` message. Use it to bootstrap your local book when you first subscribe, or to
resynchronize after a gap.

#### Request

```json theme={null}
{
  "message": "emitPublicOrderBook",
  "content": {
    "clientRequestId": "4cc68b60-ed2d-42aa-a21e-cb5486f8fd1a",
    "market": "BTC-10JUL26-55000-C"
  }
}
```

| Field                     | Type   | Required | Description                           |
| ------------------------- | ------ | -------- | ------------------------------------- |
| `message`                 | string | Yes      | `emitPublicOrderBook`                 |
| `content.clientRequestId` | string | No       | Client-generated UUID for correlation |
| `content.market`          | string | Yes      | Contract name                         |

#### Response

```json theme={null}
{
  "resultType": "publicOrderBook",
  "market": "BTC-10JUL26-55000-C",
  "data": {
    "market": "BTC-10JUL26-55000-C",
    "orders": [
      { "orderType": "sell", "price": "7247.97", "quantity": "4", "iv": "0.5968" },
      { "orderType": "buy", "price": "7104.44", "quantity": "4" },
      { "orderType": "buy", "price": "6960.92", "quantity": "16" },
      { "orderType": "buy", "price": "6700", "quantity": "1" }
    ],
    "bestBid": { "price": "7104.44", "size": "4" },
    "bestAsk": { "price": "7247.97", "size": "4", "iv": "0.5968" },
    "statusCode": 200,
    "ts": 1783085417173,
    "clientRequestId": "4cc68b60-ed2d-42aa-a21e-cb5486f8fd1a"
  }
}
```

| Field                           | Type   | Required | Description                                                                                    |
| ------------------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------- |
| `resultType`                    | string | Yes      | `publicOrderBook`                                                                              |
| `market`                        | string | Yes      | Contract name                                                                                  |
| `data.market`                   | string | Yes      | Contract name                                                                                  |
| `data.orders`                   | array  | Yes      | Price levels                                                                                   |
| `data.orders[].orderType`       | string | Yes      | Side: `buy` or `sell`                                                                          |
| `data.orders[].price`           | string | Yes      | Price level                                                                                    |
| `data.orders[].quantity`        | string | Yes      | Size at the price level                                                                        |
| `data.orders[].iv`              | string | No       | Implied volatility at the level (present on the ask side)                                      |
| `data.bestBid` / `data.bestAsk` | object | No       | Top-of-book summary (`price`, `size`, and `iv` on the ask side); omitted if that side is empty |
| `data.statusCode`               | number | Yes      | `200`                                                                                          |
| `data.ts`                       | number | Yes      | Timestamp (ms since epoch)                                                                     |
| `data.clientRequestId`          | string | No       | Client-generated UUID for correlation                                                          |
