MetaTrader®, MT4® and MT5® are trademarks of MetaQuotes Ltd. This is an independent service and is not affiliated with, authorized by, or endorsed by MetaQuotes.

MT5 API: one REST & WebSocket API for MetaTrader 5

Read balances, positions and history, stream live quotes and send orders on any MetaTrader 5 account, from any language, over plain HTTPS. We run the MT5 connection; your code only makes requests.

REST + WebSocketNo EA requiredPay per seatgRPC ready
# account summary of a connected MT5 account
curl -s -H "x-api-key: $MTAPI_KEY" \
  "https://api.metatraderapi.net/AccountSummary?id=$MTAPI_ID"

# a market order that is safe to retry
curl -s -H "x-api-key: $MTAPI_KEY" \
  "https://api.metatraderapi.net/OrderSend?id=$MTAPI_ID&symbol=EURUSD&operation=Buy&volume=0.01&clientOrderId=order-0001"
# "state": 10009 means filled; any other value is the broker's reason
import os, requests

API = "https://api.metatraderapi.net"
s = requests.Session()
s.headers["x-api-key"] = os.environ["MTAPI_KEY"]
ACCOUNT = os.environ["MTAPI_ID"]          # the account's UUID

summary = s.get(f"{API}/AccountSummary", params={"id": ACCOUNT}, timeout=75).json()
print(summary["balance"], summary["equity"], summary["currency"])

order = s.get(f"{API}/OrderSend", params={"id": ACCOUNT, "symbol": "EURUSD",
              "operation": "Buy", "volume": 0.01, "clientOrderId": "order-0001"}, timeout=75).json()
print("filled" if order.get("state") == 10009 else f"refused: {order.get('state')}")
const API = "https://api.metatraderapi.net";
const headers = { "x-api-key": process.env.MTAPI_KEY };
const id = process.env.MTAPI_ID;

const res = await fetch(`${API}/GetQuote?id=${id}&symbol=EURUSD`, { headers });
const quote = await res.json();
console.log(quote.bid, quote.ask);

// live quotes, positions and trades over one WebSocket
const ws = new WebSocket(`wss://api.metatraderapi.net/v1/stream?id=${id}`, { headers });
ws.onopen = () => ws.send(JSON.stringify({ action: "subscribe", symbol: "EURUSD" }));
● 200 JSON over HTTPS EU-hosted

What is an MT5 API?

An MT5 API is an interface that lets your own software read and control a MetaTrader 5 trading account over the network. MetaQuotes does not offer a public API for MT5 trading accounts: its Manager and Server APIs are licensed to brokers, and its Python package only drives a MetaTrader 5 desktop app on the same Windows machine. MetaTrader API is a hosted MT5 API: you connect an account with its broker server, login and password, and get REST (JSON over HTTPS), WebSocket and gRPC access to it, without installing MetaTrader or an Expert Advisor.

100+API endpoints
1–2 minto connect an account
8,000+broker servers
$14per account / month
// how it works

From account to first API call in minutes

  1. STEP 1Connect your MT5 accountIn the dashboard (or with POST /v1/seats from your backend): broker server name, login and the account's main password. A demo account works the same way.
  2. STEP 2Copy the account id and API keyEach account gets a UUID (sent as ?id=) and an API key starting with mt5api_ (sent as the x-api-key header).
  3. STEP 3Call the APIREST for requests, one WebSocket for live quotes, positions, orders and trades, gRPC if you want typed clients.
// endpoints

What the MT5 API gives you

A selection of the 100+ endpoints. All of them, with parameters and responses: documentation and OpenAPI.

AreaEndpointWhat it does
Account/AccountSummarybalance, equity, margin, free margin, leverage, currency
Account/AccountDetailsaccount and server details
Market data/SymbolListthe broker's exact symbol names (with suffixes)
Market data/GetQuotebid / ask for one symbol; /GetQuoteMany for several
Market data/PriceHistorycandles (OHLC) for a symbol and timeframe
Market data/MarketBookGetMT5 depth of market (Level 2), where the broker publishes it
Orders/OrderSendmarket and pending orders with SL / TP and clientOrderId
Orders/OrderModifymove stop loss, take profit or a pending price
Orders/OrderCloseclose a position, fully or partially
Positions/OpenedOrdersopen positions and pending orders
History/OrderHistoryclosed trades; /OrderHistoryPagination for large accounts
History/BalanceHistorydeposits, withdrawals and balance operations (MT5)
Connection/ConnectExconnect an account and wait until it is ACTIVE
Experts/EaUploadupload and run your own compiled Expert Advisor (.ex5)
// options

Ways to reach MetaTrader 5, compared

THE USUAL WAYS

  • Official MetaTrader5 Python package: Windows only; drives a MetaTrader 5 desktop app that must run on the same machine; one account per running app.
  • Expert Advisor + WebRequest / sockets: MQL5 code inside a running MetaTrader 5 app on a VPS you maintain; you build the bridge and keep it alive.
  • MetaQuotes Manager / Server API: licensed to brokers for their own server; not available for a trading account at another broker.

METATRADER API

  • MetaTrader API: any language, any OS, no desktop app, MT4 and MT5 through the same endpoints, many accounts per key.
  • Works with your own account at any broker: no broker permission, Manager licence or server access needed.
  • Each account runs on its own isolated connection; broker passwords are stored AES-256-GCM encrypted.
  • Uptime measured live on the public status page.

Where do I get an MT5 API key?

MetaQuotes does not issue API keys for trading accounts, and there is no API key inside the MetaTrader 5 app. The key comes from the service that runs the connection. With MetaTrader API you connect the account in the dashboard and click “Generate key”: the key (mt5api_…) is shown once, so store it as a secret. One key works for every account of your login (choose it with ?id=); for an app that hands keys to end users, create keys limited to one account, and read-only keys if they must not trade.

Limits, in numbers

Rate limitbursts of 40 requests, refilled at 20 per second, per API key
WebSocket25 concurrent streams per account, quotes at most every 200 ms per symbol, heartbeat every 10 s
Timeoutsa REST call waits up to 30 s for the account (MT4: 15 s); set your client timeout to 75 s
Accountsup to 50 seats per customer, more on request
Retriesevery order can carry a clientOrderId: a resend with the same id never opens a second order
// pricing

One price per connected account

REST, WebSocket, gRPC, MT4 and MT5 included. Billed monthly; add or release seats anytime.

Seats 1–4

$14 /seat per month
Start with one account
Create account
VOLUME

Seats 5–19

$13 /seat per month
From your 5th seat, automatically
Create account

Seats 20+

$12 /seat per month
Platforms and fleets
Create account
// questions

MT5 API: frequently asked questions

Do I need MetaTrader 5 or a VPS running on my side?+
No. Each connected account runs on its own isolated connection on our side. Your code only makes HTTPS and WebSocket requests, from any operating system.
Which brokers work with this MT5 API?+
Any broker that offers MetaTrader 5 accounts: you connect with the broker's server name exactly as MetaTrader shows it. More than 8,000 broker servers are listed in our broker directory.
How fast is an order?+
The API adds little time of its own; the broker's execution and the network distance to the broker's server decide most of it. Every order returns the broker's result code (state 10009 = done).
Can I stream prices and account changes instead of polling?+
Yes. One WebSocket per account delivers quotes (up to every 200 ms per symbol), positions with live profit, pending orders, executed trades and heartbeats. Up to 25 concurrent streams per account.
Can I run my own Expert Advisor through the API?+
Yes. Upload a compiled .ex5 with /EaUpload and attach it to a chart on the connected account; the file can be up to about 750 KB.
What does it cost?+
$14 per seat (one connected MT4 or MT5 account) per month for seats 1–4, $13 for seats 5–19 and $12 from the 20th seat. REST, WebSocket, gRPC, MT4 and MT5 are all included. Billed monthly by card through Stripe. There is no free trial and no sandbox: test with a broker demo account on a paid seat.
Is this an official MetaQuotes API or a broker?+
Neither. MetaTrader API is an independent software service, not affiliated with MetaQuotes. MetaQuotes licenses its Manager and Server APIs to brokers only. We are not a broker either: orders execute at your own broker under that broker's rules, and we give no trading advice.