The front door to every other endpoint.
The Connection API turns a MetaTrader login into an addressable account you can trade and stream. You send the login, main password and broker server to /ConnectEx (a GET request); a dedicated connection starts, logs in, and syncs — and you get back an account id (a UUID) plus an API key (apiKey, mt5api_…), shown only in this response. From then on, every other endpoint targets that account with ?id=. If the broker ever drops the session, it is restored automatically and /Reconnect rebuilds it on demand, and /ConnectState tells you exactly where a connection stands at any moment.
Connect, watch, reconnect, disconnect.
Connect
/ConnectEx with login, password and server. Add wait=60 to wait up to 60 seconds for ACTIVE (usually 1–2 minutes; then poll /ConnectState), or use /ConnectStream to watch it come up.
Watch
/ConnectState reports one account or all of them; /OnConnectState streams every status change over WebSocket.
Recover
/Reconnect rebuilds a dropped session; /Disconnect tears it down cleanly when you're finished.
curl "https://api.metatraderapi.net/ConnectEx?user=1072…&password=…&server=Ava-Demo%201-MT5&platform=MT5&wait=60" \ -H "Authorization: Bearer mt5mgmt_…" { "id": "7f123497-63b2-496d-864d-cf3657f73b1f", "status": "ACTIVE", "connected": true, "statusReason": null, "apiKey": "mt5api_…", "apiKeyId": "fd41e389-…", "platform": "MT5", "brokerServer": "Ava-Demo 1-MT5", "note": "…" } # apiKey is shown only here: store it. Use the id everywhere else curl "https://api.metatraderapi.net/AccountSummary?id=7f123497-63b2-496d-864d-cf3657f73b1f" -H "x-api-key: mt5api_…"
Frequently asked
How do I connect an MT4 or MT5 account via API?+
/ConnectEx. A connection starts and logs in, and you receive an account id (UUID) and an API key (mt5api_…). Add wait=60 to wait up to 60 seconds for ACTIVE; a new connection is usually ACTIVE within 1–2 minutes, so poll /ConnectState if it isn't yet.What do I do with the account id?+
?id=. The id is how the API knows which connected account to talk to.What happens if the broker drops the connection?+
/Reconnect to rebuild the session on demand, or watch /ConnectState / stream /OnConnectState to detect drops as they happen and react automatically.Do I pass a server name or a host and port?+
/GetBrokerServersByBrokerName looks up a broker's servers and access points by name.Does disconnecting stop my billing period?+
/Disconnect removes the live connection; its seat stays paid until the end of the billing month, and your next connection reuses it at no charge. An unused paid seat keeps renewing until you release it.One call, and your account is on the API.
Connect an MT4 or MT5 login and get an id you can trade and stream against, usually within 1–2 minutes.