MT4 and MT5 Account Data as JSON: a Free API for Your Trading Statistics
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
| Route | What it is | Where it stops |
|---|---|---|
| A script or Expert Advisor in MQL | Code inside the terminal that writes files or sends web requests | You write and maintain the exporter yourself, and it runs only while the terminal runs |
The MetaTrader5 Python package | The official package: Python talks to an MT5 terminal on the same Windows machine | MT5 only, and the terminal has to be open. You get raw deals: growth, drawdown and the rest are yours to compute |
| A report export | An HTML or Excel file saved from the history tab | A file, frozen when you save it, laid out for people to read |
| Broker-side APIs | The interfaces brokers use to manage their servers | They 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.
| Endpoint | What it returns | API key |
|---|---|---|
GET /api/v1/accounts | Your accounts and portfolios, each with its headline figures | Yes |
GET /api/v1/accounts/{slug} | One account, with the sections you ask for | Not needed if the account is published |
GET /api/v1/accounts/{slug}/trades | Closed trades, newest first | Yes |
GET /api/v1/accounts/{slug}/positions | Open positions and pending orders | Yes |
GET /api/v1/search/accounts | Search among published accounts | Not 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"
import requests
account = requests.get(
"https://showmytrades.com/api/v1/accounts/YOUR-ACCOUNT-SLUG",
params={"include": "equity_curve,monthly"},
timeout=15,
).json()
print(account["balance"], account["performance"]["twr_percent"])
for day in account["equity_curve"]["daily_performance"][-5:]:
print(day["date"], day["twr_percent"], day["drawdown"])
const response = await fetch(
'https://showmytrades.com/api/v1/accounts/YOUR-ACCOUNT-SLUG?include=equity_curve,monthly'
)
const account = await response.json()
console.log(account.balance, account.performance.twr_percent)
for (const month of account.monthly.monthly_performance) {
console.log(month.date, month.monthly_percent)
}
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
| Field | Meaning |
|---|---|
platform, broker, server, leverage, currency | Where the account lives. Every money figure is in currency |
demo | true for a demo account. It comes from the broker's data |
balance, equity | The closed balance, and the balance including open positions |
performance.twr_percent | Time-weighted growth in percent: deposits and withdrawals do not move it |
performance.absolute_gain_percent | Profit against the money deposited |
performance.max_drawdown_percent | The deepest fall from a peak, as a positive number |
performance.deposits, performance.withdrawals | Money moved in and out |
verified | Whether the track record and the control of the account are verified |
history_cut_at | A date, if the owner removed the history before it. If you show the account, say so |
attribution | The 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.
| Section | What you get |
|---|---|
equity_curve | One row per trading day: growth so far, balance, equity, drawdown, number of trades. Plus every deposit and withdrawal with its date |
monthly | Returns per month and per year, and ready figures for today, this week, this month and this year |
by_symbol | Trades, wins, profit and pips per instrument, longs and shorts apart |
by_magic_number | The same per magic number: on MetaTrader that means results per Expert Advisor |
advanced | Profit factor, expectancy, Sharpe ratio, average win and loss, best and worst trade, trades by hour and by weekday |
twr | The 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
- Percentages are in percent.
5.96means 5.96%. - Drawdown has two signs. In the summary
max_drawdown_percentis positive. In the daily rowsdrawdownis negative or zero. - Times are UTC, in ISO 8601.
- A hidden section is
null. The owner of an account can hide parts of it. Ask for what you need and handlenull. - 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
429with aRetry-Afterheader: 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.
🔗 Related Guides
- A self-updating trading chart on your website: the complete code, server and page
- Your trading results in Google Sheets: the same API from a spreadsheet
- Time-weighted return explained: what
twr_percentmeasures - Magic numbers and strategy labels: how results are split per Expert Advisor
- A free economic calendar API for trading bots: the other free API, for news filters
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.
How to Put a Self-Updating Trading Chart on Your Website With a Free API
Building your own site and want the chart of your MT4, MT5, cTrader or TradeLocker account on it, updating by itself? One free API request returns the data as JSON. Complete code for the server and the page.
Your Trading Results in Google Sheets, Updated Automatically
Get the balance, growth, drawdown, daily curve and monthly returns of your MT4, MT5, cTrader or TradeLocker account into Google Sheets with a short script and a free API. No CSV exports: the sheet refreshes on a timer.