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

# WebSocket channels

> Every 0xArchive WebSocket channel by venue family: its symbols, whether it streams live, replays, or both, and what each message does to your local state.

Pick the channel for the stream you want and the symbol for the market inside it. Each venue family has its own channels and symbol format. The [channel reference](#channel-reference) lists every channel, whether it streams live, replays, or both, and whether each message replaces the state you hold or changes it.

## Subscribe

Send `subscribe` with a channel and symbol after the socket opens, and treat the stream as active once `subscribed` arrives. Every example runs on any plan, including Free.

<CodeGroup>
  ```javascript Hyperliquid order book theme={"theme":"github-dark"}
  ws.send(JSON.stringify({
    op: "subscribe",
    channel: "orderbook",
    symbol: "BTC"
  }));
  ```

  ```javascript HIP-3 L4 diffs theme={"theme":"github-dark"}
  ws.send(JSON.stringify({
    op: "subscribe",
    channel: "hip3_l4_diffs",
    symbol: "xyz:XYZ100"
  }));
  ```

  ```javascript Hyperliquid Spot order book theme={"theme":"github-dark"}
  ws.send(JSON.stringify({
    op: "subscribe",
    channel: "spot_orderbook",
    symbol: "HYPE-USDC"
  }));
  ```

  ```javascript HIP-4 trades theme={"theme":"github-dark"}
  // A side stops trading when its outcome settles, so pick a live one when the example runs.
  const res = await fetch("https://api.0xarchive.io/v1/hyperliquid/hip4/instruments", {
    headers: { "X-API-Key": process.env.OXARCHIVE_API_KEY }
  });
  const side = (await res.json()).data.find(
    (i) => !i.is_settled && Date.parse(i.recurring_expiry) > Date.now()
  ).coin;

  ws.send(JSON.stringify({
    op: "subscribe",
    channel: "hip4_trades",
    symbol: side
  }));
  ```

  ```javascript Lighter order book theme={"theme":"github-dark"}
  ws.send(JSON.stringify({
    op: "subscribe",
    channel: "lighter_orderbook",
    symbol: "BTC",
    interval_ms: 1000
  }));
  ```

  ```javascript Robinhood Chain trades theme={"theme":"github-dark"}
  ws.send(JSON.stringify({
    op: "subscribe",
    channel: "rh_lighter_trades",
    symbol: "AAPL-USDG"
  }));
  ```
</CodeGroup>

To stop a stream, send `unsubscribe` with the same channel and symbol, and remove it from your local state once `unsubscribed` arrives:

```javascript theme={"theme":"github-dark"}
ws.send(JSON.stringify({
  op: "unsubscribe",
  channel: "orderbook",
  symbol: "BTC"
}));
```

Native Hyperliquid `userFills` maps to 0xArchive `trades`. There is no WebSocket channel named `userFills`: subscribe to `trades` and filter the rows client-side when you need attribution.

## Replay

Send `replay` with a bounded window instead of `subscribe` to receive stored history. These examples replay windows that end a few minutes ago, inside every plan's history, including Free's most recent 30 days. [WebSocket replay](/websocket/replay) covers the events, controls, and delivery models.

<CodeGroup>
  ```javascript HIP-3 L4 replay theme={"theme":"github-dark"}
  const end = Date.now() - 5 * 60_000; // five minutes ago
  const start = end - 60_000;          // one minute earlier

  ws.send(JSON.stringify({
    op: "replay",
    channel: "hip3_l4_diffs",
    symbol: "xyz:XYZ100",
    start,
    end
  }));
  ```

  ```javascript Full-depth order book replay theme={"theme":"github-dark"}
  const end = Date.now() - 5 * 60_000; // five minutes ago
  const start = end - 2_000;           // two seconds earlier

  ws.send(JSON.stringify({
    op: "replay",
    channel: "orderbook_full",
    symbol: "BTC",
    start,
    end
  }));
  ```
</CodeGroup>

Replay examples for every Lighter and Lighter on Robinhood Chain channel are on [Lighter channels](/websocket/lighter#replay).

## Channel reference

Live and replay availability below matches [`GET /v1/capabilities`](/capabilities), which publishes it per venue and data type. Each entry says how the channel delivers history and what each message does to the state you hold:

* **Live:** you can `subscribe` to it.
* **Real-time only:** live, with no replay; history, where it exists, is on REST.
* **Timed replay:** `historical_data` messages paced by `speed`, up to your plan's standard replay speed.
* **Checkpoint replay:** Checkpoint-anchored bulk replay: one `l4_snapshot` from the latest checkpoint at or before `start`, then ordered `l4_batch` messages; `speed` is ignored, the request is single-channel, and it is refused when no checkpoint exists for the symbol and window. [WebSocket replay](/websocket/replay) has the event flow.
* **Replaces:** each message is complete; replace what you hold with it.
* **Adds:** each message carries new events; append them.
* **Changes:** each message changes the snapshot you hold; apply the changes in the order received.

### Hyperliquid core

Symbols are bare coin names such as `BTC` and `ETH`.

* **`orderbook`:** Live and timed replay. Replaces: the top 20 price levels per side, as `levels` `[bids, asks]` live and as `bids` and `asks` in replay rows.
* **`orderbook_full`:** Live and checkpoint replay. Changes: full-depth L2. It opens with an `l4_snapshot` of every price level, then `l4_batch` level changes `{side, px, sz, n, bn}`: set the level at `px` to size `sz` and order count `n`, and remove it when `sz` is `0`.
* **`l4_diffs`:** Live and checkpoint replay. Changes: Hyperliquid core L4. It opens with an `l4_snapshot` of every resting order, then `l4_batch` order diffs that change it. [L4 order book](/websocket/l4-orderbook) has the rules for applying them.
* **`l4_orders`:** Live and checkpoint replay. Adds: `l4_batch` order lifecycle events. A live subscription starts with no snapshot; a replay opens with one.
* **`trades`:** Live and timed replay. Adds: fill legs. Trade-row `user_address` and `builder_address` fields can be null depending on the source; filter them client-side.
* **`liquidations`:** Live and timed replay. Adds: liquidation events.
* **`open_interest`** and **`funding`:** Live and timed replay. Replaces: live messages carry the market context `{coin, ctx}`, with open interest, funding, mark, oracle and mid prices, and 24-hour volume.
* **`candles`:** Replay only, timed; use REST for current candles. Each row is one candle, one hour wide unless the replay sets `interval`.
* **`ticker`:** Real-time only. Replaces: the same `{coin, ctx}` market context for one symbol.
* **`all_tickers`:** Real-time only. It takes no symbol. Replaces: `mids`, the mid price of every market.

### Hyperliquid Spot

Symbols are dashed pairs such as `HYPE-USDC` and `PURR-USDC`.

* **`spot_orderbook`:** Real-time only. Replaces: the top 20 price levels per side, as separate `bids` and `asks` arrays.
* **`spot_trades`:** Real-time only. Adds: fill legs.
* **`spot_l4_diffs`** and **`spot_l4_orders`:** Live and checkpoint replay. Changes and adds, as `l4_diffs` and `l4_orders` do: the Spot L4 channels carry order-level diffs and events, delivered as on Hyperliquid core, with the dashed pair symbol in each frame.
* **`spot_twap`:** accepted but sends no messages. Read TWAP from the [Spot TWAP routes](/rest-api/spot).

Spot order lifecycle records are on the REST Spot order-history route too. Spot has no funding, open interest, or liquidations.

### HIP-3

Symbols keep the builder prefix and its case: `xyz:XYZ100`, `km:US500`, `hyna:BTC`. Do not turn them into ordinary perp symbols.

* **`hip3_orderbook`:** Live and timed replay. Replaces: the top 20 price levels per side, as on `orderbook`.
* **`hip3_orderbook_full`:** Live and checkpoint replay. Changes: full-depth L2 level changes, as on `orderbook_full`.
* **`hip3_l4_diffs`** and **`hip3_l4_orders`:** Live and checkpoint replay. Changes and adds: HIP-3 L4, delivered as `l4_diffs` and `l4_orders` are.
* **`hip3_trades`** and **`hip3_liquidations`:** Live and timed replay. Adds: fill legs and liquidation events.
* **`hip3_open_interest`** and **`hip3_funding`:** Live and timed replay. Replaces: the `{coin, ctx}` market context.
* **`hip3_candles`:** Replay only, timed; use REST for current candles.

### HIP-4

Symbols are outcome side coins such as `#0`, as `GET /v1/hyperliquid/hip4/outcomes` lists them. Keep the outcome and side context.

* **`hip4_trades`:** Live and timed replay. Adds: fill legs.
* **`hip4_l4_diffs`** and **`hip4_l4_orders`:** Live and checkpoint replay. Changes and adds: HIP-4 L4, delivered as `l4_diffs` and `l4_orders` are.
* **`hip4_orderbook`** and **`hip4_open_interest`:** Replay only, timed, from stored history; use REST for the current book and outcome-side open interest.

HIP-4 has no funding, liquidation, or candle stream.

### Hyperliquid, all products

One channel covers perps, HIP-3, HIP-4, and Spot together. Its `symbol` is optional; when you send one, spell it as in that product's section above.

* **`mempool`:** Real-time only. It is never stored, so no route has its history. Adds: signed transactions as our Hyperliquid node receives them, before they are in a block, one item per action. It is served only on `wss://stream.0xarchive.io/ws`, and it is the one channel that comes with the Pro, Scale and Enterprise plans rather than every plan. [Mempool channel](/websocket/mempool) has the messages, limits, and errors.

### Lighter

Symbols are the names `GET /v1/lighter/instruments` lists, such as `BTC` and `ETH`. Keep Lighter data under the Lighter family even when the symbol text matches a Hyperliquid market.

Lighter live subscriptions are available on `lighter_orderbook`, `lighter_trades`, `lighter_open_interest`, and `lighter_funding` through `wss://api.0xarchive.io/ws`. `lighter_candles` and `lighter_l3_orderbook` are replay-only, and all six Lighter channels support historical replay.

* **`lighter_orderbook`:** Live and timed replay. Replaces: a full top-20 book per side, at most once per interval: one book a second by default, or the rate set by the optional `interval_ms` subscribe field (`100` to `5000`).
* **`lighter_trades`:** Live and timed replay. Adds: fill legs, two per trade with the same `tid`. Replay returns finalized trades only.
* **`lighter_open_interest`** and **`lighter_funding`:** Live and timed replay. Replaces: both carry the same market-context message.
* **`lighter_candles`:** Replay only, timed; use REST for current candles.
* **`lighter_l3_orderbook`:** Replay only, timed. Lighter L3: each row is an order-level snapshot; use REST for current L3 depth.

Without the version selector, live Lighter payloads differ from the `historical_data` rows that Lighter replay returns, so parse them separately; with `version=2026-10-01`, replay rows use the live shapes. [Lighter channels](/websocket/lighter) documents every payload field, error, and lag notice.

### Lighter on Robinhood Chain

Symbols are perps such as `BTC` and dashed spot pairs with the USDG quote, such as `AAPL-USDG`. This is Lighter's second deployment, with its own markets, so keep it apart from mainnet Lighter.

Lighter on Robinhood Chain live subscriptions are available on `rh_lighter_orderbook`, `rh_lighter_trades`, `rh_lighter_open_interest`, and `rh_lighter_funding` through `wss://api.0xarchive.io/ws`. `rh_lighter_candles` is replay-only, and all five Robinhood Chain channels support historical replay.

* **`rh_lighter_orderbook`:** Live and timed replay. Replaces, as on `lighter_orderbook`, with the same `interval_ms` range.
* **`rh_lighter_trades`:** Live and timed replay. Adds: fill legs, as on `lighter_trades`.
* **`rh_lighter_open_interest`** and **`rh_lighter_funding`:** Live and timed replay. Replaces: the market-context message, perps only.
* **`rh_lighter_candles`:** Replay only, timed; use REST for current candles.

It has no L3 channel, and a multi-channel replay keeps `rh_lighter_*` and `lighter_*` channels in separate commands.

## Keep subscription state correct

Track each active subscription as application state, and restore from that list after a reconnect:

* **Venue family, channel, and symbol,** such as Hyperliquid core `orderbook` `BTC`, HIP-3 `hip3_l4_diffs` `xyz:XYZ100`, or HIP-4 `hip4_trades` `#0`, in the family's own symbol format.
* **Book interval:** the `interval_ms` you set on `lighter_orderbook` or `rh_lighter_orderbook`. A reconnect without it falls back to one book a second.
* **Consumer:** dashboard, alert, local book, replay, or export writer, which sets throughput and gap tolerance.
* **Stop condition:** unsubscribe, close, replay stop, or a retry budget, so no stream is abandoned.

Apply messages by what they are. A message that **replaces** is a complete state: `orderbook`, `hip3_orderbook`, `spot_orderbook`, the Lighter books, and the market-context channels. A message that **changes** a snapshot needs that snapshot first and must be applied in order: the full-depth and L4 diff channels. When a gap event appears or a reconnect happens, mark state built from changes unsafe until a fresh snapshot or replay window rebuilds it. Store channel, symbol, timestamp, and message type with local state, and expose the active channel set in debug output, so a stream problem can be inspected without reproducing the session.

Subscribe to the smallest channel and symbol set the job needs, and add more only after throughput and reconnects behave.

## Next step

Parse every command and event, live and replayed, with the [Protocol reference](/websocket/schema).


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