Skip to content

Get an MT5 account balance from an API

Updated 2026-11-11

Send GET https://api.fivesocket.com/v1/accounts/{accountId}/balance with a FiveSocket API key. The response holds balance, equity, margin, free margin, currency and leverage as read from a live MT5 session, and observedAt shows when. Any language that can send an HTTPS request works. Examples for curl, Python and JavaScript are below.

7-day free trial. Paid plans start at $9.99 a month. See pricing

curl

List your linked accounts with GET https://api.fivesocket.com/v1/accounts to find the account ID, then read the balance.

curl -H "Authorization: Bearer $FIVESOCKET_KEY" \
  https://api.fivesocket.com/v1/accounts/acc_7Hq2Xv/balance

Python

import os
import time
import requests

base = "https://api.fivesocket.com/v1"
headers = {"Authorization": f"Bearer {os.environ['FIVESOCKET_KEY']}"}

accounts = requests.get(f"{base}/accounts", headers=headers, timeout=30)
accounts.raise_for_status()
account_id = accounts.json()["data"][0]["id"]

while True:
    response = requests.get(f"{base}/accounts/{account_id}/balance", headers=headers, timeout=60)
    if response.status_code != 202:
        break
    time.sleep(int(response.headers.get("Retry-After", "5")))

response.raise_for_status()
account = response.json()
print(account["balance"], account["equity"], account["currency"])

JavaScript

This runs in Node.js 18 or later, Bun or Deno as an ES module.

const base = "https://api.fivesocket.com/v1"
const headers = { Authorization: `Bearer ${process.env.FIVESOCKET_KEY}` }

async function balance(accountId) {
    while (true) {
        const response = await fetch(`${base}/accounts/${accountId}/balance`, { headers })
        if (response.status === 202) {
            const seconds = Number(response.headers.get("retry-after") ?? "5")
            await new Promise((resolve) => setTimeout(resolve, seconds * 1000))
            continue
        }
        if (!response.ok) {
            throw new Error(`FiveSocket returned ${response.status}`)
        }
        return await response.json()
    }
}

const account = await balance("acc_7Hq2Xv")
console.log(account.balance, account.equity, account.currency)

What comes back

Balance fields

balance, equity, margin, marginFree, credit, currency, leverage

Money values are decimal strings in the account currency, so parse them with a decimal type. The response also carries accountId, login, server, observedAt and latencyMs.

A 202 response with the code account_warming means MT5 is still logging in. Wait for the Retry-After seconds and send the same request again. The examples above do that.

Frequently asked questions

Is the balance real time?
Each successful read comes from a live MT5 session at the moment you ask. FiveSocket does not store balances.
Can I read the balance with an investor password?
Yes. Reads work with the MT5 investor password, and MT5 then refuses any trade on that link.
Can I get a push when the balance changes?
No. There are no webhooks or streams, so poll within your plan's rate limit.
How much does it cost?
Plans start at $9.99 a month for one MT5 account. Link your MT5 account and try it free, no card: 24 hours or 100 calls, whichever comes first. Then a 7-day free trial, card required. Cancel anytime. The trial includes one connected MT5 account.

Try it on your own account.

Link your MT5 account and try it free, no card: 24 hours or 100 calls, whichever comes first. Then a 7-day free trial, card required. Cancel anytime. The trial includes one connected MT5 account. Cancel before the trial ends and you are not charged. A demo account is the safest place to start.

7-day free trial. Paid plans start at $9.99 a month. See pricing