MetaTrader API
Metatrader 4 api

Order History

Trading history

Order history

GET
/OrderHistory
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
fromstring

'From date' in format: yyyy-MM-ddTHH:mm:ss

Default"2022-01-01T00:00:00"
to?string

'To date' in format: yyyy-MM-ddTHH:mm:ss

Default"2030-06-01T00:00:00"

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderHistory?id=%7B%7Bid%7D%7D&from=2022-01-01T00%3A00%3A00&to=2030-06-01T00%3A00%3A00"
[
  {
    "ticket": 0,
    "openTime": "2019-08-24T14:15:22Z",
    "closeTime": "2019-08-24T14:15:22Z",
    "expiration": "2019-08-24T14:15:22Z",
    "type": "Buy",
    "lots": 0.1,
    "symbol": "string",
    "openPrice": 0.1,
    "stopLoss": 0.1,
    "takeProfit": 0.1,
    "closePrice": 0.1,
    "magicNumber": 0,
    "swap": 0.1,
    "commission": 0.1,
    "comment": "string",
    "profit": 0.1,
    "rateOpen": 0.1,
    "rateClose": 0.1,
    "rateMargin": 0.1,
    "ex": {
      "order": 0,
      "login": 0,
      "symbol": "string",
      "digits": 0,
      "cmd": 0,
      "volume": 0,
      "open_time": 0,
      "state": 0,
      "open_price": 0.1,
      "sl": 0.1,
      "tp": 0.1,
      "close_time": 0,
      "value_date": 0,
      "expiration": 0,
      "place_type": 0,
      "conv_rates": [
        0.1
      ],
      "commission": 0.1,
      "commission_agent": 0.1,
      "storage": 0.1,
      "close_price": 0.1,
      "profit": 0.1,
      "taxes": 0.1,
      "magic": 0,
      "comment": "string",
      "internal_id": 0,
      "activation": 0,
      "spread": 0,
      "margin_rate": 0.1,
      "timestamp": 0,
      "reserved": [
        0
      ],
      "next": 0
    },
    "placedType": "Client",
    "state": "OPEN_NORMAL",
    "digits": 0
  }
]
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "stackTrace": "string"
}

Order history by pages

GET
/OrderHistoryPagination
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
fromstring

'From date' in format: yyyy-MM-ddTHH:mm:ss

Default"2022-01-01T00:00:00"
to?string

'To date' in format: yyyy-MM-ddTHH:mm:ss

Default"2030-06-01T00:00:00"
ordersPerPageinteger

Orders per page

Default10
Formatint32
pageNumberinteger

Page number

Default0
Formatint32
requestAgain?boolean

If need to force refresh orders from mt5 server

Defaultfalse
sort?string

Sort by open time or close time

Default"OpenTime"
Value in"OpenTime" | "CloseTime"
ascending?boolean

Ascending sort

Defaulttrue
tickets?array<integer>

List of tickets that need to return. If not specified - returns all tickets.

ignoreDepositWithdraw?boolean

Do not return deposit and withdraw operations

Defaultfalse

Response Body

curl -X GET "https://api.metatraderapi.dev/OrderHistoryPagination?id=%7B%7Bid%7D%7D&from=2022-01-01T00%3A00%3A00&to=2030-06-01T00%3A00%3A00&ordersPerPage=10&pageNumber=0&requestAgain=false&sort=OpenTime&ascending=true&tickets=0&ignoreDepositWithdraw=false"
[
  {
    "ticket": 0,
    "openTime": "2019-08-24T14:15:22Z",
    "closeTime": "2019-08-24T14:15:22Z",
    "expiration": "2019-08-24T14:15:22Z",
    "type": "Buy",
    "lots": 0.1,
    "symbol": "string",
    "openPrice": 0.1,
    "stopLoss": 0.1,
    "takeProfit": 0.1,
    "closePrice": 0.1,
    "magicNumber": 0,
    "swap": 0.1,
    "commission": 0.1,
    "comment": "string",
    "profit": 0.1,
    "rateOpen": 0.1,
    "rateClose": 0.1,
    "rateMargin": 0.1,
    "ex": {
      "order": 0,
      "login": 0,
      "symbol": "string",
      "digits": 0,
      "cmd": 0,
      "volume": 0,
      "open_time": 0,
      "state": 0,
      "open_price": 0.1,
      "sl": 0.1,
      "tp": 0.1,
      "close_time": 0,
      "value_date": 0,
      "expiration": 0,
      "place_type": 0,
      "conv_rates": [
        0.1
      ],
      "commission": 0.1,
      "commission_agent": 0.1,
      "storage": 0.1,
      "close_price": 0.1,
      "profit": 0.1,
      "taxes": 0.1,
      "magic": 0,
      "comment": "string",
      "internal_id": 0,
      "activation": 0,
      "spread": 0,
      "margin_rate": 0.1,
      "timestamp": 0,
      "reserved": [
        0
      ],
      "next": 0
    },
    "placedType": "Client",
    "state": "OPEN_NORMAL",
    "digits": 0
  }
]
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "stackTrace": "string"
}

Get history positons by ticket numbers

GET
/HistoryPositions
x-api-key<token>

Your API key

In: header

Query Parameters

idstring

Your Account UUID which you connected via the Dashboard

Default"{{id}}"
tickets?array<integer>

Ticket list of positions that you need

Response Body

curl -X GET "https://api.metatraderapi.dev/HistoryPositions?id=%7B%7Bid%7D%7D&tickets=0"
[
  {
    "ticket": 0,
    "openTime": "2019-08-24T14:15:22Z",
    "closeTime": "2019-08-24T14:15:22Z",
    "expiration": "2019-08-24T14:15:22Z",
    "type": "Buy",
    "lots": 0.1,
    "symbol": "string",
    "openPrice": 0.1,
    "stopLoss": 0.1,
    "takeProfit": 0.1,
    "closePrice": 0.1,
    "magicNumber": 0,
    "swap": 0.1,
    "commission": 0.1,
    "comment": "string",
    "profit": 0.1,
    "rateOpen": 0.1,
    "rateClose": 0.1,
    "rateMargin": 0.1,
    "ex": {
      "order": 0,
      "login": 0,
      "symbol": "string",
      "digits": 0,
      "cmd": 0,
      "volume": 0,
      "open_time": 0,
      "state": 0,
      "open_price": 0.1,
      "sl": 0.1,
      "tp": 0.1,
      "close_time": 0,
      "value_date": 0,
      "expiration": 0,
      "place_type": 0,
      "conv_rates": [
        0.1
      ],
      "commission": 0.1,
      "commission_agent": 0.1,
      "storage": 0.1,
      "close_price": 0.1,
      "profit": 0.1,
      "taxes": 0.1,
      "magic": 0,
      "comment": "string",
      "internal_id": 0,
      "activation": 0,
      "spread": 0,
      "margin_rate": 0.1,
      "timestamp": 0,
      "reserved": [
        0
      ],
      "next": 0
    },
    "placedType": "Client",
    "state": "OPEN_NORMAL",
    "digits": 0
  }
]
{
  "message": "string",
  "code": "INTERNAL_ERROR",
  "stackTrace": "string"
}