Trading API Overview
The XBTFX Trading API provides programmatic access to your trading account through a modern REST and WebSocket interface. Execute trades, manage positions, retrieve account data, and stream real-time market quotes, all over HTTPS with JSON payloads.
Base URL
Section titled “Base URL”https://interface.xbtfx.comAll REST endpoints are prefixed with /v1/. WebSocket connections use wss://ws.xbtfx.com/v1/ws.
Protocol
Section titled “Protocol”- Transport: HTTPS (TLS 1.2+)
- Format: JSON request and response bodies
- Authentication: Bearer token via
Authorizationheader - Rate Limiting: 600 weight per minute per API key
What You Can Do
Section titled “What You Can Do”- Query account balance, equity, margin, and leverage
- Look up symbol specifications (contract size, volume limits, spreads)
- Open, close, modify, and reverse positions
- Place, modify, and cancel pending limit and stop orders
- Retrieve open positions and pending orders
- Pull trade history with flexible date ranges
- Stream real-time bid/ask quotes over WebSocket
- Access order book depth (up to 5 levels)
Getting Started
Section titled “Getting Started”- Sign up at portal.xbtfx.com and open a Pro trading account (the Trading API works with Pro accounts only)
- Create an API key in the API Console at portal.xbtfx.com: log in, select your Pro account, and generate a key
- Authenticate requests using your Bearer token
- Query your account info to verify connectivity
- Start trading
Available Endpoints
Section titled “Available Endpoints”Account and Auth
Section titled “Account and Auth”| Endpoint | Method | Description |
|---|---|---|
/v1/auth/status | GET | Check API key status and permissions |
/v1/account | GET | Retrieve account balance, equity, and margin |
Market Data
Section titled “Market Data”| Endpoint | Method | Description |
|---|---|---|
/v1/symbols | GET | List all available trading symbols |
/v1/symbols/:symbol | GET | Get specification for a single symbol |
Trading
Section titled “Trading”| Endpoint | Method | Description |
|---|---|---|
/v1/trade | POST | Open a market position |
/v1/close | POST | Close a specific position |
/v1/close-all | POST | Close all open positions |
/v1/close-symbol | POST | Close all positions for a symbol |
/v1/modify | POST | Modify SL/TP on a position or order |
/v1/close-by | POST | Close position by opposite (hedging only) |
/v1/reverse | POST | Reverse a position atomically |
Pending Orders
Section titled “Pending Orders”| Endpoint | Method | Description |
|---|---|---|
/v1/orders | GET | List pending orders |
/v1/orders | POST | Place a pending limit or stop order |
/v1/orders/{ticket} | PATCH | Modify a pending order |
/v1/orders/{ticket} | DELETE | Cancel a pending order |
Positions and History
Section titled “Positions and History”| Endpoint | Method | Description |
|---|---|---|
/v1/positions | GET | List open positions |
/v1/history | GET | Retrieve trade history |
Real-Time Data
Section titled “Real-Time Data”For streaming price quotes, connect via WebSocket at wss://ws.xbtfx.com/v1/ws. The WebSocket supports real-time bid/ask quotes and market depth data.
Key Concepts
Section titled “Key Concepts”- Rate Limits: understand the weight-based rate limiting system
- Idempotency: prevent duplicate operations with idempotency keys
- Hedging vs Netting: how account mode affects trading behavior
- Error Codes: complete error reference
Code Examples
Section titled “Code Examples”Ready-to-use examples are available for: