MetaTrader 5 WebSocket API

Stream live MetaTrader 5 data over a single WebSocket per account: ticks, OHLC bar closes, account updates, open positions, trade events, and terminal status. Subscribe and unsubscribe with simple JSON control frames — no polling.

WSwss://api.fxsocket.com/mt5/{account_id}/ws?api_key=fxs_live_...

One streaming socket per account. Authentication is via the api_key query parameter — the only method available on WebSocket connections. Send JSON control frames to subscribe and unsubscribe; on subscribe the server first sends one current snapshot (account / positions / prices) before streaming deltas. Non-browser clients: the upgrade requires HTTP/1.1. Six topics are available:

  • prices Per-symbol ticks (requires symbol).
  • bars OHLC bar closes per symbol + timeframe (requires symbol and timeframe).
  • account Account snapshot, then changes.
  • positions Open positions snapshot, then changes.
  • trades Trade events as they happen.
  • terminal Terminal status, roughly once per second.
Client → server frames
{"action": "subscribe", "topic": "prices", "symbol": "EURUSD"}
{"action": "subscribe", "topic": "bars", "symbol": "EURUSD", "timeframe": "M5"}
{"action": "subscribe", "topic": "account"}
{"action": "unsubscribe", "topic": "prices", "symbol": "EURUSD"}
WSserver → client messages

Every server message is a JSON object with a type. Data messages mirror the REST shapes; control replies confirm your frames. Slow consumers get dropped messages plus a warning message rather than a stalled socket.

Server → client messages
{"type": "tick", "symbol": "EURUSD", "data": {"bid": 1.15325, "ask": 1.15333, "last": 0.0, "volume": 0, "time": "2026-06-11T08:55:56.728Z"}}
{"type": "bar", "symbol": "EURUSD", "timeframe": "M5", "data": {"open": 1.15301, "high": 1.15348, "low": 1.15289, "close": 1.15330}}
{"type": "account", "data": { ... }}
{"type": "positions", "data": [ ... ]}
{"type": "trade", "data": { ... }}
{"type": "terminal", "data": {"connected": true, "tradeAllowed": true, "serverTime": "2026-06-11T08:55:57.000Z"}}
{"type": "subscribed" | "unsubscribed" | "error" | "warning", ...}
GET/ws-tester

A built-in browser tester is served per account at https://api.fxsocket.com/mt5/{account_id}/ws-tester?api_key=fxs_live_... — handy for poking at the stream before writing code. The page is API-key gated, and since browsers can't attach headers the key must ride in the URL (it will appear in your browser history). Open yours from the Request Builder on the overview page.