API reference
One key. Every account.
Connect a MetaTrader 5 account once, then read and trade it over REST or WebSocket. The key goes in theX-API-Key header.
1. Add an account
One seat per account. Credentials are encrypted before storage.
curl -X POST https://api.socketrade.com/v2/accounts \
-H "X-API-Key: $SOCKETRADE_KEY" \
-H "Content-Type: application/json" \
-d '{ "accountNumber": "41299492",
"accountPassword": "…",
"accountServerHost": "Deriv-Demo",
"name": "Demo" }'2. Connect it
curl -X POST https://api.socketrade.com/v2/accounts/acc_…/connect \ -H "X-API-Key: $SOCKETRADE_KEY"
3. Read it
curl https://api.socketrade.com/v2/acc_…/status \
-H "X-API-Key: $SOCKETRADE_KEY"
{
"status": "ready",
"account": { "login": 41299492, "balance": 23706.35,
"equity": 23998.10, "currency": "USD",
"tradeAllowed": true },
"broker": { "connected": true, "server": "Deriv-Demo" }
}curl https://api.socketrade.com/v2/acc_…/positions \
-H "X-API-Key: $SOCKETRADE_KEY"
{ "positions": [
{ "ticket": 4789544305, "symbol": "XAUUSD", "type": "buy",
"volume": 0.1, "price_open": 3858.02,
"price_current": 3859.14, "profit": 11.20 } ] }4. Trade it
Orders return the broker retcode and the resulting deal or position.
# operation 0 buys, 1 sells
curl -X POST https://api.socketrade.com/v2/acc_…/OrderSend \
-H "X-API-Key: $SOCKETRADE_KEY" \
-H "Content-Type: application/json" \
-d '{ "symbol": "EURUSD", "operation": 0, "volume": 0.01 }'
curl -X POST https://api.socketrade.com/v2/acc_…/PositionClose \
-H "X-API-Key: $SOCKETRADE_KEY" \
-H "Content-Type: application/json" \
-d '{ "ticket": 4789544305 }'Seats
curl https://api.socketrade.com/v2/usage -H "X-API-Key: $SOCKETRADE_KEY"
{ "seats": 3, "seatsUsed": 1 }Endpoints
| POST /v2/accounts | Add an account. One seat per account. |
| POST /v2/accounts/{id}/connect | Bring the account online. |
| GET /v2/{id}/status | Balance, equity, margin and connection state. |
| GET /v2/{id}/positions | Open positions with live profit. |
| POST /v2/{id}/OrderSend | Place a market order. |
| POST /v2/{id}/PositionClose | Close a position by ticket. |
| GET /v2/{id}/history | Closed deals. |
| GET /v2/usage | Seats bought and used. |
| WS /v2/{id}/ws | Live bid/ask ticks for up to 64 subscribed symbols. |
Errors
401Missing or wrong key.
402Seat limit reached. Upgrade or remove an account.
404Account not found, or not yours.
409Account already added.
More
QuickstartDemo to first order in five minutes, with paste-ready calls.GuidesOrders, closes, history and reconnects, with the rules that matter.LimitsHistory depth, 64 symbols per socket, seats and retries.BlogWhat happens when a session drops, and the broker quirks that break an API.Seat typesTrade, execution and monitor seats, and what each may do.Api2Trade compatibleKeep your existing calls. Change the base URL and the key.ErrorsEvery status code, and which ones are worth retrying.AlternativesHonest comparisons with MetaApi, Api2Trade, MetaTraderAPI and FxSocket.BrokersServer names, symbols and quirks for twelve MT5 brokers.Use casesProp firms, copy trading, dashboards and backtesting.ProofA live session killed on purpose, back in 14.7 seconds.StatusThe public API, checked live.
Clients
Official Python and JavaScript clients, MIT licensed, with a Postman collection. The Python client needs only requests.