How MetaPortAPI works
MetaPortAPI is a lightweight Expert Advisor. Once it is attached to any chart, it listens on local TCP ports and translates simple JSON requests into MetaTrader 5 actions.
Scripts, bots, dashboards
Python, C#, Node.js, Go, R, PowerShell, C++ — or curl and Postman. Several clients can connect at once.
Inside MetaTrader 5
Your MT5 account
Orders and data go through the terminal's normal, approved connection.
REST + WebSocket
The main port. Send standard HTTP requests such as GET /v1/quote?symbol=EURUSD and receive JSON. Open a WebSocket on the same port to receive live streams.
Legacy commands
For raw TCP clients: send one JSON command per line, like {"MSG":"QUOTE","SYMBOL":"EURUSD"}, and read one JSON line back.
Legacy data stream
Connect any number of TCP clients here to receive streamed ticks, bars, market depth and trade events — one JSON object per line.
What you can do
Get data
Current prices, symbol details and sessions, account balance and margin, terminal status, candle and tick history, economic calendar, and indicator values.
Trade
Send market or pending orders, set or change stop loss and take profit, close fully or partially, and delete pending orders.
Stream
Subscribe to ticks, OHLC bars on any timeframe, depth of market, and trade events such as fills or stop-loss hits.
Review
Pull your trading history as closed positions, individual deals or orders, filtered by date — ready for reports or CSV export.
Local or remote
By default only programs on the same computer can connect. Enable remote access to drive a terminal on a VPS from your Linux server or laptop.
Many terminals, one machine
Running several MT5 installations? Give each EA its own ports — for example 81, 82, 83 — and address each account separately.
Why not a cloud API?
Cloud services add an extra hop and see your data. Tools that imitate the MT5 protocol break when MetaQuotes updates it. MetaPortAPI uses the terminal itself, so it keeps working.