MT5 REST API quickstart
Choose a language and run the complete example: create a fresh demo account, connect, read account data, open a 0.01 EURUSD demo position, inspect it, close it, verify the close, and disconnect. Only demo funds are traded. Your own API key uses service credit.
The complete demo lifecycle
/DemoAccount/OpenCreate a MetaQuotes demo account. Keep the returned login details private. This step does not fund a real trading account.
/ConnectExConnect the demo account and keep its terminal ID. The API key identifies your MRPC account; the terminal ID identifies this connection.
/AccountSummaryRead the connected account. A successful response confirms the integration can retrieve data; this request does not place a trade.
/OrderSendBuy 0.01 lot of EURUSD. Check the broker return code: HTTP 200 alone does not confirm execution.
/OpenedOrderspositionInfos contains open positions; openedOrders contains pending orders. Use the position ticket from this response for closing.
/OrderClose → /OpenedOrdersClose the position by its ticket and volume, then read OpenedOrders again to confirm it is gone.
/DisconnectDisconnect even if a previous request fails. The downloadable examples use cleanup logic and request a five-minute terminal expiry as a fallback.
Authenticate and read an account
Send your API key in the APIKey header. ConnectEx returns terminalInstanceGuid: use that value in the id header for AccountSummary and Disconnect. These are different identifiers. The request below reads an already connected account.
curl --request GET "https://mt5.mrpc.pro/AccountSummary" \
--header "APIKey: YOUR_API_KEY" \
--header "id: YOUR_TERMINAL_ID"
Disconnect after the request
Call Disconnect in a finally block, including when a read fails. The demo requests a five-minute terminal expiry as a cleanup fallback. Download the complete example above for your programming language.
Troubleshoot a failed connection
Check the API key, broker server name, login and password. If ConnectEx fails without returning a terminal ID, do not continue to AccountSummary. Check your service balance and trial limits; do not expose credentials in logs.
Run a live demo →