Skip to content

Read historical trades by time range#


Returns historical trades with specific time range for MetaApi account.

GET /users/current/accounts/:accountId/historical-trades/:startTime/:endTime

For more information see swagger documentation. Note, that this URL is valid for new-york region only. You can find URLs for other regions on API access page.


Name Type Required Description
auth-token string Yes MetaApi account token. See Authentication & authorization

Path parameters#

Name Type Required Description
accountId string Yes MetaApi account id
startTime string Yes start of time range, inclusive, in broker timezone, in YYYY-MM-DD HH:mm:ss.SSS format
endTime strinf Yes end of time range, exclusive, in broker timezone, in YYYY-MM-DD HH:mm:ss.SSS format

Query parameters#

Name Type Required Description
limit integer pagination limit, default: 1000, min: 1, max: 1000
offset integer pagination offset, default: 0, min: 0
updateHistory boolean update historical trades before returning results



  • 200 - Historical trades with requested time range for a specified MetaTrader account returned successfully. Response schema: {trades: Array}
  • 202 - metrics for the specified MetaTrader account in processing. Response schema: {status: string, message: string}. Response headers: {"retry-after": integer} - interval in seconds to retry
  • 401 - Authorization failed due to auth-token invalid. Response schema: Error
  • 403 - MetaStats API is not enabled on provided trading account. Response schema: Error
  • 404 - MetaTrader account not found or not provisioned yet. Response schema: Error


Example request:

curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' ''

Example synchronous response: ```json { "trades": [ { "_id": "865d3a4d-3803-486d-bdf3-a85679d9fad2+1", "accountId": "865d3a4d-3803-486d-bdf3-a85679d9fad2", "positionId": "1", "volume": 1, "durationInMinutes": 16, "profit": 3.01, "gain": 106, "success": "won", "openTime": "2020-09-08 22:21:36.000", "type": "DEAL_TYPE_BUY", "symbol": "EURUSD", "closeTime": "2020-09-08 24:37:36.000", "openPrice": 1.1835, "closePrice": 1.1935, "pips": 100 } ] }