OGTradEx provides a comprehensive API for programmatic access to our trading platform. Our API is designed for high performance, reliability, and ease of integration.
RESTful API for account management, order placement, and market data retrieval.
Real-time data streaming for market data, order updates, and account notifications.
Industry-standard Financial Information eXchange protocol for institutional clients.
Secure authentication methods for API access.
Our REST API provides the following main endpoint categories:
Base URL: /api/v1/account
Method | Endpoint | Description |
---|---|---|
GET | /balance | Retrieve account balances for all assets |
GET | /positions | Get current open positions |
GET | /history | Retrieve account transaction history |
GET | /settings | Get account settings and preferences |
Base URL: /api/v1/orders
Method | Endpoint | Description |
---|---|---|
POST | / | Place a new order |
GET | /{order_id} | Get order details by ID |
DELETE | /{order_id} | Cancel an existing order |
GET | /open | List all open orders |
PUT | /{order_id} | Modify an existing order |
Base URL: /api/v1/market
Method | Endpoint | Description |
---|---|---|
GET | /ticker | Get ticker information for specified symbols |
GET | /orderbook | Retrieve order book data with specified depth |
GET | /trades | Get recent trades for a symbol |
GET | /candles | Retrieve OHLCV candle data |
Base URL: /api/v1/instruments
Method | Endpoint | Description |
---|---|---|
GET | / | List all available trading instruments |
GET | /{symbol} | Get detailed information about a specific instrument |
GET | /categories | List instrument categories (forex, crypto, etc.) |
// 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);
};
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()
We provide official client libraries for popular programming languages to simplify API integration:
Comprehensive Python library with async support.
pip install ogtradex-python
View DocumentationNode.js and browser compatible library.
npm install @ogtradex/api
View Documentation