Skip to content

Read account information#

About#

Returns account information for a specified MetaTrader account

For more information see Async api documentation

Request#

In order to retrieve account information, your application needs to emit request event with the following payload.

Name Type Required Description
type string Yes request type, must be getAccountInformation if you want to retrieve account information
accountId string Yes MetaTrader account id. You can retrieve account id from Web application after you add your MetaTrader account to our platform. The account id can also be obtained via Provisioning API
requestId string Yes request id which your application must supply. Request id must be unique during an API connection
application string MetaApi application id. Default is RPC

Response#

After executing your request the API server will emit response event with the following payload.

Name Type Required Description
type string Yes The value of this field will be response in the response to the above request
requestId string Yes request id the response relates to
accountId string Yes account id specified in the request
accountInformation object Yes MetaTrader account information. Account information schema: MetatraderAccountInfo

Code example#

import ioClient from 'socket.io-client';

const socket = ioClient('https://mt-client-api-v1.agiliumtrade.agiliumtrade.ai', {
    path: '/ws',
    reconnection: false,
    query: {
        'auth-token': 'token'
    }
});

const request = {
    accountId: '23ccdd23-0b8a-400d-9aba-0129de365ba9',
    type: 'getAccountInformation',
    requestId: '6a707e89-f592-466b-885e-258a256495c1'
};

socket.on('connect', () => {
    socket.emit('request', request);
});

socket.on('response', response => {
  console.log(response);
});

socket.on('processingError', err => {
  console.error(err);
});

Response example#

{
  "type": "response",
  "requestId": "6a707e89-f592-466b-885e-258a256495c1",
  "accountInformation": {
    "broker": "True ECN Trading Ltd",
    "currency": "USD",
    "server": "ICMarketsSC-Demo",
    "balance": 7320.22,
    "equity": 7210.460000000002,
    "margin": 88.27,
    "freeMargin": 7133.74,
    "leverage": 100,
    "marginLevel": 8181.7265209,
    "tradeAllowed": true,
    "marginMode": "ACCOUNT_MARGIN_MODE_RETAIL_HEDGING",
    "name": "Will Turner",
    "login": 367906877,
    "credit": 0,
    "accountCurrencyExchangeRate": 1
  },
  "accountId": "23ccdd23-0b8a-400d-9aba-0129de365ba9"
}