Skip to main content
This walks the full path: connect, subscribe to a market’s book channel, apply the initial snapshot, then keep it current with delta frames. The client handles the handshake, keepalive, and reconnect for you — you just handle frames.
subscribe takes an array of markets, so you can open many subscriptions in one call. Each market is a MarketStream — a discriminated union on venue (polymarket needs only an outcomeId; limitless also needs kind and marketId). See the WebSocket API’s Subscriptions & markets for the market shapes and Orderbook channel for price/size units and the gap-free seq guarantee.

Confirming and closing

The server acks each subscription with a subscribed frame carrying the subscriptionId that keys every subsequent frame. Capture it if you want to unsubscribe later, and close the client when you’re done:
subscribe/unsubscribe are safe to call before the socket is open — the client replays your active subscriptions automatically on connect (and on every reconnect). See Events for the full frame set and Reconnection & lifecycle for what happens across disconnects.

Client options

Besides the required streamKey (see Authentication), createStreamClient accepts two optional settings:
baseUrl defaults to production; WebSocket defaults to the runtime’s global WebSocket (Node.js 22+, modern browsers, edge), so you only pass it on older Node or to supply a custom implementation.