Use this file to discover all available pages before exploring further.
The WebsocketClientV2 class manages two persistent connections — one public and one private — and exposes a single subscribeTopic method that automatically routes each topic to the correct endpoint. Public topics stream anonymously from wss://ws.bitget.com/v2/ws/public; private topics authenticate against wss://ws.bitget.com/v2/ws/private using your API credentials. All events are surfaced through an EventEmitter interface, making it straightforward to wire up any downstream data pipeline or trading bot.
The SDK uses WS_KEY_MAP to identify which underlying connection manages a given topic. You rarely need to reference these directly, but they are useful when calling connect() explicitly or when filtering open/close/error events.
Key
URL
Usage
WS_KEY_MAP.v2Public
wss://ws.bitget.com/v2/ws/public
Market data (no auth required)
WS_KEY_MAP.v2Private
wss://ws.bitget.com/v2/ws/private
Account, orders, positions (auth required)
import { WebsocketClientV2, WS_KEY_MAP } from 'bitget-api';const wsClient = new WebsocketClientV2({ apiKey: process.env.API_KEY, apiSecret: process.env.API_SECRET, apiPass: process.env.API_PASS,});// Proactively connect both sockets instead of waiting for the first subscriptionconst [privateConn, publicConn] = wsClient.connectAll();await Promise.all([privateConn, publicConn]);
wsClient.subscribeTopic( instType: BitgetInstTypeV2, // market / instrument type topic: WsTopicV2, // public or private topic name coin: string = 'default', // symbol (e.g. 'BTCUSDT') or 'default' for private catch-all): void
Pass a specific symbol as the third argument for public market-data topics. For private topics, omit it or pass 'default' to receive updates for all symbols.
V2 candles are streamed in real time as each interval closes. UTC-suffixed variants align candle boundaries to midnight UTC rather than the exchange local time.
Bitget’s V3/UTA API offers additional unified account topics and cross-margin support in a single wallet. If you are starting a new integration, consider using WebsocketClientV3 for the latest features. The V2 topics documented here remain fully supported on the classic API.