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.

Guides · 9 min read · 2026-08-27

How to Get an MT5 API Key (and Why MetaTrader Never Gives You One)

By MetaTrader API Editorial Team

How to Get an MT5 API Key (and Why MetaTrader Never Gives You One)

MetaTrader 5 does not issue API keys. Where an MT5 API key actually comes from, how to get one in about ten minutes, and the first three calls to make.

Short answer: MetaTrader 5 does not issue API keys. MetaQuotes has never published a public REST API for retail trading accounts, so there is no key hidden in your MetaTrader app, your broker's client area, or your MQL5 profile. An MT5 API key comes from a provider that connects to your broker for you. With MetaTrader API it takes about ten minutes: sign up, connect your MT5 login, click Generate key on the account's card, and start calling https://api.metatraderapi.net.

If you searched for this, you probably spent twenty minutes clicking through the MT5 desktop app looking for a developer tab that does not exist. You are not missing anything. The tab is not there. Below is what is actually going on, and what to do about it.


Why there is no official MT5 API key

MetaTrader 5 is closed, proprietary software owned by MetaQuotes. It is not open source — there is no public repository, no community fork, and no officially documented REST endpoint you can point a bearer token at.

What MetaQuotes does ship is three things, none of which is what a developer building an app wants:

So the honest picture: there is no first-party MT5 REST API, and therefore no first-party MT5 API key.

That leaves one practical route for an application: a hosted API service that logs into the broker's server with the account's credentials and exposes the account to you as clean JSON over HTTPS. That service issues the key. That is the key you are looking for.


The three credentials you actually need

People conflate these constantly, then spend an afternoon debugging a 401. They are three separate things:

What What it identifies Where it comes from
API key You, the developer, for one connected account The account's card in your MetaTrader API dashboard (Generate key), or the response of /ConnectEx / POST /v1/seats
Account UUID One specific MT4/MT5 trading account Returned when you register the account
MT5 login / password / server The broker account itself Your broker

Each connected account gets its own UUID and its own API key. A key that is not account-scoped can also address your other accounts through id. The Settings tab holds a fourth thing, the management key, which only creates and removes seats and is never sent as x-api-key. Almost every endpoint takes both: the key in a header, the UUID as id.

One trap worth naming now: MetaTrader accounts have a main (trading) password and an investor password. The investor password is read-only. If you connect with it, quotes and balances work fine but every order is refused (check /IsInvestor). Use the main password for anything that trades.


How to get an MT5 API key in five steps

1. Create an account

Sign up at app.metatraderapi.net. Nothing to install on your side: no MetaTrader installation, no VPS, no EA for you to run.

2. Know where the key comes from

Your API key is created per account: once the account is connected (next step), click Generate key on its card in the dashboard. The key is shown only once, so store it right away. Connecting over the API with /ConnectEx or POST /v1/seats returns a new key in the response instead. The Settings tab holds your management key for provisioning, not the API key. Treat the API key like a password: server-side only, never in a mobile app bundle, never in front-end JavaScript, never committed to Git. Unless it is account-scoped, it can address every account under your plan.

3. Register your MT5 account

Two ways, same result. In the dashboard, open Accounts and enter your MT5 login (a number), the main (trading) password, and the exact broker server name. Or do it over the API with POST /v1/seats (JSON body, management key) if you are onboarding users programmatically — that is how CRMs and prop-firm dashboards do it at volume. Code written to the classic MetaTrader REST conventions can use /ConnectEx?user=&password=&server=&platform=MT5 instead.

Either way you get back a UUID (the account id) for that account, and over the API also a new API key for it. Store it against the user in your own database.

Not sure of the exact server name? /GetBrokerServersByBrokerName?brokerName= lists a broker's server names, and an unknown server name is refused at once with up to 8 suggestions. "Exact" matters — MetaTrader server names are not fuzzy-matched.

4. Verify the connection

curl -X GET "https://api.metatraderapi.net/CheckConnect?id=YOUR_ACCOUNT_UUID" \
  -H "x-api-key: YOUR_API_KEY"

true means the account is logged into your broker's server right now. Dropped connections are restored automatically; for the status and the reason behind an error, call /ConnectState?id=. Together they make the right health check.

5. Pull real account data

curl -X GET "https://api.metatraderapi.net/AccountSummary?id=YOUR_ACCOUNT_UUID" \
  -H "x-api-key: YOUR_API_KEY"

That returns balance, equity, currency, free margin, margin, margin level, profit, leverage and credit. If you see live numbers here, you are done — you have working MT5 API access, and you never opened MetaTrader.


Your first three calls, in Python

import requests

BASE = "https://api.metatraderapi.net"
H = {"x-api-key": "YOUR_API_KEY"}
ACC = "YOUR_ACCOUNT_UUID"

# 1. Is the account live?
print(requests.get(f"{BASE}/CheckConnect", params={"id": ACC}, headers=H).text)

# 2. Balance, equity, margin
print(requests.get(f"{BASE}/AccountSummary", params={"id": ACC}, headers=H).json())

# 3. A market order (clientOrderId makes a retry safe: never a second order)
order = requests.get(f"{BASE}/OrderSend", params={
    "id": ACC, "symbol": "EURUSD", "operation": "Buy",
    "volume": 0.01, "slippage": 5,
    "stoploss": 0, "takeprofit": 0, "comment": "first-api-trade",
    "clientOrderId": "first-api-trade-0001",
}, headers=H).json()
if order.get("state") == 10009:   # HTTP 200 is not a fill; 10009 is
    print("filled, ticket", order["ticket"])
else:
    print("broker refused the order, retcode", order.get("state"))

Three calls. No MQL, no ZeroMQ socket glued to a desktop app, no Windows VPS to babysit. (If you are coming from the desktop-app-plus-bridge world, we wrote up connecting MT4 to Python without ZeroMQ separately.)

From there the surface is wide: /OpenedOrders, /ClosedOrders, /OrderModifySafe, /OrderCloseSafe, /OrderHistory with pagination, /PriceHistory, /SymbolParams, /RequiredMargin, /TradeStats, /EquityHistory. The current specification exposes more than 100 REST endpoints across MT4 and MT5.


"What about SSE?"

Short version: MetaTrader API streams over WebSocket, not Server-Sent Events. You open one socket per account, wss://api.metatraderapi.net/v1/stream?id=<account id> with the x-api-key header, and send {"action":"subscribe","symbol":"EURUSD"} for each symbol. QUOTE frames deliver ticks, CANDLE frames live bars (add "timeframe":"M1"), and POSITIONS, ORDERS and TRADE frames deliver open positions with floating P/L, pending orders and every fill, without any subscription. Market depth is on REST (/MarketBookAdd, /MarketBookGet).

That is a deliberate choice, not an omission. SSE is one-directional: the server talks, the client listens, and every subscribe or unsubscribe needs a separate HTTP round trip. Trading clients subscribe and unsubscribe constantly — a copy-trading platform re-scopes its symbol set every time a follower joins. A bidirectional socket handles that on the connection that is already open. SSE also caps out at six concurrent connections per domain in most browsers, which is a real ceiling for a multi-account dashboard.

If your stack genuinely needs SSE, put a thin translator in front of the WebSocket. Most teams do not bother once they see the message format.


Getting an MT4 API key

Identical flow, same key, same header. MT4 logins are integers too, and you can connect either by server name or by explicit host and port. One key covers both platforms — every seat includes MT4 and MT5, and you can mix them on one subscription — so you do not manage two integrations. Handy detail if you are building a copy-trading product where the master is on MT4 and half the followers are on MT5 — that architecture is covered here.


What does it cost?

One plan, priced per seat. A seat is one connected MT4 or MT5 account, billed upfront for a full billing month, and the price drops as you add seats (each price applies to the seats in its range):

Seats Per seat, per month What you get
1–4 $14 Each seat: 1 MT4 or MT5 account, REST + WebSocket streaming, 20 requests/second per API key, connect/disconnect allowed
5–19 $13 Same — everything included in every seat
20 and up $12 Same — up to 50 seats per customer; more on request

Worked totals per month: 4 seats $56, 10 seats $134, 20 seats $263, 50 seats $623. Above 50 seats is by arrangement (indicatively, 100 seats on the same graduated scale would be $1,223 per month). There is no proration or refund, and no per-request or per-feature fee. Disconnecting an account frees its seat for another account within the paid billing month at no charge.

The single $14 seat exists so you can build against a real broker account for the price of a coffee before you commit anything. That is the honest answer to "how much does this cost" — and the reason the pricing page has no "contact sales for a quote" wall on the entry plan.

Is there a free tool or a free trial? Not right now — there is no free tier, and we would rather say so than bury it. What you can do is open a demo account with your broker and point your integration at it, so you test with virtual money instead of real funds while you build (connecting it uses a normal seat). If you have questions about a serious integration before you buy, talk to us on Telegram or by email; that conversation is a lot cheaper than either of us discovering an architectural mismatch in month three.

Compare that with usage-based pricing, where every user you onboard adds metered charges to your bill. We ran the numbers against the best-known competitor in this MetaApi pricing comparison.


Is this the best API for forex trading?

Fair question, and "we say so" is not an answer. Judge any MetaTrader API on five things:

  1. Does it need anything on your side? If you have to run MetaTrader, an EA or a VPS yourself, you inherit its crashes, its memory footprint and its cost. With MetaTrader API there is nothing to install on your side, no EA for you to run and no MetaTrader window to keep open.
  2. How does it price growth? Pricing that stacks per-request charges and per-feature add-ons on top of every account punishes exactly the outcome you want. A known price per seat with everything included — and a per-seat price that drops to $12 from the 20th seat — does not.
  3. How wide is the surface? A wrapper with twelve endpoints will stop you dead the first time you need order history pagination, required margin, or trade sessions. More than 100 endpoints is a different kind of ceiling.
  4. Can you see how it runs? For this platform: measured uptime is published on a live status page, and security details are in the Trust Center.
  5. Does it cover both platforms? MT4 is not dead. Anything that handles only MT5 makes MT4 someone else's problem, and that someone is you.

For a hobbyist testing one strategy on one account, a cloud wrapper's five-minute sandbox is genuinely fine. For a prop firm, a CRM, a signal service or any product that has to survive its own growth, a known price per seat keeps the cost curve predictable. The long-form version of that argument is in MetaApi vs direct MetaTrader API.


Five mistakes that eat the first day

  1. Investor password instead of the main password. Reads work, trades fail, no obvious error. Check this first, always.
  2. Approximate server name. ICMarkets-Live12 is not ICMarkets Live 12. Use /GetBrokerServersByBrokerName and copy exactly.
  3. API key in front-end code. It authenticates every account on your plan. Keep it server-side.
  4. Confusing the key with the UUID. The key goes in the x-api-key header; the account UUID goes in id. Swapping them produces a 401 that looks like a billing problem.
  5. Assuming the session is eternal. Brokers restart servers, and connections drop at weekends. Dropped connections are restored automatically; check /ConnectState?id= on a schedule and read statusReason when it reports ERROR.

FAQ

How do I get an MT5 API key? From an API provider, not from MetaTrader. Create an account at app.metatraderapi.net, connect your MT5 login to receive an account UUID, click Generate key on the account's card (or take the key returned by /ConnectEx or POST /v1/seats), then authenticate with the x-api-key header and pass the UUID as id.

Does MetaTrader 5 have an official API key? No. MetaQuotes publishes MQL5 for Expert Advisors that run inside MetaTrader and licenses the Manager/Server API to brokers. There is no public REST API and no official API key for retail accounts.

Is MetaTrader open source? No. MT4 and MT5 are proprietary MetaQuotes products. There is no public source, and no community fork you can self-host.

Do I need MetaTrader installed to use the API? No. There is nothing to install on your side: no MetaTrader installation and no Expert Advisor for you to run.

Is there a free MT5 API? There is no free tier here. You can open a demo account with your broker and develop against it with virtual money; connecting it uses a seat, and a single seat costs $14 per month.

Does the API support SSE? Streaming is over WebSocket at wss://api.metatraderapi.net/v1/stream?id=<account id>, not Server-Sent Events — bidirectional, so you subscribe with {"action":"subscribe","symbol":"EURUSD"} on the open socket.

Can I use the same key for MT4 and MT5? Yes. Every seat includes MT4 and MT5. One key, one integration, both platforms.


Get your key

The first API call takes about ten minutes. A single seat costs $14 per month; there is no free trial.

👉 Get your MT5 API key at MetaTrader API — or read the full endpoint documentation first.


MetaTrader API is an independent service and is not affiliated with, authorized by, or endorsed by MetaQuotes. "MetaTrader", "MT4" and "MT5" are registered trademarks of MetaQuotes Ltd. References are used strictly for identification and compatibility purposes.

Ready to integrate the MetaTrader API?

REST, WebSocket and gRPC for MT4 and MT5. Pay per connected account.

Create account