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, so 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 a tokenId; kalshi addresses a book by ticker; 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, because 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 keyId and privateKeyHex (see Authentication), createStreamClient accepts two optional settings:
baseUrl defaults to production; WebSocket defaults to the runtime’s global WebSocket, which Node.js provides from 22 onward, so you only pass it on Node 20 or 21 or to supply a custom implementation. Signing needs node:crypto, so this client is server-side only either way. See Authentication.