Documentation
Account Endpoints

Balance

AccountAuth Required

Get the current account balance and optionally subscribe to real-time balance updates. The New API returns only the balance of the account your token selects.

Quick comparison

AspectLegacy APINew APIAction
EndpointbalancebalanceNone
Auth RequiredYesYesNone
account parameterOptionalRemovedRemove from requests
loginid parameterOptionalRemovedRemove from requests
accounts in responseReturned when account is allRemovedRequest each account separately
total in responseReturned when account is allRemovedSum balances yourself

Breaking changes

1. account parameter removed

In the Legacy API, account chose which balance to return: current, all or a specific login ID. The New API does not accept it and returns the balance of the account your token selects.

Required change: Remove account from your balance requests.

2. loginid parameter removed

In the Legacy API, loginid selected the account when you authorised several accounts. The New API does not accept it.

Required change: Remove loginid from your balance requests. Your token selects the account.

3. accounts removed from the response

The Legacy API returned an accounts object with the balance, currency, status and type of each account when you sent account set to all. The New API does not return it.

Required change: Request the balance of each account with that account's token.

4. total removed from the response

The Legacy API returned a total object with summed balances for Deriv and MT5 real and demo accounts. The New API does not return it.

Required change: Add up the balances of your accounts yourself if you need a total.

Request structure

Legacy APIrequest example
{
  "balance": 1,
  "account": "all",
  "loginid": "CR123456",
  "subscribe": 1,
  "req_id": 1
}
New APIrequest example
{
  "balance": 1,
  "subscribe": 1,
  "req_id": 1
}

Response structure

Legacy APIresponse example
{
  "balance": {
    "accounts": {
      "CR123456": {
        "balance": 10000.5,
        "converted_amount": 10000.5,
        "currency": "USD",
        "demo_account": 0,
        "status": 1,
        "type": "deriv"
      }
    },
    "balance": 10000.5,
    "currency": "USD",
    "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3",
    "loginid": "CR123456",
    "total": {
      "deriv": {
        "amount": 10000.5,
        "currency": "USD"
      }
    }
  },
  "echo_req": {
    "balance": 1,
    "account": "all",
    "loginid": "CR123456",
    "subscribe": 1,
    "req_id": 1
  },
  "msg_type": "balance",
  "req_id": 1,
  "subscription": {
    "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
  }
}
New APIresponse example
{
  "balance": {
    "balance": 10000.5,
    "currency": "USD",
    "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3",
    "loginid": "CR123456"
  },
  "echo_req": {
    "balance": 1,
    "subscribe": 1,
    "req_id": 1
  },
  "msg_type": "balance",
  "req_id": 1,
  "subscription": {
    "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
  }
}

Code examples

function getBalances(loginId) {
  ws.send(JSON.stringify({ balance: 1, account: "all", loginid: loginId, subscribe: 1 }));

  ws.onmessage = (event) => {
    const response = JSON.parse(event.data);
    if (response.msg_type !== "balance" || !response.balance) return;

    console.log("Balance:", response.balance.balance, response.balance.currency);
    const accounts = response.balance.accounts ?? {};
    Object.keys(accounts).forEach((id) => {
      console.log("Account " + id + ": " + accounts[id].balance);
    });
  };
}
Click to open live chat support. Get instant help from our support team.