Balance
Get the current account balance and optionally subscribe to real-time balance updates.
4 breaking changes - code updates required
Critical Change:
New only returns the current account balance - multi-account support and loginid parameter removed.
Quick comparison
| Aspect | Legacy | New | Action required |
|---|---|---|---|
Endpoint ✅ Same | balance | balance | None |
Auth Required ✅ Same | Yes | Yes | None |
Multi-account ❌ Removed | Supported | Not supported | Update to single account calls |
Breaking changes
1. Account parameter removed
What Changed: The account parameter (for fetching "all" accounts, "current", or specific account ID) has been removed.
2. Multi-account response removed
What Changed: The accounts object in the response that contained detailed information about all active accounts has been removed.
3. Total balances removed
What Changed: The total object that provided summary totals by account type (deriv, deriv_demo, mt5, mt5_demo) has been removed.
4. Login ID parameter removed
What Changed: The loginid parameter has been removed. This parameter was mandatory when multiple tokens were provided during authorization.
Migration: Use separate WebSocket connections or separate authorize calls for each account you need to query.
Request structure
Legacy Request Example
1{
2 "balance": 1,
3 "account": "all", // ❌ Removed in New
4 "loginid": "CR123456", // ❌ Removed in New
5 "subscribe": 1
6}New Request Example
1{
2 "balance": 1,
3 "subscribe": 1
4}Response structure
Legacy Response Example
1{
2 "balance": {
3 "balance": 10000.50,
4 "currency": "USD",
5 "loginid": "CR123456",
6 "accounts": { // ❌ Not in New
7 "CR123456": {
8 "balance": 10000.50,
9 "converted_amount": 10000.50,
10 "currency": "USD",
11 "demo_account": 0,
12 "status": 1,
13 "type": "deriv"
14 },
15 "MTR987654": {
16 "balance": 5000.00,
17 "converted_amount": 5000.00,
18 "currency": "USD",
19 "demo_account": 0,
20 "status": 1,
21 "type": "mt5"
22 }
23 },
24 "total": { // ❌ Not in New
25 "deriv": {
26 "amount": 10000.50,
27 "currency": "USD"
28 },
29 "mt5": {
30 "amount": 5000.00,
31 "currency": "USD"
32 }
33 }
34 },
35 "msg_type": "balance"
36}New Response Example
1{
2 "balance": {
3 "balance": 10000.50,
4 "currency": "USD",
5 "loginid": "CR123456"
6 },
7 "msg_type": "balance"
8}Code examples
Legacy Implementation
1async function getCurrentBalance() {
2 const request = {
3 balance: 1,
4 subscribe: 1
5 };
6
7 ws.send(JSON.stringify(request));
8
9 ws.onmessage = (event) => {
10 const response = JSON.parse(event.data);
11 if (response.msg_type === 'balance') {
12 console.log('Balance:', response.balance.balance);
13 console.log('Currency:', response.balance.currency);
14 console.log('Login ID:', response.balance.loginid);
15
16 // Access multi-account data
17 if (response.balance.accounts) {
18 Object.keys(response.balance.accounts).forEach(id => {
19 const acc = response.balance.accounts[id];
20 console.log(`Account ${id}: ${acc.balance}`);
21 });
22 }
23 }
24 };
25}New Implementation
1async function getCurrentBalance() {
2 const request = {
3 balance: 1,
4 subscribe: 1
5 };
6
7 ws.send(JSON.stringify(request));
8
9 ws.onmessage = (event) => {
10 const response = JSON.parse(event.data);
11 if (response.msg_type === 'balance') {
12 console.log('Balance:', response.balance.balance);
13 console.log('Currency:', response.balance.currency);
14 console.log('Login ID:', response.balance.loginid);
15
16 // Multi-account data no longer available
17 // Make separate calls for each account
18 }
19 };
20}