Full order control over a clean REST surface.
The Trading API lets your application open, modify and close MT4/MT5 orders through simple REST calls — the same actions a trader takes in MetaTrader, driven by code. /OrderSend opens a market or pending order with optional stop-loss, take-profit and magic number; /OrderModify changes an order's levels; /OrderClose closes a position in full or part. Every call returns the broker's result — ticket, open price, lots and state (10009 = done; a broker refusal is HTTP 200 with another state) — so your system always knows exactly what happened.
Manage orders
Open, adjust and close — market or pending, with stops, take-profits and partial closes.
/OrderSend/OrderModify/OrderClose/OrderDelete/OrderCloseByKnow your positions
Read open positions, pending orders and closed history to reconcile state at any time.
/OpenedOrders/PositionsTotal/OrderHistory/TradeUnrealizedPLNever send an order blind.
Three read-only calculators answer the questions that decide whether an order is a good idea — before it hits the market.
Margin
/OrderCalcMargin — the margin a hypothetical order would tie up, so you can size against free margin.
Profit
/OrderCalcProfit — the profit a move from open to close price would yield, in account currency.
Check
/OrderCheck — whether the order would be accepted at all, given margin and rules.
# open a 0.01-lot market BUY on EURUSD (all classic routes are GET) curl "https://api.metatraderapi.net/OrderSend?id=<account id>&symbol=EURUSD&operation=Buy&volume=0.01&clientOrderId=my-order-0001" \ -H "x-api-key: mt5api_…" # → { "ticket":69054439, "symbol":"EURUSD", "orderType":0, "lots":0.01, "volume":100, # "openPrice":1.16401, "state":10009, "openTimestampUTC":1791796502 } # state 10009 = done; any other state = the broker's refusal reason (still HTTP 200) # later — close it by ticket curl "https://api.metatraderapi.net/OrderClose?id=<account id>&ticket=69054439" \ -H "x-api-key: mt5api_…" # → an order object again: { "ticket":69054439, ..., "state":10009 }
Frequently asked
Can I place trades on MT4 and MT5 through a REST API?+
/OrderSend opens market or pending orders on both MT4 and MT5 accounts, with optional stop-loss, take-profit and magic number. /OrderModify and /OrderClose manage them afterwards.Can I calculate margin and profit before trading?+
/OrderCalcMargin returns the margin an order needs, /OrderCalcProfit the profit a price move would yield, and /OrderCheck whether the order would be accepted — all without placing anything.Do I get the broker's real fill back?+
Can I close part of a position?+
lots value to /OrderClose for a partial close; omit it to close the whole position. /OrderCloseBy closes one position against an opposite one.Is it safe to run automated trading on my account?+
Wire your strategy straight into the market.
Connect an account, check your margin, and send your first order with a single REST call.