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

# Live streams

> Subscribe to quotes, books, public trades and reference updates.

Server-to-server connection: `wss://api.rook.pm/v1/stream`, with `Authorization: Bearer <api-key>` in the handshake. This protocol is separate from the REST OpenAPI specification.

## Subscribe explicitly

```json theme={null}
{
  "op": "subscribe",
  "request_id": "subscribe-1",
  "channel": "books",
  "listing_ids": ["lst_a_yes"],
  "depth": 10
}
```

| Channel | Selection | Initial state |
| - | - | - |
| `quotes` | Nonempty `listing_ids` | Quote snapshots, then updates |
| `books` | Nonempty `listing_ids`, optional positive `depth` | L2 snapshots, then level updates |
| `trades` | Nonempty `listing_ids` | Acknowledgement, then new public prints |
| `reference` | Nonempty `family_ids`, optional `resource_types` | Acknowledgement with change cursor, then matching changes |

Acknowledgements identify accepted and rejected selectors, the subscription ID and epoch. They never broaden subscriptions silently. Quote/book snapshots end at `snapshot_complete` before subsequent updates. Trade subscriptions do not replay historical prints; use REST for retained history.

## Sequence and recovery

Data envelopes carry `type`, `subscription_id`, `epoch`, a monotonically increasing `sequence`, `published_at` and channel-specific `data`. Epochs and sequences are scoped to each subscription. Reconnects or sequence gaps require a new affected-state snapshot.

Book deltas identify the listing, revision, timestamps and changed levels with `side`, exact `price` and exact `quantity`. Quantity is the new absolute size; zero removes the level. Reference recovery uses the acknowledged cursor with the same family/resource filters on [`GET /changes`](/api-reference/list-changes).

```json theme={null}
{
  "op": "unsubscribe",
  "request_id": "unsubscribe-1",
  "subscription_id": "sub_example"
}
```

Unsubscribe ends the named subscription and returns an acknowledgement. Errors include request/subscription references and retry or resnapshot guidance. Heartbeats indicate connection liveness, while data timestamps indicate upstream freshness.

RFQs, maker confirmation, orders and fills remain on the execution venue or broker. Customer fair values are private and outside these public channels.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.