# fxapis MT5 API documentation > fxapis is a hosted REST API for MetaTrader 5 (MT5). Connect an MT5 account with its login, password and server, then trade it and read its positions and history over HTTPS; MetaTrader 5 runs on fxapis's side, hosted in the EU, so there is nothing to install. MT5 only — no MT4. - Base URL: https://api.fxapis.com. Authenticate with `Authorization: Bearer `; keys are created in the console at https://fxapis.com/dashboard/keys (sign up at https://fxapis.com/sign-up). - Successful responses are `{ "data": … }`; failures are `{ "error": { "code", "message" } }`. Match on `code`. - Send an `Idempotency-Key` header with every order (honoured for 24 hours). An opening order whose result is unknown is confirmed against the broker's history; poll it, never resend it. - Official SDKs: TypeScript (`npm install fxapis`) and Python (`pip install fxapis`); examples and starters at https://github.com/FXapis. - Event webhooks: register an HTTPS endpoint with `POST /v1/webhooks` (scope `webhooks:write`) to get a signed, retried POST when an order fills, a position opens or closes, an account changes state or a multi-account order finishes. Verify each delivery's `fxapis-signature` with the SDKs' `verifyWebhook()` / `fxapis.webhooks.verify()`. - A hosted MCP server for AI agents at https://api.fxapis.com/mcp: Claude and ChatGPT connect by signing in to fxapis with OAuth; unattended agents can send an API key instead. - Works with any MetaTrader 5 broker or prop firm, demo or live; no broker partnerships. What varies by broker: https://docs.fxapis.com/guides/broker-compatibility. - Live and test keys are labels only: both reach real brokers. Test with demo accounts. - Every page below is also available as Markdown by appending `.mdx` to its URL. The raw OpenAPI document is at https://api.fxapis.com/docs/json. ## Get started - [Overview](https://docs.fxapis.com/index.mdx): Documentation for fxapis, the hosted MetaTrader 5 REST API: connect MT5 accounts, place and manage orders, trade many accounts at once, and read history. Guides and a full API reference. - [Quickstart](https://docs.fxapis.com/quickstart.mdx): From an API key to a filled order, in about five minutes. - [SDKs and examples](https://docs.fxapis.com/sdks.mdx): Official TypeScript and Python SDKs, runnable examples, MCP client configs, integrations and a Next.js starter — all open source on GitHub. - [Signals and click-to-trade](https://docs.fxapis.com/signals.mdx): A complete integration for apps whose members approve each trade: connecting their accounts, instant execution on approval, showing their trades, and closing. ## Guides - [Guides](https://docs.fxapis.com/guides.mdx): Step-by-step guides for the fxapis MetaTrader 5 API: complete programs in Python, Node.js, PHP, C#, Go, Java and Ruby, connecting accounts, multi-account… - [Place MetaTrader 5 orders from Python — no MetaTrader installed](https://docs.fxapis.com/guides/python.mdx): A complete Python program that connects an MT5 account, places a market order with an idempotency key, handles every failure correctly, reads positions and… - [Place MetaTrader 5 orders from Node.js and TypeScript — no MetaTrader installed](https://docs.fxapis.com/guides/nodejs.mdx): A complete TypeScript program for Node.js that connects an MT5 account, places a market order with an idempotency key, retries safely, reads positions and… - [Place MetaTrader 5 orders from PHP — no MetaTrader installed](https://docs.fxapis.com/guides/php.mdx): A complete PHP program using Guzzle that connects an MT5 account, places a market order with an idempotency key, handles SEND_FAILED and ORDER_UNRESOLVED… - [Place MetaTrader 5 orders from C# and .NET — no MetaTrader installed](https://docs.fxapis.com/guides/csharp.mdx): A complete .NET 8 console program using HttpClient that connects an MT5 account, places a market order with an idempotency key, handles every failure… - [Place MetaTrader 5 orders from Go — no MetaTrader installed](https://docs.fxapis.com/guides/go.mdx): A complete Go program using net/http that connects an MT5 account, places a market order with an idempotency key, retries safely, never resends an unresolved… - [Place MetaTrader 5 orders from Java — no MetaTrader installed](https://docs.fxapis.com/guides/java.mdx): A complete Java 17 program using java.net.http.HttpClient and Jackson that connects an MT5 account, places a market order with an idempotency key, handles… - [Place MetaTrader 5 orders from Ruby — no MetaTrader installed](https://docs.fxapis.com/guides/ruby.mdx): A complete Ruby program using Net::HTTP that connects an MT5 account, places a market order with an idempotency key, retries safely, never resends an… - [Use the MetaTrader 5 API on Linux and macOS](https://docs.fxapis.com/guides/linux-macos.mdx): Why the official MetaTrader5 Python package only works on Windows next to a running terminal, the Wine, Docker and VPS workarounds people use on Linux and… - [Connect MT5 accounts by login, password and server](https://docs.fxapis.com/guides/connect-accounts.mdx): How to connect a MetaTrader 5 account to the fxapis API: finding the exact server name, trading versus investor password, two-factor sign-in, handling… - [Broker compatibility](https://docs.fxapis.com/guides/broker-compatibility.mdx): fxapis works with any MetaTrader 5 broker or prop firm, demo or live: what you need to connect an account, how the server search works, what differs from… - [Place one order across many MT5 accounts](https://docs.fxapis.com/guides/multi-account-orders.mdx): Send the same MetaTrader 5 trade to many accounts in one API call — up to 1,000 accounts, within your plan's limit: per-account volumes, barrier policies for… - [Copy trading](https://docs.fxapis.com/guides/copy-trading.mdx): Copy an MT5 master account's trades to follower accounts, managed by fxapis: sizing, symbol mapping, risk limits, an executions log, webhooks, and no code on… - [Idempotent MT5 orders: never double-fill on retry](https://docs.fxapis.com/guides/idempotency.mdx): Why retrying a MetaTrader 5 order can open a second position, and how the fxapis Idempotency-Key prevents it: 24-hour keys, replays, in-flight and reuse… - [Webhooks](https://docs.fxapis.com/guides/webhooks.mdx): Get a signed HTTPS POST when an order fills, a position opens or closes, an account changes state, or a multi-account order finishes. - [TradingView alerts to MT5 — no EA, no VPS](https://docs.fxapis.com/guides/tradingview.mdx): Turn TradingView alerts into MetaTrader 5 orders with a secret webhook URL: create a hook in the console or the API, set up the TradingView alert step by… - [MCP server: connect Claude, ChatGPT and AI agents to MetaTrader 5](https://docs.fxapis.com/guides/mcp.mdx): Connect Claude (claude.ai, Desktop, Code), ChatGPT and other AI agents to your MetaTrader 5 accounts through the fxapis MCP server: sign in, choose read-only… - [Claude plugin and skill](https://docs.fxapis.com/guides/claude-plugin.mdx): The fxapis plugin for Claude Code: the MCP server with sign-in, the trading-mt5-safely skill, status and positions commands, and a hook that confirms every… - [Read-only connector](https://docs.fxapis.com/guides/mcp-read-only.mdx): fxapis insights: a read-only MCP server for your MetaTrader 5 accounts — accounts, figures, positions, orders, deals, quotes and market hours — that never… - [Monitor MT5 trader accounts for prop-firm rules](https://docs.fxapis.com/guides/prop-firms.mdx): Use deals, positions and order history from the fxapis MT5 API to check prop-firm rules such as daily loss and maximum drawdown on your side, with read-only… - [Migrating from MetaApi to fxapis](https://docs.fxapis.com/guides/migrate-from-metaapi.mdx): A concept-by-concept guide for moving an MT5 integration from MetaApi to fxapis: provisioning and deploy versus connect and modes, RPC and streaming versus… ## Reference guides - [Authentication](https://docs.fxapis.com/authentication.mdx): Keys, admin keys, environments, scopes and rotation. - [Accounts](https://docs.fxapis.com/accounts.mdx): Connecting MT5 accounts, keeping them online, and what each state means. - [Trading and history](https://docs.fxapis.com/trading.mdx): Orders, closes, pending orders, multi-account orders, and the history they leave. - [Instruments and symbols](https://docs.fxapis.com/instruments.mdx): Name a market once — XAUUSD, US30, BTCUSD — and trade each account's own broker symbol for it. List any connected broker's symbols, contract specifications… - [Errors](https://docs.fxapis.com/errors.mdx): Every error code, what causes it, and whether to retry. - [Security](https://docs.fxapis.com/security.mdx): How we protect your broker credentials, your keys and your data. - [Changelog](https://docs.fxapis.com/changelog.mdx): What changed in the fxapis API, newest first. ## API reference - [Conventions](https://docs.fxapis.com/api-reference.mdx): Every endpoint of the fxapis API, generated from its OpenAPI description. - Accounts - [Balance, equity and margin](https://docs.fxapis.com/api-reference/accounts/balance-equity-and-margin.mdx): Balance, equity and margin. The account's money as its MetaTrader terminal reports it: balance, equity, margin, free margin, margin level, credit and open… - [Connect an MT5 account](https://docs.fxapis.com/api-reference/accounts/connect-an-mt5-account.mdx): Connect an MT5 account. Stores the account and encrypts its password. - [Delete an account and its history](https://docs.fxapis.com/api-reference/accounts/delete-an-account-and-its-history.mdx): Delete an account and its history. Removes the account for good: its terminal is stopped, its password erased, and the record deleted with its orders, deals… - [Fetch one account](https://docs.fxapis.com/api-reference/accounts/fetch-one-account.mdx): Fetch one account. One connected account: its login, server, label, mode, current state and when it last changed. - [List connected accounts](https://docs.fxapis.com/api-reference/accounts/list-connected-accounts.mdx): List connected accounts. Every account in this workspace, newest first. - [Move an account to another server](https://docs.fxapis.com/api-reference/accounts/move-an-account-to-another-server.mdx): Move an account to another server. For a login refused because it was added under the wrong server name: keeps the stored password and tries it on server… - [Poll lifecycle state](https://docs.fxapis.com/api-reference/accounts/poll-lifecycle-state.mdx): Poll lifecycle state. The endpoint to poll after bringing an account online. - [Replace an account's password](https://docs.fxapis.com/api-reference/accounts/replace-an-accounts-password.mdx): Replace an account's password. Gives a connected account a new trading password — after the member changed it at the broker, or when the account is in… - [Search broker servers](https://docs.fxapis.com/api-reference/accounts/search-broker-servers.mdx): Search broker servers. MT5 servers matching what someone typed — a broker's name (vantage), the start of a server name (JustMarkets-De), with or without… - [What happened to an account](https://docs.fxapis.com/api-reference/accounts/what-happened-to-an-account.mdx): What happened to an account. The account's history in words, newest first: added, logging in, refused by the broker, online, moved to another server, taken… - Lifecycle - [Bring an account online](https://docs.fxapis.com/api-reference/lifecycle/bring-an-account-online.mdx): Bring an account online. Starts connecting the account and returns 202 immediately — the broker login is still in progress. - [Bring several accounts online at once](https://docs.fxapis.com/api-reference/lifecycle/bring-several-accounts-online-at-once.mdx): Bring several accounts online at once. Brings every account listed online and returns 202 with a result for each — the broker logins are still in progress. - [Change how eagerly the account stays connected](https://docs.fxapis.com/api-reference/lifecycle/change-how-eagerly-the-account-stays-connected.mdx): Change how eagerly the account stays connected. always_on: stays connected. - [Disconnect and erase the credential](https://docs.fxapis.com/api-reference/lifecycle/disconnect-and-erase-the-credential.mdx): Disconnect and erase the credential. Takes the account offline and deletes the stored password. - [Restart the connection](https://docs.fxapis.com/api-reference/lifecycle/restart-the-connection.mdx): Restart the connection. For an account that is online but misbehaving — degraded, stale quotes, a stuck sync. - [Take an account offline](https://docs.fxapis.com/api-reference/lifecycle/take-an-account-offline.mdx): Take an account offline. Takes the account offline and keeps it, with its stored password, in standby — ready to be brought online again. - Trading - [Cancel a pending order](https://docs.fxapis.com/api-reference/trading/cancel-a-pending-order.mdx): Cancel a pending order. Removes a pending order that has not triggered. - [Close a position](https://docs.fxapis.com/api-reference/trading/close-a-position.mdx): Close a position. Closes a position in whole, or partly if you send a volume. - [Confirm pending results with the broker now](https://docs.fxapis.com/api-reference/trading/confirm-pending-results-with-the-broker-now.mdx): Confirm pending results with the broker now. Confirms the result of every opening order on this account still in unknown, and brings its deals and positions… - [Margin required, or profit at a price](https://docs.fxapis.com/api-reference/trading/margin-required-or-profit-at-a-price.mdx): Margin required, or profit at a price. Opens nothing and is safe to call freely. - [Move a pending order's price or levels](https://docs.fxapis.com/api-reference/trading/move-a-pending-orders-price-or-levels.mdx): Move a pending order's price or levels. Keeps the order's ticket. - [Move a position's stop loss or take profit](https://docs.fxapis.com/api-reference/trading/move-a-positions-stop-loss-or-take-profit.mdx): Move a position's stop loss or take profit. Send null to remove a level. - [Place a limit, stop or stop-limit order](https://docs.fxapis.com/api-reference/trading/place-a-limit-stop-or-stop-limit-order.mdx): Place a limit, stop or stop-limit order. A success here means placed and waiting, not filled — the broker answers 10008 PLACED and the order is working until… - [Place a market order](https://docs.fxapis.com/api-reference/trading/place-a-market-order.mdx): Place a market order. Sends a market order and waits for the broker's answer. - [Positions on an account](https://docs.fxapis.com/api-reference/trading/positions-on-an-account.mdx): Positions on an account. What we last saw, with observedAt saying when. - History - [An account's full deal history](https://docs.fxapis.com/api-reference/history/an-accounts-full-deal-history.mdx): An account's full deal history. Everything the broker recorded against this account, including deals no order of yours caused — a stop loss firing, a swap… - [Deals produced by one order](https://docs.fxapis.com/api-reference/history/deals-produced-by-one-order.mdx): Deals produced by one order. One order can produce several deals — a partial fill leaves more than one. - [Fetch one order](https://docs.fxapis.com/api-reference/history/fetch-one-order.mdx): Fetch one order. The authoritative record of one order: what was asked for, what the broker returned, and its own return code unmodified. - [List orders](https://docs.fxapis.com/api-reference/history/list-orders.mdx): List orders. Every order this workspace has placed, newest first, across all accounts unless accountId narrows it. - Waves - [Cancel a multi-account order before it is sent](https://docs.fxapis.com/api-reference/waves/cancel-a-multi-account-order-before-it-is-sent.mdx): Cancel a multi-account order before it is sent. Only while nothing has been sent. - [Follow a multi-account order](https://docs.fxapis.com/api-reference/waves/follow-a-multi-account-order.mdx): Follow a multi-account order. Poll this after creating a multi-account order. - [List multi-account orders](https://docs.fxapis.com/api-reference/waves/list-multi-account-orders.mdx): List multi-account orders. Multi-account orders in this workspace, newest first, with each one's state, symbol, side, number of accounts and summary of results. - [Place one trade on many accounts](https://docs.fxapis.com/api-reference/waves/place-one-trade-on-many-accounts.mdx): Place one trade on many accounts. A multi-account order: one trade placed on many accounts at once. - Workspace - [The workspace this credential belongs to](https://docs.fxapis.com/api-reference/workspace/the-workspace-this-credential-belongs-to.mdx): The workspace this credential belongs to. Its plan, and whether trading is switched off. - API keys - [Create a key](https://docs.fxapis.com/api-reference/api-keys/create-a-key.mdx): Create a key. Needs an admin key (fx_admin_…), made by the workspace owner in the console — or a signed-in owner or admin. - [List this workspace's keys](https://docs.fxapis.com/api-reference/api-keys/list-this-workspaces-keys.mdx): List this workspace's keys. Needs an admin key (fx_admin_…), made by the workspace owner in the console — or a signed-in owner or admin. - [Read one key](https://docs.fxapis.com/api-reference/api-keys/read-one-key.mdx): Read one key. Needs an admin key (fx_admin_…), made by the workspace owner in the console — or a signed-in owner or admin. - [Rename or re-scope a key](https://docs.fxapis.com/api-reference/api-keys/rename-or-re-scope-a-key.mdx): Rename or re-scope a key. Needs an admin key (fx_admin_…), made by the workspace owner in the console — or a signed-in owner or admin. - [Revoke a key](https://docs.fxapis.com/api-reference/api-keys/revoke-a-key.mdx): Revoke a key. Needs an admin key (fx_admin_…), made by the workspace owner in the console — or a signed-in owner or admin. - Members - [Change a member's role](https://docs.fxapis.com/api-reference/members/change-a-members-role.mdx): Change a member's role. Console only — not available with API keys. - [Invite someone](https://docs.fxapis.com/api-reference/members/invite-someone.mdx): Invite someone. Console only — not available with API keys. - [List open invitations](https://docs.fxapis.com/api-reference/members/list-open-invitations.mdx): List open invitations. Console only — not available with API keys. - [List this workspace's members](https://docs.fxapis.com/api-reference/members/list-this-workspaces-members.mdx): List this workspace's members. Console only — not available with API keys. - [Remove a member](https://docs.fxapis.com/api-reference/members/remove-a-member.mdx): Remove a member. Console only — not available with API keys. - [Send an invitation again](https://docs.fxapis.com/api-reference/members/send-an-invitation-again.mdx): Send an invitation again. Console only — not available with API keys. - [Withdraw an invitation](https://docs.fxapis.com/api-reference/members/withdraw-an-invitation.mdx): Withdraw an invitation. Console only — not available with API keys. - Billing - [Coins accepted for crypto payment](https://docs.fxapis.com/api-reference/billing/coins-accepted-for-crypto-payment.mdx): Coins accepted for crypto payment. Each with the network it must be sent on. - [Invoices, newest first](https://docs.fxapis.com/api-reference/billing/invoices-newest-first.mdx): Invoices, newest first. Every invoice for this workspace, newest first, with its number, amount, status, provider and any refunds. - [One invoice](https://docs.fxapis.com/api-reference/billing/one-invoice.mdx): One invoice. One invoice by id, with its lines, payment status and refunds. - [The available plans](https://docs.fxapis.com/api-reference/billing/the-available-plans.mdx): The available plans. The plans on offer now: what each includes and what it costs. - [This month's usage and what it would cost](https://docs.fxapis.com/api-reference/billing/this-months-usage-and-what-it-would-cost.mdx): This month's usage and what it would cost. Counted as it happens rather than derived at the end of the month, so this is the same number the invoice will use. - [Usage broken down by day](https://docs.fxapis.com/api-reference/billing/usage-broken-down-by-day.mdx): Usage broken down by day. For a chart, or for checking an invoice line against the day it came from. - [What is paying for the plan](https://docs.fxapis.com/api-reference/billing/what-is-paying-for-the-plan.mdx): What is paying for the plan. The workspace's subscription, if it has one: plan, card or crypto, status, the current paid period and whether it ends at period… - Health - [Liveness](https://docs.fxapis.com/api-reference/health/liveness.mdx): Liveness. Says the fxapis API process is up, for liveness probes and uptime monitors. - [Readiness](https://docs.fxapis.com/api-reference/health/readiness.mdx): Readiness. Says the API can serve traffic right now, including storing and using account credentials. ## Optional - [llms-full.txt](https://docs.fxapis.com/llms-full.txt): Every page of these docs, including the full API reference, in one Markdown file. - [fxapis.com llms.txt](https://fxapis.com/llms.txt): The product, plans and limits. - [OpenAPI document](https://api.fxapis.com/docs/json): The raw OpenAPI 3.1 specification.