pipsocketDOCS
API reference / Account data

Deal and order history

Deals and past orders in a time range.

List deals

GET/v1/accounts/{account}/history/deals

The account's deals in a time range (MT5's HistorySelect), read fresh from its terminal.

Path

accountstringrequired

The account's id, acc_ and 26 characters, as the dashboard shows it.

Query

fromintegerrequired

The range's start: broker server time, seconds since 1970, included.

tointegerrequired

The range's end: broker server time, seconds since 1970, included. Not before from.

Response

A list of these
ticketinteger
MT5 · DEAL_TICKET
orderinteger
MT5 · DEAL_ORDER

The order that made the deal.

positioninteger
MT5 · DEAL_POSITION_ID

The position's id (identifier).

symbolstring
MT5 · DEAL_SYMBOL
typeenumor null

MT5's DEAL_TYPE: buy, sell, or a balance operation.

buysellbalancecreditchargecorrectionbonuscommissioncommission_dailycommission_monthlycommission_agent_dailycommission_agent_monthlyinterestbuy_canceledsell_canceleddividenddividend_frankedtax
entryenum

MT5's DEAL_ENTRY: in opens or adds, out closes, inout reverses, out_by closes by an opposite position.

inoutinoutout_by
reasonenum

MT5's DEAL_REASON: who or what made the deal (expert for the API, sl, tp, so for a stop out).

clientmobilewebexpertsltpsoother
volumenumber
MT5 · DEAL_VOLUME
pricenumber
MT5 · DEAL_PRICE
profitnumber
MT5 · DEAL_PROFIT
commissionnumber
MT5 · DEAL_COMMISSION
swapnumber
MT5 · DEAL_SWAP
feenumber
MT5 · DEAL_FEE
magicinteger
MT5 · DEAL_MAGIC
commentstring
MT5 · DEAL_COMMENT
time_mscinteger
MT5 · DEAL_TIME_MSC

Broker server time, milliseconds since 1970.

Errors

401invalid_api_key

The key is not a workspace's current key (a rolled key stops working within about a minute).

401missing_api_key

No API key: send it as Authorization: Bearer <key>.

404no_such_account

No such account, or one the key's workspace doesn't have: the two look the same.

422invalid_request

A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.

422range_too_large

The history range holds more than one answer can carry: ask for a shorter range.

503account_not_connected

The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.

503bad_command

The terminal refused the command, for example a negative expiration, or a history range MT5 can't select.

503engine_busy

The account's engine host has too many calls in flight (256). Nothing was done; try again.

503engine_unavailable

The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.

503terminal_error

The terminal did not give the answer asked for.

504engine_timeout

The account's engine did not answer within 30 seconds.

504terminal_timeout

The account's terminal did not answer within 5 seconds.

List past orders

GET/v1/accounts/{account}/history/orders

The account's orders no longer pending in a time range (MT5's HistorySelect), with their final state, read fresh from its terminal.

Path

accountstringrequired

The account's id, acc_ and 26 characters, as the dashboard shows it.

Query

fromintegerrequired

The range's start: broker server time, seconds since 1970, included.

tointegerrequired

The range's end: broker server time, seconds since 1970, included. Not before from.

Response

A list of these
ticketinteger
MT5 · ORDER_TICKET
symbolstring
MT5 · ORDER_SYMBOL
typeenumor null
MT5 · ORDER_TYPE

MT5's ENUM_ORDER_TYPE: buy and sell are market orders (ORDER_TYPE_BUY, ORDER_TYPE_SELL); buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit and sell_stop_limit are pending orders (ORDER_TYPE_BUY_LIMIT and so on); close_by is ORDER_TYPE_CLOSE_BY.

buysellbuy_limitsell_limitbuy_stopsell_stopbuy_stop_limitsell_stop_limitclose_by
stateenumor null

MT5's ORDER_STATE.

startedplacedcanceledpartialfilledrejectedexpiredrequest_addrequest_modifyrequest_cancel
volume_initialnumber
MT5 · ORDER_VOLUME_INITIAL
volume_currentnumber
MT5 · ORDER_VOLUME_CURRENT
price_opennumber
MT5 · ORDER_PRICE_OPEN
magicinteger
MT5 · ORDER_MAGIC
commentstring
MT5 · ORDER_COMMENT
positioninteger
MT5 · ORDER_POSITION_ID
time_setup_mscinteger
MT5 · ORDER_TIME_SETUP_MSC

Broker server time, milliseconds since 1970.

time_done_mscinteger
MT5 · ORDER_TIME_DONE_MSC

Broker server time, milliseconds since 1970.

Errors

401invalid_api_key

The key is not a workspace's current key (a rolled key stops working within about a minute).

401missing_api_key

No API key: send it as Authorization: Bearer <key>.

404no_such_account

No such account, or one the key's workspace doesn't have: the two look the same.

422invalid_request

A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.

422range_too_large

The history range holds more than one answer can carry: ask for a shorter range.

503account_not_connected

The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.

503bad_command

The terminal refused the command, for example a negative expiration, or a history range MT5 can't select.

503engine_busy

The account's engine host has too many calls in flight (256). Nothing was done; try again.

503engine_unavailable

The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.

503terminal_error

The terminal did not give the answer asked for.

504engine_timeout

The account's engine did not answer within 30 seconds.

504terminal_timeout

The account's terminal did not answer within 5 seconds.