Skip to content

Remove history#

About#

Clears the order and transaction history of a specified application so that it can be synchronized from scratch

For more information see Async api documentation

Request#

In order to remove history, your application needs to emit request event with the following payload.

Name Type Required Description
type string Yes request type, must be removeHistory if you want to remove history
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 Yes MetaApi application id. Default is MetaApi

Response#

After history removed 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

After connecting to the terminal, another response will follow in synchronization event:

Name Type Required Description
type string Yes The value of this field will be authenticated
accountId string Yes account id specified in the request

Code example#

import ioClient from 'socket.io-client';

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

const request = {
    accountId: '865d3a4d-3803-486d-bdf3-a85679d9fad2',
    type: 'removeHistory',
    requestId: '57bfbc9f-108d-4131-a300-5f7d9e69c11b'
};

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

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

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

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

Response example#

First response:

{
  "type": "response",
  "requestId": "57bfbc9f-108d-4131-a300-5f7d9e69c11b",
  "accountId": "865d3a4d-3803-486d-bdf3-a85679d9fad2"
}

Second response (for more see Authenticated):

{
  "type": "authenticated",
  "accountId": "865d3a4d-3803-486d-bdf3-a85679d9fad2"
}