XBTFX Trading API
Compatible with XBTFX MetaTrader 5® accountsProgrammatically trade, manage positions, monitor account state, and stream real-time market data on compatible XBTFX MetaTrader 5® accounts through REST and WebSocket. Build automated strategies, connect AI agents, and integrate your account into custom workflows. Start with docs, working examples, AI skills, or the XBTFX MCP server. Designed for developers and users with experience in programming or AI coding assistants.

Automate Your Trading with the XBTFX API
The XBTFX Trading API lets you send instructions to your compatible XBTFX MetaTrader 5® account. Open positions, modify stops, query balances, and stream live quotes through standard REST and WebSocket calls.
API Endpoints for Trading, Positions & Market Data
Open and close positions, set stop loss and take profit, query account balances, retrieve trade history, and stream live forex and crypto quotes via WebSocket.
Send Your First API Trade in Minutes
A few lines of code in your language of choice. Standard HTTP — any language that can make a POST request works.
Execute Trades with Natural Language
The XBTFX Trading API is built to be consumed by AI agents and large language models — clean JSON, human-readable errors, predictable endpoints. Connect via the XBTFX Skills Hub or the MCP server and your AI client can send trades through conversational commands.
- Conversational orders — buy, sell, close, condition on data.
- Tool-grounded reasoning — every action returns a structured response.
- Portable across clients — Claude, Cursor, Windsurf, Codex.
Less technical? See our AI Agent Trading overview.
Illustrative example. Conditional flows depend on the configured agent and market-data feeds.
What AI agents do with the API
Event-Driven Trading
Smart Risk Management
Portfolio Rebalancing
Autonomous Analysis
Built for Your Existing XBTFX Account
Use your current Edge or ECN MetaTrader 5 account, your existing base currency, and your existing margin mode. The API plugs into the same account you already trade on.
Production-grade endpoints
Hedging & netting modes
Idempotency keys
Weight-based rate limits
FIX 4.4 institutional
Edge or ECN — same account
Edge & ECN accounts
PAMM, MAM & Copy Master accounts
Multi-currency settlement
Hedging or netting
Developer Resources
Example code, AI skill files, and full API documentation — everything you need to get building.
API Documentation
AI Skills Hub
Get Started in Three Steps
Same shell, two starting points — pick the one that matches your account state.
Frequently
Asked Questions
-
What is the XBTFX Trading API?
The XBTFX Trading API provides REST and WebSocket access for programmatic trading, account monitoring, market-data retrieval, and streaming on compatible XBTFX MetaTrader 5® accounts. It's built by XBTFX — you interact with clean HTTP endpoints and JSON responses to send trades and retrieve account data.
-
What programming languages can I use?
Any language that can make HTTP requests. Python, JavaScript, Go, Rust, C#, Java, Ruby, PHP — if it can send a POST request with a JSON body, it can send trades to your XBTFX account via the API.
-
Can I build automated trading strategies?
Yes. The XBTFX Trading API is designed for algorithmic and automated trading. You can build signal-driven bots, portfolio rebalancers, risk management systems, or any custom logic that sends trades to your account.
-
Is there a WebSocket feed for real-time prices?
Yes. The XBTFX Trading API provides a WebSocket endpoint for streaming real-time quotes from symbols available on your account. Quotes include 5-level market depth when available. Up to 1,000 symbol subscriptions per connection with up to 10 concurrent connections.
-
What's the difference between hedging and netting mode?
These are margin modes that determine how positions behave. Hedging allows multiple independent positions per symbol, including opposing buy and sell. Netting aggregates everything into one position per symbol. Your API key inherits the mode from your account.
-
What are the rate limits?
600 weight per minute per API key. Most requests cost 1 weight — up to 600 calls per minute. Bulk operations like close-all cost 10 weight. Every response includes headers showing your remaining budget.
-
Can I trade crypto CFDs through the API?
Yes. Every symbol available on your XBTFX account is accessible through the API — including cryptocurrency CFDs. You can also use the API with accounts denominated in BTC, ETH, USDT, or XRP.
-
Is the API free to use?
Yes. The XBTFX Trading API is included with every trading account at no additional cost. No API fees, subscription charges, or per-call costs beyond your normal trading commissions and spreads.
-
How do I get an API key?
First, create an XBTFX trading account at my.xbtfx.com if you don't have one. Then log in to the API Console at console.xbtfx.com with your XBTFX credentials, select your trading account, and generate a key. Verify it works by sending GET /v1/auth/status before placing trades.
-
Can I use the API with a demo account?
Yes. API keys work with both live and demo accounts. This lets you test your integration and validate your code before going live — on the same API with the same endpoints.
-
What should I do before placing trades?
Verify your API key and account status first by sending GET /v1/auth/status. This confirms your key is valid, shows your permissions and margin mode, and ensures your account is ready before you send any trade requests.
-
Do I need programming experience?
Using the REST API directly requires basic programming knowledge. However, with the AI integration paths, you don't need to write code yourself — connect the XBTFX MCP server to Claude Code or Cursor, or install a skill file from the Skills Hub, and issue trading commands through natural language. Familiarity with AI coding assistants is recommended.
-
Can I use AI to trade my account?
Yes. Use the XBTFX Skills Hub for agent frameworks that support skill files, or connect the XBTFX MCP server to MCP-compatible clients like Claude Code, Claude Desktop, OpenAI Codex, Cursor, or Windsurf. Both paths let you issue trading commands in natural language through the XBTFX Trading API.
-
Is it safe to give an AI agent access to my account?
API keys are typically stored locally by the agent on your machine and are not uploaded to third-party servers. The agent sends API calls directly to XBTFX's servers using your key. You can revoke the key instantly from the Console at any time. We recommend starting with a demo account to test your setup before going live.



