Single forex trading API for all your MetaTrader accounts
Manage MetaTrader accounts - create, read, update, deploy, and delete accounts.
Get all accounts with optional filtering and pagination.
GET /api/accounts?limit=10&offset=0&state=DEPLOYED
{
"success": true,
"data": [
{
"_id": "account-id-123",
"name": "My Trading Account",
"login": "12345678",
"server": "MetaQuotes-Demo",
"platform": "mt5",
"state": "DEPLOYED",
"connectionId": "conn-id-456",
"createdAt": "2024-01-15T10:00:00Z",
"lastUpdated": "2024-01-15T10:00:00Z"
}
],
"count": 1
}
Get a specific account by ID.
{
"success": true,
"data": {
"_id": "account-id-123",
"name": "My Trading Account",
"login": "12345678",
"server": "MetaQuotes-Demo",
"platform": "mt5",
"state": "DEPLOYED",
"connectionId": "conn-id-456"
}
}
Create a new MetaTrader account.
{
"name": "New Trading Account",
"login": "87654321",
"password": "your-password",
"server": "MetaQuotes-Demo",
"platform": "mt5",
"application": "MetaApi"
}
{
"success": true,
"data": {
"_id": "new-account-id",
"name": "New Trading Account",
"login": "87654321",
"server": "MetaQuotes-Demo",
"platform": "mt5",
"state": "CREATED",
"createdAt": "2024-01-15T10:00:00Z"
},
"message": "Account created successfully"
}
Update an existing account.
{
"name": "Updated Account Name",
"password": "new-password"
}
Delete an account.
Deploy an account to start receiving real-time data.
Undeploy an account to stop receiving real-time data.
Execute trades, get positions, orders, and portfolio information.
Health check endpoint to verify API connectivity.
{
"success": true,
"status": "ok",
"timestamp": "2024-01-15T10:00:00.000Z"
}
Get all open positions with risk calculations.
{
"success": true,
"data": [
{
"id": "123456789",
"symbol": "EURUSD",
"type": "POSITION_TYPE_BUY",
"volume": 0.1,
"openPrice": 1.08500,
"currentPrice": 1.08650,
"profit": 15.00,
"swap": 0.00,
"commission": -0.70,
"unrealizedProfit": 14.30,
"stopLoss": 1.08000,
"takeProfit": 1.09000,
"risk": {
"exposure": 10850.00,
"riskPercent": 2.5,
"riskAmount": 271.25
}
}
],
"count": 1
}
Get complete dashboard data including account info, positions, and portfolio risk.
{
"success": true,
"data": {
"account": {
"balance": 10000.00,
"equity": 10150.00,
"margin": 850.00,
"freeMargin": 9300.00,
"marginLevel": 1194.12,
"profit": 150.00,
"currency": "USD"
},
"positions": [...],
"portfolio": {
"totalExposure": 10850.00,
"totalRisk": 271.25,
"riskPercent": 2.71,
"diversification": 3,
"longPositions": 2,
"shortPositions": 1
}
}
}
Get all pending orders.
{
"success": true,
"data": [
{
"id": "987654321",
"symbol": "GBPUSD",
"type": "ORDER_TYPE_BUY_LIMIT",
"volume": 0.1,
"openPrice": 1.25000,
"stopLoss": 1.24500,
"takeProfit": 1.26000,
"currentPrice": 1.24800,
"state": "ORDER_STATE_PLACED"
}
],
"count": 1
}
Place a new market or pending order.
{
"symbol": "EURUSD",
"volume": 0.1,
"type": "MARKET",
"action": "BUY",
"stopLoss": 1.08000,
"takeProfit": 1.09000
}
{
"success": true,
"data": {
"orderId": "123456789",
"requestId": "req-123",
"symbol": "EURUSD",
"volume": 0.1,
"type": "ORDER_TYPE_BUY",
"openPrice": 1.08500,
"stopLoss": 1.08000,
"takeProfit": 1.09000
}
}
Get current prices, historical data, and symbol specifications.
Get current price for a specific symbol.
GET /api/prices/EURUSD
{
"success": true,
"data": {
"symbol": "EURUSD",
"bid": 1.08500,
"ask": 1.08520,
"spread": 0.00020,
"time": "2024-01-15T10:00:00Z"
}
}
Get prices for multiple symbols at once.
{
"symbols": ["EURUSD", "GBPUSD", "USDJPY", "XAUUSD"]
}
Get prices for popular symbols (EURUSD, GBPUSD, USDJPY, XAUUSD, XAGUSD).
/api/marketwatch
Get all symbols from Market Watch.
Get Market Watch symbols with full specifications.
Get current prices for all Market Watch symbols.
Get specification for a specific symbol (contract size, pip value, etc.).
Get current price for a specific symbol from Market Watch.
Get complete Market Watch dashboard data with all symbols and prices.
Prop trading risk management features - trackers, statistics, and equity charts.
Get tracker events by time range.
Stream tracker events in real-time via Server-Sent Events (SSE).
const eventSource = new EventSource('/api/risk/tracker-events/stream');
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Tracker event:', data);
};
Get all trackers for an account.
Create a new risk tracker.
{
"name": "Daily Loss Limit",
"type": "dailyLossLimit",
"period": "DAY",
"value": 500.00,
"enabled": true
}
Get a specific tracker by ID.
Update a tracker.
Delete a tracker.
Get period statistics for a tracker.
Get equity chart data for an account.
Stream real-time price updates via Server-Sent Events (SSE) or WebSocket.
Server-Sent Events endpoint for real-time price streaming.
const eventSource = new EventSource('/api/stream/sse');
eventSource.onmessage = (event) => {
const priceData = JSON.parse(event.data);
console.log('Price update:', priceData);
// {
// "symbol": "EURUSD",
// "bid": 1.08500,
// "ask": 1.08520,
// "spread": 0.00020,
// "time": "2024-01-15T10:00:00Z",
// "equity": 10000.00
// }
};
eventSource.onerror = (error) => {
console.error('SSE error:', error);
};
Get streaming service statistics.
{
"success": true,
"data": {
"websocketClients": 5,
"sseClients": 3,
"trackerEventClients": 2,
"totalClients": 10,
"isListening": true,
"symbolsTracked": 15,
"trackerEventsTracked": 50
}
}
Start listening to price updates for specified symbols.
{
"symbols": ["EURUSD", "GBPUSD", "USDJPY", "XAUUSD"]
}
{
"success": true,
"message": "Streaming started"
}
Real-time bidirectional communication using WebSocket protocol.
ws://localhost:3000/ws or wss://your-domain.com/ws
Connect to WebSocket server for real-time price updates.
const ws = new WebSocket('ws://localhost:3000/ws');
// Connection opened
ws.onopen = () => {
console.log('WebSocket connected');
// Send subscribe message
ws.send(JSON.stringify({
type: 'subscribe',
symbols: ['EURUSD', 'GBPUSD']
}));
};
// Listen for messages
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
// Price update format:
// {
// "symbol": "EURUSD",
// "bid": 1.08500,
// "ask": 1.08520,
// "spread": 0.00020,
// "time": "2024-01-15T10:00:00Z",
// "equity": 10000.00
// }
};
// Handle errors
ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
// Connection closed
ws.onclose = () => {
console.log('WebSocket disconnected');
};
{
"type": "subscribe",
"symbols": ["EURUSD", "GBPUSD", "USDJPY"]
}
{
"type": "unsubscribe",
"symbols": ["EURUSD"]
}
{
"type": "ping"
}
{
"symbol": "EURUSD",
"bid": 1.08500,
"ask": 1.08520,
"spread": 0.00020,
"time": "2024-01-15T10:00:00Z",
"equity": 10000.00
}
{
"type": "initial",
"prices": [
{
"symbol": "EURUSD",
"bid": 1.08500,
"ask": 1.08520,
"spread": 0.00020,
"time": "2024-01-15T10:00:00Z"
},
{
"symbol": "GBPUSD",
"bid": 1.26500,
"ask": 1.26520,
"spread": 0.00020,
"time": "2024-01-15T10:00:00Z"
}
]
}
{
"type": "status",
"status": "connected",
"message": "Real-time streaming connected"
}