> ## 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.

# Real-Time WebSocket Market Data

> Use 0xArchive WebSocket subscriptions for live market data when event order and stream state matter.

Real-time market data means live subscription behavior. Reach for it when REST snapshots and historical replay are the wrong primitives.

Real-time WebSocket is the right surface when the application needs continuing updates: live dashboards, monitors, alerts, local order-book state, or agent workflows that watch a bounded market. Use REST when you need one response. Use WebSocket replay when the job needs historical stream order.

## Real-Time Fit

| Need                          | Use                                            |
| ----------------------------- | ---------------------------------------------- |
| Latest point-in-time snapshot | REST order-book, trades, or summary routes     |
| Continuing live updates       | WebSocket subscription                         |
| Historical event order        | WebSocket replay                               |
| Backtest input file           | REST history or replay depending on sequencing |
| Freshness evidence            | Data-quality routes before trusting output     |

## Subscription Design

<Steps>
  <Step title="Choose route family">
    Pick Hyperliquid core, Hyperliquid Spot, HIP-3, HIP-4, or Lighter before choosing a channel.
  </Step>

  <Step title="Choose one channel and symbol">
    Start with the minimum channel-symbol pair that confirms the consumer can keep up.
  </Step>

  <Step title="Handle state changes">
    Track snapshots, updates, gaps, unsubscribe events, reconnects, and local state rebuilds.
  </Step>

  <Step title="Observe lag">
    Watch consumer lag, message queue depth, reconnect count, and gap events before widening.
  </Step>
</Steps>

## Live Subscription Packet

Use this packet before opening or regenerating a live subscription.

| Field               | Capture                                                                    |
| ------------------- | -------------------------------------------------------------------------- |
| Venue family        | Core, Spot, HIP-3, HIP-4, or Lighter                                       |
| Channel-symbol pair | One channel and one symbol for the first run                               |
| Consumer            | Dashboard, alert, local book, model input, incident monitor, or agent task |
| Keep-alive policy   | Ping interval, idle timeout, reconnect cap, and resubscribe behavior       |
| Lag signal          | Queue depth, last message time, processing delay, and dropped UI updates   |
| Exit path           | Unsubscribe, close, retry budget, or fail-visible state                    |

## Real-Time Safety

Do not subscribe to every channel by default. A broad subscription set can create local backlog, stale UI, duplicate reconnect subscriptions, or incorrect local books even if the server accepts the connection. Record active subscriptions as application state, not as unreviewed prompt text.

If an alert or model depends on a real-time stream, pair the stream with data-quality behavior. The stream client should know what to do when a gap appears, when reconnect occurs, or when freshness falls outside the job tolerance.

## Agent Prompt Shape

<Prompt>
  Use 0xArchive WebSocket for live Lighter BTC order-book monitoring. Show the channel choice, connection path, gap handling, keep-alive, and unsubscribe behavior.
</Prompt>

## Next Step

Use [WebSocket Channels](/websocket/channels) for channel examples, [Keep Alive](/websocket/keep-alive) for reconnect behavior, and [WebSocket L4 Order Book](/websocket/l4-orderbook) when the stream maintains order-level book state.
