REST · WebSocket · SDK

API Reference

The Guro Markets API gives you programmatic access to live market data, order execution, account management and portfolio analytics. Build trading bots, automate strategies, and integrate with your own systems.

Base URLhttps://api.guromarkets.com/v2
WebSocketwss://api.guromarkets.com/v2/stream
Security

Authentication & Keys

All API requests require authentication using an API key passed in the request header. Generate keys from your dashboard under Settings → API Access.

💡 Tip: Create separate API keys for each application or bot you run. This allows you to revoke individual keys without affecting other integrations.

Request Header

HTTP Header
X-API-Key: gm_live_sk_4b8f2a91c3e7d5f0a6b2c4e8f1d3a5b7
Content-Type: application/json

API Key Types

Key TypePrefixPermissionsScope
Live Keygm_live_sk_Full trading accessProduction
Paper Keygm_paper_sk_Demo trading onlySandbox
Read Keygm_read_sk_Market data & account readBoth
Webhook Keygm_wh_sk_Webhook signature verificationBoth
⚠ Security: Never expose your API keys in client-side code, public repositories, or URLs. Store secrets in environment variables and rotate keys every 90 days.
Getting Started

Quick Start

Get up and running in under 5 minutes. Place your first trade programmatically using our REST API.

JavaScript (Node.js)
// Install: npm install @guromarkets/api
import { GuroMarketsClient } from '@guromarkets/api';

const client = new GuroMarketsClient({
  apiKey: process.env.GURO_API_KEY,
  environment: 'live', // or 'paper'
});

// Get account balance
const account = await client.account.get();
console.log(`Balance: $${account.balance}`);

// Get live price for XAU/USD
const quote = await client.marketData.getQuote('XAUUSD');
console.log(`XAU/USD: ${quote.bid} / ${quote.ask}`);

// Place a market buy order
const order = await client.orders.create({
  instrument: 'XAUUSD',
  side: 'buy',
  type: 'market',
  volume: 0.1,         // 0.1 lots
  stopLoss: 2368.00,
  takeProfit: 2410.00,
});

console.log(`Order placed: ${order.id} @ ${order.executionPrice}`);
Python
# Install: pip install guromarkets
from guromarkets import GuroMarketsClient
import os

client = GuroMarketsClient(
    api_key=os.environ['GURO_API_KEY'],
    environment='live'
)

# Get account balance
account = client.account.get()
print(f"Balance: ${account['balance']}")

# Get live quote
quote = client.market_data.get_quote('XAUUSD')
print(f"XAU/USD: {quote['bid']} / {quote['ask']}")

# Place a market buy order
order = client.orders.create(
    instrument='XAUUSD',
    side='buy',
    order_type='market',
    volume=0.1,
    stop_loss=2368.00,
    take_profit=2410.00
)
print(f"Order: {order['id']} @ {order['execution_price']}")
cURL
# Get account info
curl -X GET "https://api.guromarkets.com/v2/account" \
  -H "X-API-Key: gm_live_sk_YOUR_KEY" \
  -H "Content-Type: application/json"

# Place a market order
curl -X POST "https://api.guromarkets.com/v2/orders" \
  -H "X-API-Key: gm_live_sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "instrument": "XAUUSD",
    "side": "buy",
    "type": "market",
    "volume": 0.1,
    "stopLoss": 2368.00,
    "takeProfit": 2410.00
  }'
REST API

Market Data

Real-time and historical price data for all 500+ instruments. No authentication required for public endpoints.

Parameters
ParameterTypeDescription
instrument requiredstringInstrument code e.g. XAUUSD, EURUSD, BTCUSD
Example Response
{ "instrument": "XAUUSD", "bid": 2386.92, "ask": 2387.45, "spread": 0.53, "timestamp": "2026-05-13T10:29:00Z" }
Parameters
ParameterTypeDescription
instruments requiredstring[]Comma-separated list of instrument codes
Example Response
{ "quotes": [{ "instrument": "XAUUSD", "bid": 2386.92, "ask": 2387.45 }, ...] }
Parameters
ParameterTypeDescription
instrument requiredstringInstrument code
timeframe requiredstring1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w
from optionalISO 8601Start datetime
to optionalISO 8601End datetime (default: now)
limit optionalintegerMax candles to return (default: 100, max: 5000)
Example Response
{ "instrument": "XAUUSD", "timeframe": "1h", "candles": [{ "time": "2026-05-13T09:00:00Z", "open": 2382.10, "high": 2391.20, "low": 2379.80, "close": 2387.45, "volume": 18420 }] }
Parameters
ParameterTypeDescription
category optionalstringforex, crypto, metals, indices, commodities
search optionalstringSearch by name or symbol
Example Response
{ "instruments": [{ "symbol": "XAUUSD", "name": "Gold Spot", "category": "metals", "minVolume": 0.01, "maxVolume": 100, "pipSize": 0.01 }] }
REST API

Order Management

Place, modify, and cancel orders across all instrument types. Requires Live or Paper API key.

✓ Sandbox: Use a Paper API key (gm_paper_sk_) to test order placement without real money. Paper trading mirrors live conditions exactly.
Parameters
ParameterTypeDescription
instrument requiredstringInstrument code e.g. XAUUSD
side requiredstringbuy or sell
type requiredstringmarket, limit, stop, stop_limit
volume requirednumberLot size (min 0.01)
price optionalnumberRequired for limit and stop orders
stopLoss optionalnumberStop loss price
takeProfit optionalnumberTake profit price
leverage optionalintegerLeverage ratio (default: account setting)
Example Response
{ "orderId": "ord_4821GM", "status": "filled", "instrument": "XAUUSD", "side": "buy", "volume": 0.1, "executionPrice": 2387.45, "margin": 238.75, "timestamp": "2026-05-13T10:29:00Z" }
Parameters
ParameterTypeDescription
status optionalstringopen, filled, cancelled, all (default: all)
instrument optionalstringFilter by instrument
limit optionalintegerResults per page (default: 50, max: 200)
Example Response
{ "orders": [...], "total": 142, "page": 1 }
Parameters
ParameterTypeDescription
orderId requiredstringOrder ID to cancel
Example Response
{ "orderId": "ord_4821GM", "status": "cancelled", "timestamp": "2026-05-13T10:29:00Z" }
REST API

Account API

Retrieve account balance, equity, margin usage and settings.

Example Response
{ "accountId": "GM-2026-00847", "balance": 10842.00, "equity": 11234.55, "margin": 274.45, "freeMargin": 10568.10, "marginLevel": "4094%", "unrealisedPnl": 392.55, "currency": "USD" }
Example Response
{ "leverage": "1:100", "hedging": true, "stopOut": "50%", "marginCall": "100%" }
REST API

Positions & History

Parameters
ParameterTypeDescription
instrument optionalstringFilter by instrument
Example Response
{ "positions": [{ "id": "pos_4821", "instrument": "XAUUSD", "side": "buy", "volume": 0.5, "entryPrice": 2368.40, "currentPrice": 2387.45, "unrealisedPnl": 952.50, "swap": -0.42 }] }
Parameters
ParameterTypeDescription
positionId requiredstringPosition ID to close
volume optionalnumberPartial close volume (default: full close)
Example Response
{ "positionId": "pos_4821", "status": "closed", "closePrice": 2387.45, "realisedPnl": 952.50 }
WebSocket API

WebSocket Streaming

Real-time streaming of price quotes, order book updates, and account notifications. Latency < 10ms globally via Cloudflare edge.

WebSocket — Live Price Stream
const ws = new WebSocket('wss://api.guromarkets.com/v2/stream');

// Authenticate on connect
ws.onopen = () => {
  ws.send(JSON.stringify({
    type: 'auth',
    apiKey: 'gm_live_sk_YOUR_KEY'
  }));
};

// Subscribe to instruments
ws.send(JSON.stringify({
  type: 'subscribe',
  channels: ['quotes', 'positions'],
  instruments: ['XAUUSD', 'EURUSD', 'BTCUSD']
}));

// Handle incoming messages
ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);

  switch (msg.type) {
    case 'quote':
      console.log(`${msg.instrument}: Bid=${msg.bid} Ask=${msg.ask}`);
      break;
    case 'order.filled':
      console.log(`Order filled: ${msg.orderId} @ ${msg.price}`);
      break;
    case 'position.update':
      console.log(`P&L Update: $${msg.unrealisedPnl}`);
      break;
  }
};

// Heartbeat (every 30s)
setInterval(() => ws.send(JSON.stringify({ type: 'ping' })), 30000);

WebSocket Message Types

Event TypeDirectionDescription
authClient → ServerAuthenticate with API key
subscribeClient → ServerSubscribe to price/account channels
quoteServer → ClientReal-time bid/ask update for instrument
ohlcServer → ClientOHLC bar close for subscribed timeframe
order.createdServer → ClientOrder placed confirmation
order.filledServer → ClientOrder execution notification
position.updateServer → ClientUnrealised P&L update
margin.callServer → ClientMargin level below threshold alert
ping / pongBothConnection heartbeat
Limits

Rate Limits

Rate limits are applied per API key. Exceeding limits returns HTTP 429. Headers on every response show your current usage.

Endpoint GroupRate LimitBurstWindow
Market Data (public)500 req/min1,00060s rolling
Account & Positions120 req/min24060s rolling
Order Placement60 req/min12060s rolling
Historical Data30 req/min6060s rolling
WebSocket Connections10 per key—Concurrent
WebSocket Subscriptions100 per connection——
Rate Limit Headers: Check X-RateLimit-Remaining and X-RateLimit-Reset on every response to monitor your usage.
Reference

Error Handling

All errors return a JSON body with a machine-readable code and human-readable message.

Error Response Format
{
  "error": {
    "code": "INSUFFICIENT_MARGIN",
    "message": "Insufficient margin to open position. Required: $240.50, Available: $180.20",
    "details": {
      "required": 240.50,
      "available": 180.20,
      "instrument": "XAUUSD"
    },
    "requestId": "req_9f84b2c1d3e7",
    "timestamp": "2026-05-13T10:29:00Z"
  }
}
HTTP CodeError CodeDescription
400INVALID_PARAMETERMissing or malformed request parameter
401UNAUTHORIZEDAPI key missing, invalid, or expired
403FORBIDDENKey lacks permission for this operation
404NOT_FOUNDResource (order, position) not found
409INSUFFICIENT_MARGINNot enough free margin to open position
409EXPOSURE_LIMITInstrument has reached its trading capacity; reduce size or retry later
409CLIENT_LIMITOrder would exceed your maximum position size on this instrument
409MARKET_CLOSEDInstrument market is currently closed
429RATE_LIMITEDRate limit exceeded — retry after X seconds
500INTERNAL_ERRORServer error — contact support if persistent
Libraries

SDKs & Libraries

Official and community SDKs. All official SDKs are open source, actively maintained, and include TypeScript types.

JavaScript / TypeScript Official
npm install @guromarkets/api
⭐ 2.4k stars on GitHub
Python Official
pip install guromarkets
⭐ 1.8k stars on GitHub
Go Official
go get github.com/guromarkets/go-sdk
⭐ 940 stars on GitHub
Rust
cargo add guromarkets
⭐ 620 stars on GitHub
Events

Webhooks & Events

Configure webhooks to receive HTTP POST notifications for account events — no polling required.

Webhook Payload — order.filled
{
  "event": "order.filled",
  "timestamp": "2026-05-13T10:29:00Z",
  "webhookId": "wh_9f84b2c1",
  "data": {
    "orderId": "ord_4821GM",
    "instrument": "XAUUSD",
    "side": "buy",
    "volume": 0.1,
    "executionPrice": 2387.45,
    "stopLoss": 2368.00,
    "takeProfit": 2410.00,
    "commission": 0.00,
    "marginUsed": 238.75
  }
}

// Verify webhook signature (Node.js)
import crypto from 'crypto';

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature), Buffer.from(expected)
  );
}

Available Webhook Events

EventTrigger
order.createdNew order placed
order.filledOrder executed at market
order.cancelledOrder cancelled
position.openedNew position opened
position.closedPosition closed (P&L realised)
position.sl_hitStop loss triggered
position.tp_hitTake profit triggered
deposit.confirmedDeposit credited to account
withdrawal.processedWithdrawal sent
margin.callMargin level below call threshold
kyc.approvedKYC verification passed
Updates

API Changelog

v2.1.0
May 1, 2026
New
Added WebSocket ohlc channel for real-time candlestick data. Added OCO (One-Cancels-Other) order type. Added GET /instruments/search endpoint.
v2.0.0
March 15, 2026
Major
Full API redesign. New authentication model with scoped API keys. WebSocket v2 with sub-10ms latency. Improved error codes. Rate limit headers on all responses. v1 deprecated — sunset June 2026.
v1.8.2
Jan 20, 2026
Bug fixes: Fixed race condition in order execution under high-frequency conditions. Improved margin calculation accuracy for cross-currency pairs.