Socketrade

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/accountsAdd an account. One seat per account.
POST /v2/accounts/{id}/connectBring the account online.
GET /v2/{id}/statusBalance, equity, margin and connection state.
GET /v2/{id}/positionsOpen positions with live profit.
POST /v2/{id}/OrderSendPlace a market order.
POST /v2/{id}/PositionCloseClose a position by ticket.
GET /v2/{id}/historyClosed deals.
GET /v2/usageSeats bought and used.
WS /v2/{id}/wsLive 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

Clients

Official Python and JavaScript clients, MIT licensed, with a Postman collection. The Python client needs only requests.

Source on GitHub →