Install
ws package provides WebSocket support for Node.js.
Quick Start
REST Methods
Every REST endpoint has a typed method on thePolyNode client:
WebSocket Streaming
Subscribe to real-time events with a builder pattern:Event Callbacks
Async Iterator
Subscription Filters
All filters from the Subscriptions & Filters page are supported:Subscription Types
Multiple Subscriptions
Subscriptions stack on the same connection:Compression
Zlib compression is enabled by default for all WebSocket connections (~50% bandwidth savings). No configuration needed. To disable compression (not recommended):Auto-Reconnect
Enabled by default. The SDK reconnects with exponential backoff and replays all active subscriptions:Cleanup
Configuration
Error Handling
Orderbook Streaming
The SDK includes a dedicated orderbook client for real-time book data fromob.polynode.dev. This is a separate WebSocket connection from the event stream, with its own URL, protocol, and message format.
Subscribe
Event Handlers
LocalOrderbook Helper
Maintain a sorted local copy of the book:Compression
Zlib compression is enabled by default (~50% bandwidth savings). No configuration needed.Configuration
System Events
Cleanup
OrderbookEngine
TheOrderbookEngine is a higher-level wrapper around the orderbook WebSocket. It manages one connection, maintains local state for all subscribed tokens, and lets you create filtered views that only deliver updates for specific token subsets.
This is useful when your app has multiple components that each need different slices of the orderbook — a trade page showing one market, a sidebar showing another, a portfolio view watching 20 positions. One connection, one shared state, multiple filtered outputs.

