Back to Home

API Documentation

OGTradEx provides a comprehensive API for programmatic access to our trading platform. Our API is designed for high performance, reliability, and ease of integration.

REST API

RESTful API for account management, order placement, and market data retrieval.

  • HTTPS with TLS 1.3
  • JSON response format
  • Rate limiting: 100 requests/second
  • Comprehensive error handling

WebSocket API

Real-time data streaming for market data, order updates, and account notifications.

  • Persistent connections
  • Binary and JSON formats
  • Heartbeat mechanism
  • Automatic reconnection

FIX Protocol

Industry-standard Financial Information eXchange protocol for institutional clients.

  • FIX 4.2, 4.4, and 5.0 support
  • Drop Copy service
  • Dedicated sessions
  • Custom tag support

Authentication

Secure authentication methods for API access.

  • API key & secret
  • JWT tokens
  • OAuth 2.0 support
  • IP whitelisting

API Endpoints

Our REST API provides the following main endpoint categories:

Account Endpoints

Base URL: /api/v1/account

MethodEndpointDescription
GET/balanceRetrieve account balances for all assets
GET/positionsGet current open positions
GET/historyRetrieve account transaction history
GET/settingsGet account settings and preferences

Order Endpoints

Base URL: /api/v1/orders

MethodEndpointDescription
POST/Place a new order
GET/{order_id}Get order details by ID
DELETE/{order_id}Cancel an existing order
GET/openList all open orders
PUT/{order_id}Modify an existing order

Market Data Endpoints

Base URL: /api/v1/market

MethodEndpointDescription
GET/tickerGet ticker information for specified symbols
GET/orderbookRetrieve order book data with specified depth
GET/tradesGet recent trades for a symbol
GET/candlesRetrieve OHLCV candle data

Instrument Endpoints

Base URL: /api/v1/instruments

MethodEndpointDescription
GET/List all available trading instruments
GET/{symbol}Get detailed information about a specific instrument
GET/categoriesList instrument categories (forex, crypto, etc.)

Code Examples

JavaScript

// Place a market order using the REST API
const placeOrder = async () => {
  const apiKey = 'your_api_key';
  const apiSecret = 'your_api_secret';
  const timestamp = Date.now().toString();
  
  // Create signature (implementation depends on your authentication method)
  const signature = createSignature(apiSecret, timestamp, 'POST', '/api/v1/orders');
  
  const response = await fetch('https://api.ogtradex.com/api/v1/orders', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': apiKey,
      'X-Timestamp': timestamp,
      'X-Signature': signature
    },
    body: JSON.stringify({
      symbol: 'BTC/USD',
      side: 'buy',
      type: 'market',
      quantity: 0.1
    })
  });
  
  const data = await response.json();
  console.log('Order placed:', data);
};

Python

import requests
import time
import hmac
import hashlib
import json

# Connect to WebSocket for real-time market data
def connect_to_websocket():
    import websocket
    import threading
    
    def on_message(ws, message):
        data = json.loads(message)
        print(f"Received: {data}")
    
    def on_error(ws, error):
        print(f"Error: {error}")
    
    def on_close(ws, close_status_code, close_msg):
        print("Connection closed")
    
    def on_open(ws):
        print("Connection opened")
        # Subscribe to BTC/USD ticker
        ws.send(json.dumps({
            "method": "subscribe",
            "params": {
                "channel": "ticker",
                "symbols": ["BTC/USD"]
            },
            "id": 1
        }))
    
    websocket_url = "wss://stream.ogtradex.com/ws"
    ws = websocket.WebSocketApp(websocket_url,
                              on_open=on_open,
                              on_message=on_message,
                              on_error=on_error,
                              on_close=on_close)
    
    wst = threading.Thread(target=ws.run_forever)
    wst.daemon = True
    wst.start()
    
    return ws

# Usage
ws = connect_to_websocket()
# Keep the main thread running
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    ws.close()

API Libraries

We provide official client libraries for popular programming languages to simplify API integration:

Python SDK

Comprehensive Python library with async support.

pip install ogtradex-python
View Documentation

JavaScript/TypeScript

Node.js and browser compatible library.

npm install @ogtradex/api
View Documentation

Java SDK

Enterprise-ready Java client library.

maven: com.ogtradex:api-client:1.2.0
View Documentation