Public WebSocket streams deliver real-time market data — price tickers, order book snapshots, trade history, and candlestick (kline) data — for both spot and futures markets. No API key is required for public channels; you can create aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/bitmart-api/llms.txt
Use this file to discover all available pages before exploring further.
WebsocketClient with no arguments and start subscribing immediately.
Setup
Create the client and attach your event handlers before callingsubscribe(). All updates arrive on the update event regardless of which topic or market they originate from — use the table field (spot) or group field (futures) in the payload to distinguish between channels in your handler.
Spot Public Topics
Spot topics always begin withspot/ and use underscore-separated symbols such as BTC_USDT.
- Ticker
- Order Book Depth
- Klines (Candlesticks)
- Trades
Real-time best bid/ask, last price, and 24-hour statistics for a symbol.
Futures Public Topics
Futures topics begin withfutures/ and use symbols without underscores (e.g. BTCUSDT). The client automatically routes these to the v2 futures public WebSocket connection (futuresPublicV2).
- Ticker
- Order Book Depth
- Trades
- Klines (Candlesticks)
Subscribing to
futures/ticker (no symbol suffix) delivers tickers for all active futures contracts in a single stream.Multiple Subscriptions at Once
Bothsubscribe() and subscribeTopics() accept arrays of topic strings, which are batched into a single subscribe message (up to 20 topics per request). This is the most efficient way to subscribe to many streams at startup.
subscribeTopics() to mix spot and futures topics in one call — the library will route each to its correct connection automatically:
Complete Working Example
The example below is a complete, runnable Node.js script adapted from the official SDK examples. It subscribes to several spot tickers and a range of futures klines, and logs every update.Handling Update Events
Theupdate event payload contains different fields depending on the market:
- Spot messages include a
tableproperty (e.g."spot/ticker") and adataarray. - Futures messages include a
groupproperty (e.g."futures/klineBin1m:BTCUSDT") and adataarray.