# API2Trade > REST and WebSocket API for MetaTrader 4 and MetaTrader 5 trading accounts. Connect an account with the Account API, then trade, read history and stream prices through that account's own Trading API. - Use API v2. API v1 (Legacy) is switched off on 31 December 2026. - Authenticate every REST request with the header `X-API-Key`; the WebSocket takes `?api_key=` instead. - Account API base URL: `https://api.api2trade.com`. Each connected account's Trading API: `https://api.api2trade.com/v2/{account_id}/`. - The same endpoints work for MT4 and MT5 accounts. - Every page below is plain Markdown. All of API v2 in one file: https://docs.api2trade.com/llms-full.txt ## Docs - [Introduction](https://docs.api2trade.com/docs.mdx): Api2Trade API Documentation - [Quickstart](https://docs.api2trade.com/docs/quickstart.mdx): From an API key to live quotes in four steps. - [Authentication](https://docs.api2trade.com/docs/authentication.mdx): One API key for everything, and where each API expects it. - [AI coding agents](https://docs.api2trade.com/docs/ai-agents.mdx): Give Claude Code, Cursor, Copilot and other coding agents the docs in a form they read well. - [Migrating to API v2](https://docs.api2trade.com/docs/migrate-to-v2.mdx): The Legacy API is switched off on 31 December 2026. What changes, and how to move an account. ## API v2 - [Account API: Accounts](https://docs.api2trade.com/docs/api-v2/account-api/accounts.mdx): Connect, inspect and disconnect MetaTrader accounts. Each connected account then gets its own trading API, documented separately. - [Trading API: System](https://docs.api2trade.com/docs/api-v2/trading-api/system.mdx): Is the connection alive, connected to the broker, and logged in? - [Trading API: Account](https://docs.api2trade.com/docs/api-v2/trading-api/account.mdx): Account state, open trades, deal history. - [Trading API: Market](https://docs.api2trade.com/docs/api-v2/trading-api/market.mdx): Quotes, OHLC bars, symbol contract specs. - [Trading API: Trading](https://docs.api2trade.com/docs/api-v2/trading-api/trading.mdx): Margin/profit calculation and placing, modifying and closing orders. - [MT4 vs MT5](https://docs.api2trade.com/docs/api-v2/platforms.mdx): The trading API is the same on both platforms, with a few differences worth knowing. - [WebSocket](https://docs.api2trade.com/docs/api-v2/websocket.mdx): Live prices, bars, account changes, pending orders and trade events over one socket. - [Errors](https://docs.api2trade.com/docs/api-v2/errors.mdx): What the API returns when something is wrong, and which failures are worth retrying. ## OpenAPI - [Account API](https://api.api2trade.com/v2/openapi.json): connect, list and remove accounts — the live spec - [Trading API (MT5)](https://docs.api2trade.com/openapi/trading-api-mt5.json): one account's endpoints - [Trading API (MT4)](https://docs.api2trade.com/openapi/trading-api-mt4.json): the same endpoints; only the commission fields of SymbolInfo differ ## Optional - [Full API v2 documentation](https://docs.api2trade.com/llms-full.txt): every page above in one file, reference included API v1 (Legacy) — switched off on 31 December 2026; only for maintaining existing code. - [MetaTrader 5: Connection](https://docs.api2trade.com/docs/api-v1/metatrader-5-api/connection.mdx): Connect and disconnect functions - [MetaTrader 5: Account](https://docs.api2trade.com/docs/api-v1/metatrader-5-api/account.mdx): Account functions - [MetaTrader 5: Trading](https://docs.api2trade.com/docs/api-v1/metatrader-5-api/trading.mdx): Trading functionallity - [MetaTrader 5: Order History](https://docs.api2trade.com/docs/api-v1/metatrader-5-api/orderhistory.mdx): Order history functions - [MetaTrader 5: Quote History](https://docs.api2trade.com/docs/api-v1/metatrader-5-api/quotehistory.mdx): OHLC history - [MetaTrader 5: Trade Stats](https://docs.api2trade.com/docs/api-v1/metatrader-5-api/tradestats.mdx): Trading statistic - [MetaTrader 5: Service](https://docs.api2trade.com/docs/api-v1/metatrader-5-api/service.mdx): Service functions not related to account - [MetaTrader 4: Connection](https://docs.api2trade.com/docs/api-v1/metatrader-4-api/connection.mdx): Connection handling - [MetaTrader 4: Account](https://docs.api2trade.com/docs/api-v1/metatrader-4-api/account.mdx): Account functions - [MetaTrader 4: Trading](https://docs.api2trade.com/docs/api-v1/metatrader-4-api/trading.mdx): Connection handling - [MetaTrader 4: Order History](https://docs.api2trade.com/docs/api-v1/metatrader-4-api/orderhistory.mdx): Trading history - [MetaTrader 4: Trade Stats](https://docs.api2trade.com/docs/api-v1/metatrader-4-api/tradestats.mdx): Trading statistic - [MetaTrader 4: Service](https://docs.api2trade.com/docs/api-v1/metatrader-4-api/service.mdx): Service functions not related to account