Configuration
Provide your API credentials in theaccounts array when constructing the client.
All three credential fields —
apiKey, apiSecret, and apiPass — are required for authentication. Missing any of them will cause an error when the private connection is opened.Auto-authentication
Authentication is triggered automatically when the private WebSocket connection is established. You do not need to call any login method manually. When you callsubscribe() with a private channel, the client:
1
Opens the connection
The private WebSocket connection is opened if it is not already active.
2
Authenticates
A signed login request is sent using your API credentials. The signature uses
timestamp + 'GET' + '/users/self/verify' with HMAC-SHA256.3
Subscribes
Once authentication succeeds, the subscription request is sent.
connectPrivate() early to warm up the connection before subscribing:
Event listeners
Set up all event listeners before subscribing.Private channels
Account
Streams changes to account balance and related information.Positions
Balance and Position
Combines balance and position data in one channel.Orders
Algo Orders
Liquidation Warning
Account Greeks
Options greeks for the account.Withdrawal Info
Grid Orders
Multiple accounts
You can authenticate multiple accounts on a singleWebsocketClient instance by adding more entries to the accounts array. Each account is authenticated independently and account-level data from all accounts arrives on the same update event.
Handling authentication failures
Authentication errors arrive on theexception event. To prevent an infinite reconnect loop when credentials are invalid, close the connection explicitly:

