MetaTrader API: read and trade MT4 and MT5 from code
A hosted MetaTrader API for MT4 and MT5, over REST and WebSocket. Read balance, equity, positions and history, and trade with a Full Access key.
$8 per account every 30 days. First account free for 15 days.
Equity (USD)
100,842.65
/account-information
- /positions2 open+842.65
- /history-positions3 closed today+390.90
- /ordersEURUSD buy limit1.08200
- /quotesEURUSD1.08735
from fundedops import FundedOps
with FundedOps(api_key="fo_live_...") as client:
for account in client.accounts.list():
print(account.id, account.state, account.connection_status)
info = client.accounts.account_information(account.id)
print(info.balance, info.equity, info.currency)
# Deploy and block until connected (timeout is mandatory).
client.accounts.deploy(account.id)
client.wait_until_connected(account.id, timeout=180)Endpoints
Every path starts with /v1.Every path starts with /v1. The API reads trading data, and with a Full Access key it places, changes and closes trades.
Account lifecycle
9 endpoints
- GET
/accounts - POST
/accounts - GET
/accounts /{id} - PATCH
/accounts /{id} - DELETE
/accounts /{id} - POST
/accounts /{id} /deploy - POST
/accounts /{id} /redeploy - POST
/accounts /{id} /undeploy - GET
/servers
Trading
12 endpoints
- POST
/accounts /{id} /orders - PATCH
/accounts /{id} /orders /{ticket} - DELETE
/accounts /{id} /orders /{ticket} - PATCH
/accounts /{id} /positions /{ticket} - POST
/accounts /{id} /positions /{ticket} /close - POST
/accounts /{id} /positions /close - POST
/accounts /{id} /positions /{ticket} /close-by - GET
/accounts /{id} /calculate-margin - GET
/accounts /{id} /calculate-profit - GET
/accounts /{id} /check-order - GET
/accounts /{id} /trade-requests - GET
/accounts /{id} /trade-requests /{trade_request_id}
Account data
12 endpoints
- GET
/accounts /{id} /account-information - GET
/accounts /{id} /positions - GET
/accounts /{id} /orders - GET
/accounts /{id} /history-deals - GET
/accounts /{id} /history-orders - GET
/accounts /{id} /history-positions - GET
/accounts /{id} /trade-stats - GET
/accounts /{id} /equity-history - GET
/accounts /{id} /balance-history - GET
/accounts /{id} /balance-operations - GET
/accounts /{id} /symbols - GET
/accounts /{id} /symbols /{symbol}
Market data
3 endpoints
- GET
/accounts /{id} /quote - GET
/accounts /{id} /quotes - GET
/accounts /{id} /candles
Billing
2 endpoints
- GET
/billing - POST
/billing /checkout
Health
1 endpoint
- GET
/ping
MCP server
1 endpoint
- POST
/mcp
Every operation above is a tool in our MetaTrader MCP server for AI apps such as Claude Code and Cursor, with the same API key and the same errors and limits.
WebSocket stream
1 endpoint
- WSS
/stream
Subscribe to an account to get a full snapshot, then live updates to account information, positions, orders and new deals. Quotes and candles stream on the same socket.
Full request and response shapes are in the API reference.
Limits
Go over the request limit and you get a 429 with a Retry-After header.The same limits apply to live and test keys. Go over the request limit and you get a 429 with a Retry-After header. The Python SDK needs Python 3.10 or newer, and the JavaScript and TypeScript SDK needs Node 22 or newer.
- requests per second, shared by all your keys
- 25
- requests in a single burst
- 100
- WebSocket connections per developer account, shared by all its keys
- 5
- account subscriptions per connection
- 50
MT4 works the same way
MT4 accounts use the same endpoints and data model as MT5, with five differences:
Every record says its platform
Each position, order and deal has aplatformfield that says MT4 or MT5 (mt4ormt5).One history pool
MT4 keeps one history. You read it as closed deals from/history-dealsor as finished orders from/history-orders.Ticket and position ID match
On MT4 a position's ticket is also its position ID. Deals and orders point to it throughpositionId.No stop-limit orders
MT4 pending orders arebuy_limit,sell_limit,buy_stopandsell_stoponly.A partial close opens a new ticket
Closing part of an MT4 position opens a new ticket for the volume that is left. List History Positions joins those tickets back into one row through the broker's comment links, and a piece the broker does not number stays its own row. After a Close By, the position that was closed by the other shows volume 0 and the other carries the profit.
Docs
The docs are public. You don't need an account to read them.
- QuickstartCreate a key, connect an account, then read and stream it.
- REST referenceEvery endpoint, field and error.
- WebSocket streamSubscribe, snapshots, updates and limits.
- Python SDKSync and async clients and streaming.
- JavaScript and TypeScript SDKA typed client for Node, with streaming and webhook checks.
- TradingPlace, change and close trades, with idempotency keys, statuses and errors.
- WebhooksSigned events at your own URL, with retries.
- AI agents (MCP)Use the API from AI apps with the same key.
- Errors and limitsEvery error code and every limit.
The Python SDK is on PyPI and the JavaScript and TypeScript SDK is on npm.