Automation·

MT4 and MT5 Account Data as JSON: a Free API for Your Trading Statistics

MetaTrader has no web API for your own account. How to read the balance, equity, growth, drawdown, monthly returns, closed trades and open positions of an MT4 or MT5 account as JSON, with a free REST API. Examples in cURL, Python and JavaScript.

Sooner or later you want the numbers of your MetaTrader account inside a program: a chart on your website, a weekly report, a dashboard, a message in a chat. And you find that MetaTrader was built to trade on a screen, not to serve data to other software.

This guide lists what MetaTrader offers on its own, where each option stops, and a shorter road: a free REST API that returns your MT4 or MT5 account as JSON, statistics included.

🧰 What MetaTrader Offers on Its Own

RouteWhat it isWhere it stops
A script or Expert Advisor in MQLCode inside the terminal that writes files or sends web requestsYou write and maintain the exporter yourself, and it runs only while the terminal runs
The MetaTrader5 Python packageThe official package: Python talks to an MT5 terminal on the same Windows machineMT5 only, and the terminal has to be open. You get raw deals: growth, drawdown and the rest are yours to compute
A report exportAn HTML or Excel file saved from the history tabA file, frozen when you save it, laid out for people to read
Broker-side APIsThe interfaces brokers use to manage their serversThey are for brokers, not for the holder of an account

None of these is a web address that answers "how is the account doing" in JSON. That is the missing piece.

🔓 The Short Road: a REST API Over Your Connected Account

Connect the account to ShowMyTrades once. The connection is read-only, with the investor password or with our small Expert Advisor: the steps are in how to show your MT4 or MT5 results on your website. Your history is imported, the statistics are computed, and from then on they follow the account.

After that, the account is a few addresses away.

EndpointWhat it returnsAPI key
GET /api/v1/accountsYour accounts and portfolios, each with its headline figuresYes
GET /api/v1/accounts/{slug}One account, with the sections you ask forNot needed if the account is published
GET /api/v1/accounts/{slug}/tradesClosed trades, newest firstYes
GET /api/v1/accounts/{slug}/positionsOpen positions and pending ordersYes
GET /api/v1/search/accountsSearch among published accountsNot needed

The base address is https://showmytrades.com. The API is read-only: it cannot place or close a trade, and it cannot change an account.

📡 The First Request

For a published account there is nothing to set up. {slug} is the last part of the address of the account page.

curl "https://showmytrades.com/api/v1/accounts/YOUR-ACCOUNT-SLUG?include=equity_curve,monthly"

For a private account, and for the list of your accounts, create a free Developer API Key under Settings in the dashboard and send it with the request:

curl "https://showmytrades.com/api/v1/accounts" \
  -H "Authorization: Bearer smt_live_YOUR_KEY"

The key is a secret. Use it from a server or from a script of your own, never in a web page.

📊 What the Account Object Contains

FieldMeaning
platform, broker, server, leverage, currencyWhere the account lives. Every money figure is in currency
demotrue for a demo account. It comes from the broker's data
balance, equityThe closed balance, and the balance including open positions
performance.twr_percentTime-weighted growth in percent: deposits and withdrawals do not move it
performance.absolute_gain_percentProfit against the money deposited
performance.max_drawdown_percentThe deepest fall from a peak, as a positive number
performance.deposits, performance.withdrawalsMoney moved in and out
verifiedWhether the track record and the control of the account are verified
history_cut_atA date, if the owner removed the history before it. If you show the account, say so
attributionThe line to show next to the data, with its link

🧩 Sections on Request

The account object is the summary. The rest comes with include, in a single request.

SectionWhat you get
equity_curveOne row per trading day: growth so far, balance, equity, drawdown, number of trades. Plus every deposit and withdrawal with its date
monthlyReturns per month and per year, and ready figures for today, this week, this month and this year
by_symbolTrades, wins, profit and pips per instrument, longs and shorts apart
by_magic_numberThe same per magic number: on MetaTrader that means results per Expert Advisor
advancedProfit factor, expectancy, Sharpe ratio, average win and loss, best and worst trade, trades by hour and by weekday
twrThe growth after every single closed trade

These are the figures you would otherwise compute from raw deals. Time-weighted growth in particular is easy to get wrong when the account has deposits and withdrawals.

📜 Trades and Positions

Closed trades come in pages of 20. Go on while has_more is true.

import os
import requests

BASE = "https://showmytrades.com/api/v1/accounts/YOUR-ACCOUNT-SLUG"
HEADERS = {"Authorization": f"Bearer {os.environ['SHOWMYTRADES_KEY']}"}

trades, page = [], 1
while True:
    answer = requests.get(f"{BASE}/trades", headers=HEADERS,
                          params={"from": "2026-11-01", "page": page}, timeout=15).json()
    trades += answer["data"]
    if not answer["pagination"]["has_more"]:
        break
    page += 1

print(len(trades), "trades, net result", round(sum(t["net_profit"] for t in trades), 2))

Each trade has ticket, symbol, side, volume, the open and close prices and times, profit, commission, swap, net_profit, comment and magic_number. Add up net_profit, not profit: the first already includes commission and swap.

/positions returns what is on the account now: open positions and pending orders, up to 200 per page, with ?type=open or ?type=pending to split them.

⚙️ Five Conventions That Save You an Hour

  1. Percentages are in percent. 5.96 means 5.96%.
  2. Drawdown has two signs. In the summary max_drawdown_percent is positive. In the daily rows drawdown is negative or zero.
  3. Times are UTC, in ISO 8601.
  4. A hidden section is null. The owner of an account can hide parts of it. Ask for what you need and handle null.
  5. Limits are per minute. 30 requests with a free key, 120 on the Pro and Ultra plans, 20 per IP address without a key. Over the limit you get a 429 with a Retry-After header: wait that long.

The full reference, field by field, is in the API documentation.

🤝 What the API Asks in Return

It is free. On the free plan, wherever you show the data, put one visible line next to it: Data from ShowMyTrades, with a link. Every response carries the text and the address in its attribution field. On the Pro and Ultra plans the line is optional.

🤖 The Same Data for an AI Assistant

Claude, ChatGPT and other assistants can read the same data through the MCP server, at https://showmytrades.com/api/v1/mcp. Published accounts need no key there either. You can then ask in plain words: "draw the monthly returns of my account" or "which symbols lost money this quarter".

❓ FAQ

Does it work for MT4 as well as MT5? Yes. Both connect the same way and return the same format. So do cTrader and TradeLocker.

Does my terminal have to stay open? Not with the investor password: nothing runs on your side. With the Expert Advisor the data flows while your terminal runs.

Can the API open or close trades? No. It only reads. The connection to the account is read-only too.

How fresh is the data? The statistics follow the account as trades close, and /positions shows what is open now. For a chart or a report, asking every few minutes is more than enough.

Can I read an account that is not mine? Yes, if its owner published it: pass its slug to the same endpoint. Private accounts of other people do not exist for the API.

What does it cost? Nothing. Connecting accounts, the API and the MCP server are free. The paid plans raise the limits and make the line "Data from ShowMyTrades" optional.


Connect your MetaTrader account free and make the first request. If you only want to look at the format first, call the API on any published account.