# MT5 REST API Documentation Welcome to the MT5 REST API! This API allows you to seamlessly connect your MetaTrader 5 (MT5) accounts, retrieve real-time market data, manage trades, and track account performance using standard HTTP requests. **Base URL:** `https://mt-api.indexnano.com` --- ## 1. Authentication & API Keys All requests to the API must be authenticated using an API Key. **How to get your API Key:** 1. Log in to your user dashboard. 2. Navigate to the **API Access** section. 3. Create a new API key and select your desired **Scope**: - **Read Only:** Best for analytics, dashboards, or trading journals where you only need to pull data. - **Trade and Read:** Required if you plan to execute, modify, or close trades via the API. **How to use the API Key:** Include your API key in the headers of every request using the `Authorization` Bearer format: ```http Authorization: Bearer YOUR_API_KEY ``` --- ## 2. The Connection Flow (Important) To interact with an MT5 account, you must first connect to it. 1. Call the `POST /v1/connect` endpoint with your MT5 credentials. 2. The API will return a unique `connection_id`. 3. For all subsequent requests (like getting your balance or placing a trade), you will pass this `connection_id` into the URL as the `?id=` parameter. --- ## 3. Connection Endpoints ### Connect to MT5 Account Establish a connection to your MT5 broker server. **cURL Request:** ```bash curl -X POST "https://mt-api.indexnano.com/v1/connect" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "account_number": 12345678, "password": "YourPassword123", "server": "Broker-Server-Live" }' ``` **Success Response (200 OK):** ```json { "connection_id": "w4isr666-nk4k-7yn8-xyob-dh3cja1vo83c" } ``` *(Save this `connection_id` to use as `?id=` in all other endpoints!)* ### Check Connection Check connection state and reconnect if the connection is lost. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/CheckConnect?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json "OK" ``` ### Manage Deployment Status Update the deployment status of your connected MT5 account. Setting the status to `false` pauses the account. *(Note: If an account remains paused/undeployed for 7 consecutive days, it will be automatically disconnected).* **cURL Request:** ```bash curl -X POST "https://mt-api.indexnano.com/v1/deployment?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "status": false }' ``` **Success Response (200 OK):** ```json { "success": true, "connection_id": "w4isr666-nk4k-7yn8-xyob-dh3cja1vo83c", "status": false } ``` --- ## 4. Account Information ### Get Account Summary Retrieve core financial metrics like balance, equity, and margin. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/AccountSummary?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json { "balance": 10500.50, "credit": 0.0, "profit": 125.20, "equity": 10625.70, "margin": 250.00, "freeMargin": 10375.70, "marginLevel": 4250.28, "leverage": 500, "currency": "USD" } ``` ### Get Opened Orders List all currently active trades on the account. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/OpenedOrders?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "ticket": 5432109, "symbol": "EURUSD", "orderType": "Buy", "lots": 0.1, "openPrice": 1.08500, "openTime": "2026-06-08T10:30:00", "stopLoss": 1.08000, "takeProfit": 1.09500, "profit": 12.50 } ] ``` ### Get Closed Orders (History) Retrieve the last 100 closed orders for journaling or analytics. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/ClosedOrders?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json { "orders": [ { "ticket": 5432001, "symbol": "EURUSD", "orderType": "Buy", "state": "Filled", "lots": 0.5, "openPrice": 1.08100, "openTime": "2026-06-07T09:15:00", "closePrice": 1.08500, "closeTime": "2026-06-07T14:30:00", "profit": 200.00, "commission": -3.50, "swap": 0.00 } ], "internalDeals": [], "internalOrders": [], "action": 0 } ``` ### Get Closed Orders by Date (Pagination) If an account has more than 100 trades, use this endpoint to fetch closed orders within a specific date range. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/ClosedOrdersPagination?id={connection_id}&from=2026-05-01T00:00:00&to=2026-06-01T00:00:00&sort=CloseTime&ascending=false" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json { "orders": [ { "ticket": 5432001, "symbol": "EURUSD", "orderType": "Buy", "state": "Filled", "lots": 0.5, "openPrice": 1.08100, "openTime": "2026-05-15T09:15:00", "closePrice": 1.08500, "closeTime": "2026-05-15T14:30:00", "profit": 200.00, "commission": -3.50, "swap": 0.00 } ], "internalDeals": [], "internalOrders": [], "action": 0 } ``` --- ## 5. Trading Actions *(Requires the "Trade and Read" API scope)* ### Send an Order Open a new market or pending order. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/OrderSend?id={connection_id}&symbol=EURUSD&operation=Buy&volume=0.1" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Parameters:** - `id` (string): Your `connection_id` (Required) - `symbol` (string): The trading pair (e.g., `EURUSD`) (Required) - `operation` (string): `Buy`, `Sell`, `BuyLimit`, `SellLimit`, `BuyStop`, `SellStop` (Required) - `volume` (number): Lot size (e.g., `0.01`) (Required) - `price` (number): Required for pending orders or Instant Execution - `stoploss` (number): Stop Loss price - `takeprofit` (number): Take Profit price **Success Response (200 OK):** ```json { "ticket": 5432110, "symbol": "EURUSD", "orderType": "Buy", "lots": 0.1, "openPrice": 1.08510, "state": "Filled" } ``` ### Close an Order Close an existing open position. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/OrderClose?id={connection_id}&ticket=5432109" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Parameters:** - `id` (string): Your `connection_id` (Required) - `ticket` (integer): The ticket number of the order to close (Required) - `lots` (number): Volume to close (leave empty to close the full order) - `price` (number): Price (Optional) - `slippage` (integer): Slippage (Optional) **Success Response (200 OK):** ```json { "ticket": 5432109, "symbol": "EURUSD", "orderType": "Buy", "state": "Filled", "lots": 0.1, "openPrice": 1.08500, "openTime": "2026-06-08T10:30:00", "closePrice": 1.08650, "closeTime": "2026-06-08T15:45:00", "profit": 15.00, "commission": -0.70, "swap": 0.00 } ``` ### Modify an Order Modify an existing market or pending order (e.g., update Stop Loss, Take Profit, or entry price for pending orders). **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/OrderModify?id={connection_id}&ticket=5432110&stoploss=1.08000&takeprofit=1.09500" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Parameters:** - `id` (string): Your `connection_id` (Required) - `ticket` (integer): The ticket number of the order to modify (Required) - `stoploss` (number): New Stop Loss price (use `0` to remove) (Required) - `takeprofit` (number): New Take Profit price (use `0` to remove) (Required) - `price` (number): New entry price (for pending orders only) **Success Response (200 OK):** ```json { "ticket": 5432110, "time": "2026-06-09T19:30:00", "openPrice": 1.08510, "stoploss": 1.08000, "takeprofit": 1.09500, "closePrice": 0.0, "tickVolume": 0 } ``` ### Close All Opened Orders Close all currently active market orders on the account. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/CloseOpenedOrders?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "ticket": 5432109, "symbol": "EURUSD", "orderType": "Buy", "state": "Filled", "lots": 0.1, "openPrice": 1.08500, "openTime": "2026-06-08T10:30:00", "closePrice": 1.08650, "closeTime": "2026-06-09T19:35:00", "profit": 15.00, "commission": -0.70, "swap": 0.00 } ] ``` ### Delete All Pending Orders Delete all pending orders (e.g., Limits and Stops) currently waiting to be triggered on the account. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/DeletePendingOrders?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "ticket": 5432115, "symbol": "GBPUSD", "orderType": "BuyLimit", "state": "Cancelled", "lots": 0.2, "openPrice": 1.25000, "openTime": "2026-06-09T10:00:00", "stopLoss": 1.24500, "takeProfit": 1.26000, "profit": 0.00 } ] ``` --- ## 6. Market Data ### Get Available Symbols List of available symbols. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/Symbols?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json { "currency": "USD", "symbolInfo": { "currency": "USD", "description": "Euro vs US Dollar", "digits": 5, "spread": 10, "tickValue": 1.0, "tickSize": 0.00001, "contractSize": 100000.0, "calcMode": "Forex" } } ``` ### Get Latest Quote Latest quote for the specified symbol. *(Note: `symbol` is the trading instrument, e.g., `EURUSD`. You can get a list of available symbols using the `/v1/Symbols` endpoint).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/GetQuote?id={connection_id}&symbol={symbol}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json { "symbol": "EURUSD", "bid": 1.08510, "ask": 1.08520, "time": "2026-06-09T19:10:21", "last": 1.08515, "volume": 100 } ``` ### Get Multiple Quotes Latest quotes for multiple specified symbols. *(Note: Pass multiple symbols by repeating the `symbol` parameter, e.g., `symbol=EURUSD&symbol=GBPUSD`).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/GetQuoteMany?id={connection_id}&symbol=EURUSD&symbol=GBPUSD" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "symbol": "EURUSD", "bid": 1.08510, "ask": 1.08520, "time": "2026-06-09T19:10:21", "last": 1.08515, "volume": 100 }, { "symbol": "GBPUSD", "bid": 1.26500, "ask": 1.26520, "time": "2026-06-09T19:10:21", "last": 1.26510, "volume": 85 } ] ``` ### Get Symbol Parameters Full information about a symbol and its trading group settings (e.g., margin requirements, volume limits, swap rates). **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/SymbolParams?id={connection_id}&symbol={symbol}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json { "symbol": "EURUSD", "symbolInfo": { "currency": "USD", "description": "Euro vs US Dollar", "digits": 5, "spread": 10, "contractSize": 100000.0, "calcMode": "Forex" }, "symbolGroup": { "groupName": "Forex", "tradeMode": "FullAccess", "minVolume": 1000, "maxVolume": 10000000, "volumeStep": 1000, "initialMargin": 100000.0, "swapType": "InPoints", "swapLong": -5.0, "swapShort": 2.0 } } ``` ### Get Server Timezone Server timezone in minutes (e.g., `120` means GMT+2). **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/ServerTimezone?id={connection_id}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json 120 ``` ### Check Trade Session Check if the market is currently open for a specified symbol. **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/IsTradeSession?id={connection_id}&symbol={symbol}" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json true ``` ### Check Multiple Trade Sessions Check if the market is currently open for multiple specified symbols. *(Note: Pass multiple symbols by repeating the `symbols` parameter, e.g., `symbols=EURUSD&symbols=XAUUSD`).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/GetIsTradeSessionMany?id={connection_id}&symbols=EURUSD&symbols=XAUUSD" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ true, false ] ``` ### Get Monthly Price History Price history (OHLC bars) for 30 days starting from the specified date. *(Note: `timeFrame` is in minutes, e.g., `60` for H1, `240` for H4, `1440` for D1).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/PriceHistoryMonth?id={connection_id}&symbol=EURUSD&year=2026&month=5&day=1&timeFrame=240" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "time": "2026-05-01T00:00:00", "openPrice": 1.08000, "highPrice": 1.08500, "lowPrice": 1.07900, "closePrice": 1.08450, "tickVolume": 15000, "spread": 10, "volume": 0 }, { "time": "2026-05-01T04:00:00", "openPrice": 1.08450, "highPrice": 1.08800, "lowPrice": 1.08400, "closePrice": 1.08750, "tickVolume": 12500, "spread": 12, "volume": 0 } ] ``` ### Get Monthly Price History for Multiple Symbols Price history (OHLC bars) for 30 days starting from the specified date for multiple symbols. *(Note: Pass multiple symbols by repeating the `symbol` parameter).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/PriceHistoryMonthMany?id={connection_id}&symbol=EURUSD&symbol=GBPUSD&year=2026&month=5&day=1&timeFrame=240" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "symbol": "EURUSD", "bars": [ { "time": "2026-05-01T00:00:00", "openPrice": 1.08000, "highPrice": 1.08500, "lowPrice": 1.07900, "closePrice": 1.08450, "tickVolume": 15000, "spread": 10, "volume": 0 } ] }, { "symbol": "GBPUSD", "bars": [ { "time": "2026-05-01T00:00:00", "openPrice": 1.26000, "highPrice": 1.26500, "lowPrice": 1.25900, "closePrice": 1.26400, "tickVolume": 18000, "spread": 15, "volume": 0 } ] } ] ``` ### Get Today's Price History Price history (OHLC bars) for the current day. *(Note: `timeFrame` is in minutes, e.g., `15` for M15, `60` for H1).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/PriceHistoryToday?id={connection_id}&symbol=EURUSD&timeFrame=60" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "time": "2026-06-09T00:00:00", "openPrice": 1.08500, "highPrice": 1.08700, "lowPrice": 1.08400, "closePrice": 1.08650, "tickVolume": 5000, "spread": 10, "volume": 0 }, { "time": "2026-06-09T01:00:00", "openPrice": 1.08650, "highPrice": 1.08850, "lowPrice": 1.08600, "closePrice": 1.08800, "tickVolume": 6200, "spread": 11, "volume": 0 } ] ``` ### Get Today's Price History for Multiple Symbols Price history (OHLC bars) for the current day for multiple symbols. *(Note: Pass multiple symbols by repeating the `symbol` parameter).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/PriceHistoryTodayMany?id={connection_id}&symbol=EURUSD&symbol=GBPUSD&timeFrame=60" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "symbol": "EURUSD", "bars": [ { "time": "2026-06-09T00:00:00", "openPrice": 1.08500, "highPrice": 1.08700, "lowPrice": 1.08400, "closePrice": 1.08650, "tickVolume": 5000, "spread": 10, "volume": 0 } ] }, { "symbol": "GBPUSD", "bars": [ { "time": "2026-06-09T00:00:00", "openPrice": 1.26500, "highPrice": 1.26700, "lowPrice": 1.26400, "closePrice": 1.26650, "tickVolume": 4800, "spread": 12, "volume": 0 } ] } ] ``` ### Get Price History by Date Range Price history (OHLC bars) for a specific date range. *(Note: `from` and `to` must be in `yyyy-MM-ddTHH:mm:ss` format. `timeFrame` is in minutes).* **cURL Request:** ```bash curl -X GET "https://mt-api.indexnano.com/v1/PriceHistory?id={connection_id}&symbol=EURUSD&from=2026-01-01T00:00:00&to=2026-01-07T00:00:00&timeFrame=240" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Success Response (200 OK):** ```json [ { "time": "2026-01-01T00:00:00", "openPrice": 1.05000, "highPrice": 1.05500, "lowPrice": 1.04900, "closePrice": 1.05400, "tickVolume": 10000, "spread": 10, "volume": 0 }, { "time": "2026-01-01T04:00:00", "openPrice": 1.05400, "highPrice": 1.05800, "lowPrice": 1.05300, "closePrice": 1.05750, "tickVolume": 12000, "spread": 11, "volume": 0 } ] ``` --- ## Common Error Codes If something goes wrong, the API will return standard HTTP status codes: - **`400 Bad Request`**: Missing parameters (e.g., you forgot to pass `?id=`). - **`401 Unauthorized`**: Your API key is missing, invalid, or revoked. - **`402 Payment Required`**: You have insufficient credits to make this API call. - **`403 Forbidden`**: You are trying to use a `connection_id` that belongs to another user, or the account is paused.