API Reference
FxSocket exposes your MT4 and MT5 terminals through a REST API and WebSocket streams. All endpoints return JSON. Authenticate with a Bearer token in the Authorization header.
https://api.fxsocket.comAPI Tester
Try a live request. Enter your API key and select an endpoint.
Authentication
Authorization: Bearer sk_live_xxxAll requests require a Bearer token. Create API keys from your dashboard. Keys can be scoped to read-only, trade, or full access.
Account
/v1/accountReturns account balance, equity, margin, free margin, and currency. Use this to monitor account health or display P&L.
{
"id": "acc_8xKm2",
"balance": 10000.00,
"equity": 10234.50,
"margin": 120.40,
"free_margin": 10114.10,
"currency": "USD"
}/v1/accountsList all connected accounts under your API key. Returns account IDs, broker info, platform type (MT4/MT5), and connection status.
[{
"id": "acc_8xKm2",
"broker": "ICMarkets",
"platform": "MT5",
"status": "connected"
}]Trading
/v1/positionsList all open positions. Returns symbol, direction, volume, open price, current profit, and stop loss / take profit levels.
[{
"id": "pos_3nF8x",
"symbol": "EURUSD",
"type": "BUY",
"volume": 0.1,
"open_price": 1.08342,
"sl": 1.0800,
"tp": 1.0900,
"profit": 23.50
}]/v1/ordersCreate a market or pending order. Specify symbol, type (BUY, SELL, BUY_LIMIT, SELL_LIMIT, BUY_STOP, SELL_STOP), volume, and optional SL/TP.
{
"id": "ord_2aF9xK",
"symbol": "EURUSD",
"type": "BUY",
"volume": 0.1,
"price": 1.08342,
"status": "filled"
}/v1/orders/{id}Modify an existing order. Update stop loss, take profit, or pending order price. Cannot change symbol or direction.
{
"id": "ord_2aF9xK",
"sl": 1.0720,
"tp": 1.0950,
"updated": true
}/v1/orders/{id}Close an open position or cancel a pending order. Returns the closing price and realized profit.
{
"id": "ord_2aF9xK",
"status": "closed",
"close_price": 1.08501,
"profit": 15.90
}Market Data
/v1/quotes/{symbol}Get the current bid/ask price for a symbol. For real-time streaming, use the WebSocket endpoint instead.
{
"symbol": "EURUSD",
"bid": 1.08340,
"ask": 1.08342,
"spread": 0.2,
"time": "2026-04-02T14:30:00.123Z"
}/v1/candles/{symbol}Fetch historical OHLCV candlestick data. Supports all standard timeframes: M1, M5, M15, M30, H1, H4, D1, W1, MN. Specify date range with from/to parameters.
{
"symbol": "EURUSD",
"timeframe": "H1",
"candles": [{
"time": "2026-04-02T14:00:00Z",
"open": 1.0830,
"high": 1.0841,
"low": 1.0828,
"close": 1.0834,
"volume": 1243
}]
}/v1/historyRetrieve closed trade and order history. Filter by date range, symbol, or order type. Includes profit, commission, and swap.
{
"trades": [{
"id": "trd_x9Km3",
"symbol": "XAUUSD",
"type": "BUY",
"volume": 0.05,
"profit": 45.20,
"closed_at": "2026-04-02T14:30:00Z"
}],
"total": 142
}WebSocket Streams
wss://ws.fxsocket.com/v1/streamReal-time streaming connection. Subscribe to price quotes, order updates, and account changes. Authenticate via the Authorization header. No rate limits on WebSocket connections.
// Price update
{
"type": "quote",
"data": {
"symbol": "EURUSD",
"bid": 1.08340,
"ask": 1.08342,
"time": "2026-04-02T14:30:00.123Z"
}
}
// Order update
{
"type": "order_opened",
"data": {
"id": "ord_2aF9xK",
"symbol": "EURUSD",
"type": "BUY",
"volume": 0.1,
"price": 1.08342
}
}SDKs
Official client libraries are available for Python, Node.js, Go, and Rust. Each SDK wraps the REST API and WebSocket streams with language-native interfaces.
- Python:
pip install fxsocket - Node.js:
npm install fxsocket - Go:
go get github.com/fxsocket/go - Rust:
cargo add fxsocket
Rate Limits
REST API requests are limited to 60 requests per second per account. WebSocket connections have no rate limits. If you hit a rate limit, the API returns HTTP 429 with a Retry-After header.
Errors
All errors return a JSON body with error and message fields. HTTP status codes follow standard conventions: 400 for bad requests, 401 for auth failures, 404 for missing resources, 429 for rate limits, and 500 for server errors.