Back to Documentation
REST API

REST API
Reference

Complete HTTP API for trading operations, account management, position control, and market data.

Base URL
http://127.0.0.1:8080/v1
Auth
Bearer Token
Latency
<22ms
Rate Limit
100 req/s

Authentication

All requests require a valid API key

Generate your API key from the API Server modal inside Tradyn Terminal. Include the key in the Authorization header of every request:

$curl -H "Authorization: Bearer tk_live_..." http://127.0.0.1:8080/v1/api/account

API Key Scoping

Restrict keys to read-only, trade-only, or full access

Custom Port

Run the API server on a custom port for added security

Key Rotation

Generate new keys and revoke old ones instantly

Endpoints

API Reference

17 endpoints across 5 categories. Tap any row to inspect payloads.

Account

Positions

Orders

Trading

Market Data

Order Types

Use the type field for pending orders

0Buy
1Sell
2Buy Limit
3Sell Limit
4Buy Stop
5Sell Stop
Success
{
  "success": true,
  "data": { ... }
}
Error
{
  "success": false,
  "error": "Insufficient margin"
}

HTTP Status Codes

200OK

Request succeeded

400Bad Request

Missing or invalid parameters

401Unauthorized

Missing authorization header

403Forbidden

Invalid API key

404Not Found

Resource does not exist

500Server Error

Internal server error

503Unavailable

Not connected to trading server

Code Examples

Quick Start
in any language

Copy-paste examples to get your first API call running in seconds. Each example covers account info, positions, and trade execution.

Fetch account balance and equity
List all open positions with P&L
Execute a market buy with SL/TP
Close and modify existing positions
1import requests
2
3API_KEY = "tk_live_a1b2c3d4e5f6"
4BASE_URL = "http://127.0.0.1:8080/v1"
5headers = {"Authorization": f"Bearer {API_KEY}"}
6
7# Get account info
8account = requests.get(
9 f"{BASE_URL}/api/account", headers=headers
10).json()
11
12print(f"Balance: {account['data']['balance']}")
13print(f"Equity: {account['data']['equity']}")
14
15# Get open positions
16positions = requests.get(
17 f"{BASE_URL}/api/positions", headers=headers
18).json()
19
20for pos in positions["data"]:
21 print(f" {pos['symbol']} {pos['type']} {pos['volume']} lots P&L: {pos['profit']}")
22
23# Place a market buy
24order = requests.post(f"{BASE_URL}/api/trade", headers=headers, json={
25 "symbol": "EURUSD",
26 "action": "buy",
27 "volume": 0.10,
28 "sl": 1.0800,
29 "tp": 1.0950
30}).json()
31
32print(f"Filled ticket #{order['data']['ticket']} @ {order['data']['price']}")

Need real-time data?

Check out our WebSocket API for live market ticks, position updates, and instant notifications.