This is the WebSocket connection-start checklist. WebSocket Connection remains the broader connection reference. Connect to WebSocket when the workflow needs live messages or replay control. Use REST for a one-off snapshot or bounded historical pull where streaming order does not matter.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.
Minimal Connection
Connection Checklist
Choose stream or replay
Decide whether the job needs live subscription messages, replay, or REST history before opening the socket.
Subscribe after open
Send subscription or replay commands only after the socket reaches the open state.
Handle every event class
Implement open, message, error, close, keep-alive, reconnect, and unsubscribe behavior.
What To Decide Before Code
| Decision | Why |
|---|---|
| Channel family | Prevents core, Spot, HIP-3, HIP-4, and Lighter mixups |
| Symbol format | Keeps pair symbols, builder prefixes, and outcome identifiers intact |
| Consumer capacity | Prevents message backlog and stale local state |
| Reconnect policy | Prevents tight reconnect loops |
| Gap policy | Decides whether a downstream job can continue |
Connection State To Track
Keep connection state in one object rather than scattering it across callbacks.| Field | Store |
|---|---|
status | connecting, open, closing, closed, reconnecting, or failed |
activeSubscriptions | channel-symbol pairs that should be restored after reconnect |
lastMessageAt | latest server message timestamp seen by the client |
retryCount | reconnect attempts for the current outage |
close | close code, reason, and whether the close was expected |
unsafeState | local books, alerts, or replay outputs that need rebuild after a gap |