TermlessDocs

Reference

Accounts

The MT5 accounts this server keeps connected around the clock. Each has an id you choose, used in every account URL. A route that needs the broker answers 503 while the account reconnects (it waits up to 2 s first) or while it is turned off. On an account the broker reports as real money, trading is off until an admin sets trade_real: true.

List accounts

GET/api/v1/accounts

Every account the key may see, with its live connection status.

Scope read

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Response 200 Accounts.

A JSON array of Account objects.

  • id string required

    Your id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.

  • label string required

    Display name.

  • login integer required

    MT5 login number.

  • server string required

    Trade server name, for example Pepperstone-Demo.

  • host string required

    Web terminal host the session connects to.

  • port integer required

    Port, usually 443.

  • symbols array of string required

    Symbols kept subscribed for live prices (the watchlist).

  • enabled boolean required

    When false the server keeps the account but does not connect it.

  • created_at integer required

    When the account was added, unix seconds (UTC).

  • tls_name string or null required

    For an IP access point: the name on the gateway's certificate. null for a named host.

  • trade_real boolean required

    Whether trading is allowed when the broker reports this account as real money (account type real or preliminary). Off by default: every route that needs the trade scope then answers 403 real_account. Demo and contest accounts trade either way, and reading is never affected.

  • new_trades_paused boolean required

    New trades are paused (0.6.0): an order that would open something answers 403 trading_paused and is not sent; closing, changing stops and cancelling still work.

  • pinned boolean required

    The gateway's certificate key was pinned by an admin (see the server directory).

  • status object required

    AccountStatus fields
    • connected boolean required

      Whether the session to the broker is up right now.

    • since integer or null required

      Unix seconds (UTC) when the current connection came up. null while disconnected.

    • reconnects integer required

      Automatic reconnects since the server started.

    • ping_ms number or null required

      Last heartbeat round trip in milliseconds. null before the first one.

    • server_build integer or null required

      MT5 build the broker's server reported. null before the first login.

    • last_error string or null required

      Why the last connection attempt failed or the connection dropped. null while connected.

    • subscribed integer required

      Number of symbols with a live price subscription.

    • login_rejected boolean required

      True after the broker refused the login. A refusal within an hour of losing a working connection (a broker restarting refuses logins with code 2 for seconds to minutes) is tried again after 10, 20, 30 and 60 s, then every minute for code 2 until an hour after the loss (0.6.3), then every 5 minutes; any other refusal only every 5 minutes, so a wrong password cannot get the account locked.

    • retry_at integer or null required

      Unix seconds (UTC) of the next connection attempt while disconnected, else null.

  • clock string or null required

    How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds <name>_utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock.

    ny7utcNone

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl
curl -s "$TERMLESS_URL/api/v1/accounts" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.get(f"{base}/accounts", headers=auth)
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

req = urllib.request.Request(f"{base}/accounts", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts`, {
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 200
[
  {
    "id": "pepperstone-12345678",
    "label": "Pepperstone demo",
    "login": 12345678,
    "server": "Pepperstone-Demo",
    "host": "mt5-demo01.pepperstone.com",
    "port": 443,
    "symbols": [
      "XAUUSD",
      "EURUSD"
    ],
    "enabled": true,
    "created_at": 1790881742,
    "tls_name": null,
    "trade_real": false,
    "new_trades_paused": false,
    "clock": null,
    "pinned": false,
    "status": {
      "connected": true,
      "since": 1790968298,
      "reconnects": 0,
      "ping_ms": 14.2,
      "server_build": 6090,
      "last_error": null,
      "subscribed": 2,
      "login_rejected": false,
      "retry_at": null
    }
  }
]

Add an account

POST/api/v1/accounts

Saves the account and starts connecting it in the background, so status.connected is false at first. Poll GET /api/v1/accounts/{id} until it connects; a refused login shows in status.last_error and status.login_rejected. host is looked up from server (this install's directory, then the built-in list) when omitted; 400 if it cannot be found. 409 if the id, or the same login on the same host, exists. trade_real: true allows trading if the broker reports the account as real money (off by default).

Scope admin

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Request body AccountCreate

  • id string

    Your id for the account: a-z, 0-9 and -, up to 48 characters. Defaults to the server's first word and the login, for example pepperstone-12345678.

  • label string

    Display name. Defaults to the server and login.

  • login integer required

    MT5 login number (a numeric string also works).

  • password string required write-only

    MT5 password (master or investor). Write-only.

  • server string required

    Trade server name exactly as the broker spells it.

  • host string

    Web terminal host. Looked up from server (this install's directory, then the built-in list) when omitted; 400 if it cannot be found.

  • port integer

    Port. Defaults to the directory's port, else 443.

  • tls_name string

    For an IP access point: the name on its certificate. Defaults to the directory's for that host.

  • symbols array of string

    Symbols to keep subscribed (the watchlist).

  • enabled boolean default true

    false saves the account without connecting it.

  • trade_real boolean default false

    Allow trading when the broker reports the account as real money. Off by default; demo and contest accounts trade either way.

  • clock string or null

    How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds <name>_utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock.

    ny7utcNone

Response 201 Saved. Connecting in the background.

A Account object.

  • id string required

    Your id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.

  • label string required

    Display name.

  • login integer required

    MT5 login number.

  • server string required

    Trade server name, for example Pepperstone-Demo.

  • host string required

    Web terminal host the session connects to.

  • port integer required

    Port, usually 443.

  • symbols array of string required

    Symbols kept subscribed for live prices (the watchlist).

  • enabled boolean required

    When false the server keeps the account but does not connect it.

  • created_at integer required

    When the account was added, unix seconds (UTC).

  • tls_name string or null required

    For an IP access point: the name on the gateway's certificate. null for a named host.

  • trade_real boolean required

    Whether trading is allowed when the broker reports this account as real money (account type real or preliminary). Off by default: every route that needs the trade scope then answers 403 real_account. Demo and contest accounts trade either way, and reading is never affected.

  • new_trades_paused boolean required

    New trades are paused (0.6.0): an order that would open something answers 403 trading_paused and is not sent; closing, changing stops and cancelling still work.

  • pinned boolean required

    The gateway's certificate key was pinned by an admin (see the server directory).

  • status object required

    AccountStatus fields
    • connected boolean required

      Whether the session to the broker is up right now.

    • since integer or null required

      Unix seconds (UTC) when the current connection came up. null while disconnected.

    • reconnects integer required

      Automatic reconnects since the server started.

    • ping_ms number or null required

      Last heartbeat round trip in milliseconds. null before the first one.

    • server_build integer or null required

      MT5 build the broker's server reported. null before the first login.

    • last_error string or null required

      Why the last connection attempt failed or the connection dropped. null while connected.

    • subscribed integer required

      Number of symbols with a live price subscription.

    • login_rejected boolean required

      True after the broker refused the login. A refusal within an hour of losing a working connection (a broker restarting refuses logins with code 2 for seconds to minutes) is tried again after 10, 20, 30 and 60 s, then every minute for code 2 until an hour after the loss (0.6.3), then every 5 minutes; any other refusal only every 5 minutes, so a wrong password cannot get the account locked.

    • retry_at integer or null required

      Unix seconds (UTC) of the next connection attempt while disconnected, else null.

  • clock string or null required

    How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds <name>_utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock.

    ny7utcNone

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 409 conflict The thing already exists or the state does not allow it. On a trade route with an Idempotency-Key: the key was already used with a different body or query string, or the first request with it did not finish (cut off, or the server restarted; check positions and orders, then use a new key), or it is still running after 30 s.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl
curl -s -X POST "$TERMLESS_URL/api/v1/accounts" \
  -H "Authorization: Bearer $TERMLESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"label": "Pepperstone demo", "login": 12345678, "password": "your MT5 password", "server": "Pepperstone-Demo", "symbols": ["XAUUSD", "EURUSD"]}'
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.post(f"{base}/accounts", headers=auth, json={
        "label": "Pepperstone demo",
        "login": 12345678,
        "password": "your MT5 password",
        "server": "Pepperstone-Demo",
        "symbols": [
            "XAUUSD",
            "EURUSD"
        ]
    })
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

payload = {
    "label": "Pepperstone demo",
    "login": 12345678,
    "password": "your MT5 password",
    "server": "Pepperstone-Demo",
    "symbols": [
        "XAUUSD",
        "EURUSD"
    ]
}

headers["Content-Type"] = "application/json"
req = urllib.request.Request(f"{base}/accounts", data=json.dumps(payload).encode(), headers=headers, method="POST")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "label": "Pepperstone demo",
    "login": 12345678,
    "password": "your MT5 password",
    "server": "Pepperstone-Demo",
    "symbols": [
      "XAUUSD",
      "EURUSD"
    ]
  })
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 201
{
  "id": "pepperstone-12345678",
  "label": "Pepperstone demo",
  "login": 12345678,
  "server": "Pepperstone-Demo",
  "host": "mt5-demo01.pepperstone.com",
  "port": 443,
  "symbols": [
    "XAUUSD",
    "EURUSD"
  ],
  "enabled": true,
  "created_at": 1790981179,
  "tls_name": null,
  "trade_real": false,
  "new_trades_paused": false,
  "clock": null,
  "pinned": false,
  "status": {
    "connected": false,
    "since": null,
    "reconnects": 0,
    "ping_ms": null,
    "server_build": null,
    "last_error": null,
    "subscribed": 0,
    "login_rejected": false,
    "retry_at": null
  }
}

Get an account

GET/api/v1/accounts/{id}

One account with its live connection status.

Scope read

Path parameters

  • id string required

    Account id.

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Response 200 The account.

A Account object.

  • id string required

    Your id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.

  • label string required

    Display name.

  • login integer required

    MT5 login number.

  • server string required

    Trade server name, for example Pepperstone-Demo.

  • host string required

    Web terminal host the session connects to.

  • port integer required

    Port, usually 443.

  • symbols array of string required

    Symbols kept subscribed for live prices (the watchlist).

  • enabled boolean required

    When false the server keeps the account but does not connect it.

  • created_at integer required

    When the account was added, unix seconds (UTC).

  • tls_name string or null required

    For an IP access point: the name on the gateway's certificate. null for a named host.

  • trade_real boolean required

    Whether trading is allowed when the broker reports this account as real money (account type real or preliminary). Off by default: every route that needs the trade scope then answers 403 real_account. Demo and contest accounts trade either way, and reading is never affected.

  • new_trades_paused boolean required

    New trades are paused (0.6.0): an order that would open something answers 403 trading_paused and is not sent; closing, changing stops and cancelling still work.

  • pinned boolean required

    The gateway's certificate key was pinned by an admin (see the server directory).

  • status object required

    AccountStatus fields
    • connected boolean required

      Whether the session to the broker is up right now.

    • since integer or null required

      Unix seconds (UTC) when the current connection came up. null while disconnected.

    • reconnects integer required

      Automatic reconnects since the server started.

    • ping_ms number or null required

      Last heartbeat round trip in milliseconds. null before the first one.

    • server_build integer or null required

      MT5 build the broker's server reported. null before the first login.

    • last_error string or null required

      Why the last connection attempt failed or the connection dropped. null while connected.

    • subscribed integer required

      Number of symbols with a live price subscription.

    • login_rejected boolean required

      True after the broker refused the login. A refusal within an hour of losing a working connection (a broker restarting refuses logins with code 2 for seconds to minutes) is tried again after 10, 20, 30 and 60 s, then every minute for code 2 until an hour after the loss (0.6.3), then every 5 minutes; any other refusal only every 5 minutes, so a wrong password cannot get the account locked.

    • retry_at integer or null required

      Unix seconds (UTC) of the next connection attempt while disconnected, else null.

  • clock string or null required

    How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds <name>_utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock.

    ny7utcNone

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl
curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.get(f"{base}/accounts/pepperstone-12345678", headers=auth)
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

req = urllib.request.Request(f"{base}/accounts/pepperstone-12345678", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts/pepperstone-12345678`, {
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 200
{
  "id": "pepperstone-12345678",
  "label": "Pepperstone demo",
  "login": 12345678,
  "server": "Pepperstone-Demo",
  "host": "mt5-demo01.pepperstone.com",
  "port": 443,
  "symbols": [
    "XAUUSD",
    "EURUSD"
  ],
  "enabled": true,
  "created_at": 1790881742,
  "tls_name": null,
  "trade_real": false,
  "new_trades_paused": false,
  "clock": null,
  "pinned": false,
  "status": {
    "connected": true,
    "since": 1790968298,
    "reconnects": 0,
    "ping_ms": 14.2,
    "server_build": 6090,
    "last_error": null,
    "subscribed": 2,
    "login_rejected": false,
    "retry_at": null
  }
}

Update an account

PATCH/api/v1/accounts/{id}

Change the label, watchlist or login details, or turn it off with enabled: false (logs out and parks it). Changing password, server, host, port or tls_name logs in again; symbols replaces the watchlist and starts streaming new ones without logging in again. trade_real allows (true) or stops (false) trading when the broker reports the account as real money; it takes effect at once.

Scope admin

Path parameters

  • id string required

    Account id.

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Request body AccountPatch

Send only the fields you want to change.

  • label string

    Display name.

  • password string write-only

    New MT5 password. Write-only. Logs in again.

  • server string

    Trade server name. Logs in again; the host is looked up when host is not sent.

  • host string

    Web terminal host. Logs in again.

  • port integer

    Port. Logs in again.

  • tls_name string

    The name on the gateway's certificate, for an IP access point; an empty string clears it. Logs in again.

  • symbols array of string

    Replaces the whole watchlist and starts streaming new symbols without logging in again.

  • enabled boolean

    false logs out and parks the account, true connects it again.

  • trade_real boolean

    true allows trading when the broker reports the account as real money; false turns it off again. Takes effect at once, without logging in again.

  • new_trades_paused boolean

    true refuses orders that would open something (403 trading_paused, not sent) while closing, changing stops and cancelling still work; false lets them through again (0.6.0). At once, no new login.

  • clock string or null

    How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds <name>_utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock. null takes it away; at once, open streams too.

    ny7utcNone

Response 200 The updated account.

A Account object.

  • id string required

    Your id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.

  • label string required

    Display name.

  • login integer required

    MT5 login number.

  • server string required

    Trade server name, for example Pepperstone-Demo.

  • host string required

    Web terminal host the session connects to.

  • port integer required

    Port, usually 443.

  • symbols array of string required

    Symbols kept subscribed for live prices (the watchlist).

  • enabled boolean required

    When false the server keeps the account but does not connect it.

  • created_at integer required

    When the account was added, unix seconds (UTC).

  • tls_name string or null required

    For an IP access point: the name on the gateway's certificate. null for a named host.

  • trade_real boolean required

    Whether trading is allowed when the broker reports this account as real money (account type real or preliminary). Off by default: every route that needs the trade scope then answers 403 real_account. Demo and contest accounts trade either way, and reading is never affected.

  • new_trades_paused boolean required

    New trades are paused (0.6.0): an order that would open something answers 403 trading_paused and is not sent; closing, changing stops and cancelling still work.

  • pinned boolean required

    The gateway's certificate key was pinned by an admin (see the server directory).

  • status object required

    AccountStatus fields
    • connected boolean required

      Whether the session to the broker is up right now.

    • since integer or null required

      Unix seconds (UTC) when the current connection came up. null while disconnected.

    • reconnects integer required

      Automatic reconnects since the server started.

    • ping_ms number or null required

      Last heartbeat round trip in milliseconds. null before the first one.

    • server_build integer or null required

      MT5 build the broker's server reported. null before the first login.

    • last_error string or null required

      Why the last connection attempt failed or the connection dropped. null while connected.

    • subscribed integer required

      Number of symbols with a live price subscription.

    • login_rejected boolean required

      True after the broker refused the login. A refusal within an hour of losing a working connection (a broker restarting refuses logins with code 2 for seconds to minutes) is tried again after 10, 20, 30 and 60 s, then every minute for code 2 until an hour after the loss (0.6.3), then every 5 minutes; any other refusal only every 5 minutes, so a wrong password cannot get the account locked.

    • retry_at integer or null required

      Unix seconds (UTC) of the next connection attempt while disconnected, else null.

  • clock string or null required

    How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds <name>_utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock.

    ny7utcNone

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl
curl -s -X PATCH "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \
  -H "Authorization: Bearer $TERMLESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"symbols": ["XAUUSD", "EURUSD", "GBPUSD"]}'
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.patch(f"{base}/accounts/pepperstone-12345678", headers=auth, json={
        "symbols": [
            "XAUUSD",
            "EURUSD",
            "GBPUSD"
        ]
    })
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

payload = {
    "symbols": [
        "XAUUSD",
        "EURUSD",
        "GBPUSD"
    ]
}

headers["Content-Type"] = "application/json"
req = urllib.request.Request(f"{base}/accounts/pepperstone-12345678", data=json.dumps(payload).encode(), headers=headers, method="PATCH")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts/pepperstone-12345678`, {
  method: "PATCH",
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "symbols": [
      "XAUUSD",
      "EURUSD",
      "GBPUSD"
    ]
  })
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 200
{
  "id": "pepperstone-12345678",
  "label": "Pepperstone demo",
  "login": 12345678,
  "server": "Pepperstone-Demo",
  "host": "mt5-demo01.pepperstone.com",
  "port": 443,
  "symbols": [
    "XAUUSD",
    "EURUSD",
    "GBPUSD"
  ],
  "enabled": true,
  "created_at": 1790881742,
  "tls_name": null,
  "trade_real": false,
  "new_trades_paused": false,
  "clock": null,
  "pinned": false,
  "status": {
    "connected": true,
    "since": 1790968298,
    "reconnects": 0,
    "ping_ms": 14.2,
    "server_build": 6090,
    "last_error": null,
    "subscribed": 2,
    "login_rejected": false,
    "retry_at": null
  }
}

Remove an account

DELETE/api/v1/accounts/{id}

Logs out and forgets the account. Positions at the broker are not touched.

Scope admin

Path parameters

  • id string required

    Account id.

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Response 204 Removed.

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl
curl -s -X DELETE "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.delete(f"{base}/accounts/pepperstone-12345678", headers=auth)
r.raise_for_status()  # 204, no body
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

req = urllib.request.Request(f"{base}/accounts/pepperstone-12345678", data=None, headers=headers, method="DELETE")
with urllib.request.urlopen(req, timeout=35) as r:
    print(r.status)  # 204, no body
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts/pepperstone-12345678`, {
  method: "DELETE",
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
// 204: no body
Response
HTTP/1.1 204 No Content

Get balance and margin

GET/api/v1/accounts/{id}/summary

Balance, equity, margin and the counts of positions and orders, the same numbers MT5 shows. Profit, equity and margin are live. server_offset turns this account's market and trade times into UTC. Never waits on the broker once the account record has been read: a copy older than 5 s is answered at once and read again in the background (balance and credit follow the trade pushes either way).

Scope read

Path parameters

  • id string required

    Account id.

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Response 200 Account summary.

A Summary object.

  • login integer required

    MT5 login number.

  • name string required

    Account holder name at the broker.

  • server string required

    Trade server name.

  • company string required

    Broker company name.

  • currency string required

    Deposit currency.

  • leverage integer required

    Leverage, for example 200 for 1:200.

  • balance number required

    Balance without open positions.

  • credit number required

    Credit from the broker.

  • profit number required

    Floating profit of open positions, live.

  • equity number required

    balance + credit + profit, live.

  • margin number required

    Margin in use, live.

  • margin_free number required

    equity - margin.

  • margin_level number required

    equity / margin x 100, in percent. 0 with no margin in use.

  • margin_so_call number required

    Margin call level.

  • margin_so_so number required

    Stop out level.

  • trade_allowed boolean required

    Whether the broker allows trading on this account.

  • demo boolean required

    True for a demo account.

  • hedging boolean required

    True for a hedging account, false for netting.

  • server_offset integer required

    Trade server clock, in seconds east of UTC. Subtract it from any market or trade time to get UTC. From the account record, read again at least hourly, and checked against live ticks (a tick's server time minus its arrival, to the quarter hour): when they disagree the ticks win while a tick agreed in the last 10 minutes, then the record. It is the offset now; times from before the broker's last summer-time switch were stamped with the old one.

  • positions integer required

    Open positions.

  • orders integer required

    Pending orders.

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
  • 502 broker_error The broker's server failed or answered with something unexpected.
  • 503 disconnected busy stopping disconnected: the account is not connected (it reconnects on its own; the route waits up to 2 s first) or is turned off; retry with backoff (on a trade route it was never sent: a trade's Idempotency-Key is let go). busy: requests of one command go to the broker one at a time per account, and this one waited its whole turn (20 s) behind earlier ones and was never sent, so sending it again is safe (a trade's Idempotency-Key is let go, so the retry with the same key is sent).
  • 504 timeout unconfirmed timeout: the broker did not answer a request that was sent (one broker call is given 20 s), or the whole request ran past 30 s (TERMLESS_REQUEST_TIMEOUT). unconfirmed (trades, since 0.6.0): the broker took the trade but its final result did not come, so it may have been carried out; the body adds request_id, retcode (null or the last in-between state, 10001 to 10003) and retcode_text. Retry with the same Idempotency-Key: the stored answer is replayed (the real result once it came late), so the broker never sees it twice; then check positions and orders.
curl
curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/summary" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.get(f"{base}/accounts/pepperstone-12345678/summary", headers=auth)
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

req = urllib.request.Request(f"{base}/accounts/pepperstone-12345678/summary", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts/pepperstone-12345678/summary`, {
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 200
{
  "login": 12345678,
  "name": "Demo Trader",
  "server": "Pepperstone-Demo",
  "company": "Pepperstone Group Limited",
  "currency": "USD",
  "leverage": 200,
  "balance": 10412.58,
  "credit": 0.0,
  "profit": 238.11,
  "equity": 10650.69,
  "margin": 878.93,
  "margin_free": 9771.76,
  "margin_level": 1211.78,
  "margin_so_call": 100.0,
  "margin_so_so": 50.0,
  "trade_allowed": true,
  "demo": true,
  "hedging": true,
  "server_offset": 10800,
  "positions": 3,
  "orders": 2
}

Get every account's summary

GET/api/v1/overview

The summary of every enabled account the caller may read, read together, in one request (0.7.0): what the dashboard's Overview asks every 4 s. An account with no summary (not connected) carries an error instead.

Scope read

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Response 200 Summaries.

A Overview object.

  • accounts array of OverviewAccount required

    Every enabled account the caller may read.

    OverviewAccount fields
    • id string required

      Account id.

    • summary object

      Summary fields
      • login integer required

        MT5 login number.

      • name string required

        Account holder name at the broker.

      • server string required

        Trade server name.

      • company string required

        Broker company name.

      • currency string required

        Deposit currency.

      • leverage integer required

        Leverage, for example 200 for 1:200.

      • balance number required

        Balance without open positions.

      • credit number required

        Credit from the broker.

      • profit number required

        Floating profit of open positions, live.

      • equity number required

        balance + credit + profit, live.

      • margin number required

        Margin in use, live.

      • margin_free number required

        equity - margin.

      • margin_level number required

        equity / margin x 100, in percent. 0 with no margin in use.

      • margin_so_call number required

        Margin call level.

      • margin_so_so number required

        Stop out level.

      • trade_allowed boolean required

        Whether the broker allows trading on this account.

      • demo boolean required

        True for a demo account.

      • hedging boolean required

        True for a hedging account, false for netting.

      • server_offset integer required

        Trade server clock, in seconds east of UTC. Subtract it from any market or trade time to get UTC. From the account record, read again at least hourly, and checked against live ticks (a tick's server time minus its arrival, to the quarter hour): when they disagree the ticks win while a tick agreed in the last 10 minutes, then the record. It is the offset now; times from before the broker's last summer-time switch were stamped with the old one.

      • positions integer required

        Open positions.

      • orders integer required

        Pending orders.

    • error object

      Fields
      • code string required

        Error code.

      • message string required

        What went wrong.

      • status integer required

        The HTTP status the summary route would answer.

Errors

  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl
curl -s "$TERMLESS_URL/api/v1/overview" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.get(f"{base}/overview", headers=auth)
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

req = urllib.request.Request(f"{base}/overview", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/overview`, {
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 200
{
  "accounts": [
    {
      "id": "pepperstone-12345678",
      "summary": {
        "login": 12345678,
        "name": "Demo Trader",
        "server": "Pepperstone-Demo",
        "company": "Pepperstone Group Limited",
        "currency": "USD",
        "leverage": 200,
        "balance": 10412.58,
        "credit": 0.0,
        "profit": 238.11,
        "equity": 10650.69,
        "margin": 878.93,
        "margin_free": 9771.76,
        "margin_level": 1211.78,
        "margin_so_call": 100.0,
        "margin_so_so": 50.0,
        "trade_allowed": true,
        "demo": true,
        "hedging": true,
        "server_offset": 10800,
        "positions": 3,
        "orders": 2
      }
    }
  ]
}

Check the account is ready

GET/api/v1/accounts/{id}/ready

A bot's pre-flight check before it sends an order: ready_to_read and ready_to_trade, the reasons (a machine code, what it blocks: read, trade or none, and a plain message), and the facts behind them: the link (connected, since, ping, the last frame's age), the login, the server build and whether Termless has been checked against it, the trade side (the broker allows trading, investor login, demo, the real-money switch, whether the caller's key can trade), each watched or asked symbol's last tick age and whether its market is open (from the symbol's quote sessions; a closed market is never stale), and frames that could not be decoded in the last hour. Answered from memory, with no broker round trip, so it is cheap enough to call before every order. A not-ready account is a 200 with the reasons, not an error.

Scope read

Path parameters

  • id string required

    Account id.

Query parameters

  • symbols string

    The symbols you are about to trade, comma-separated, at most 50 (more is 400). Their market must be open for ready_to_trade (an old or missing price is a note, price_stale or no_price, not a block; each one's age is in prices); an unknown one is the reason unknown_symbol.

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Response 200 The check.

A Ready object.

  • account string required

    Account id.

  • checked_at integer required

    When this was worked out, unix milliseconds (UTC).

  • ready_to_read boolean required

    Reads of this account work now: false when any reason blocks read.

  • ready_to_trade boolean required

    An order sent now can reach the broker and be accepted on the account side: false when any reason blocks read or trade.

  • reasons array of ReadyReason required

    Why not, and warnings. Empty when all is well.

    ReadyReason fields
    • code string required

      What it is. Blocks read: turned_off, disconnected, login_rejected. Blocks trade (an order would certainly fail): trade_disabled, investor_login, real_account_blocked, key_read_only, account_not_loaded, market_closed, unknown_symbol. Notes: price_stale and no_price (an asked symbol's price is old or missing; since 0.5.1 a note, since a market order still fills at the broker's price), build_unverified, undecoded_frames, link_quiet, connected_recently.

      turned_offdisconnectedlogin_rejectedtrade_disabledinvestor_loginreal_account_blockedkey_read_onlyaccount_not_loadedmarket_closedprice_staleno_priceunknown_symbolbuild_unverifiedundecoded_frameslink_quietping_overdueconnected_recentlynew_trades_paused
    • blocks string required

      read (reading and trading both fail), trade, or none (a note).

      readtradenone
    • message string required

      One plain sentence for people and logs.

    • symbol string

      The symbol, on the per-symbol reasons only.

  • link object required

    Fields
    • connected boolean required

      Whether the session's link to the broker is up.

    • since integer or null required

      When the current connection came up, unix seconds (UTC); null while disconnected.

    • connected_for_s integer or null required

      Seconds since then; null while disconnected.

    • ping_ms number or null required

      Last heartbeat round trip; null while disconnected.

    • reconnects integer required

      Reconnects since the session started.

    • last_frame_age_ms integer or null required

      Milliseconds since the last frame of any kind from the broker; null while disconnected.

    • ping_pending_ms integer or null required

      How long the oldest unanswered ping has waited, in milliseconds; null when none is waiting (0.6.0). Past 2,000 the reasons carry ping_overdue.

    • pings_missed integer required

      Pings missed in a row; the link is cut at two (0.6.0).

    • last_error string or null required

      The last error, only while disconnected.

    • retry_at integer or null required

      The next connection attempt, unix seconds (UTC), only while disconnected.

  • login object required

    Fields
    • logged_in boolean required

      The session holds a logged-in link.

    • rejected boolean required

      The last refusal was of the login details.

  • server object required

    Fields
    • build integer or null required

      The broker's server build; null before the first connect.

    • build_verified boolean required

      A build Termless's decoding has been checked against live.

    • verified_builds array of integer required

      The builds checked against live (health::VERIFIED_BUILDS).

  • trading object required

    Fields
    • allowed boolean required

      Every check on the trade side passes.

    • account_trade_allowed boolean required

      The broker allows trading on the account.

    • investor boolean required

      Logged in with the investor (read-only) password.

    • demo boolean required

      A demo or contest account.

    • real_money string or null required

      demo, allowed (real money with trade_real on), blocked (real money with it off); null before the account record is read.

      demoallowedblockedNone
    • key_can_trade boolean required

      The caller's scope is trade or admin.

  • prices array of ReadyPrice required

    The watched symbols, then the asked ones that are not watched.

    ReadyPrice fields
    • symbol string required

      Symbol name.

    • watched boolean required

      On the account's watchlist (streamed).

    • asked boolean required

      Named in symbols=.

    • last_tick_age_ms integer or null required

      Milliseconds since its last tick; null before the first.

    • market_open boolean or null required

      Whether its market is open now; null when that cannot be told.

    • market_source string or null required

      sessions (the spec's quote sessions, on the broker's clock), heuristic (no spec loaded yet: the forex week, Sunday 17:00 to Friday 17:00 New York time), or null.

      sessionsheuristicNone
    • fresh boolean required

      A tick came within 120 s, or the market is closed (a closed market is never stale). Information: nothing is blocked on it (since 0.5.1).

  • undecoded_last_hour integer required

    Frames from this account the client could not decode in the last hour.

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl
curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/ready?symbols=XAUUSD,EURUSD" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.get(f"{base}/accounts/pepperstone-12345678/ready", headers=auth, params={"symbols": "XAUUSD,EURUSD"})
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

req = urllib.request.Request(f"{base}/accounts/pepperstone-12345678/ready?symbols=XAUUSD,EURUSD", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts/pepperstone-12345678/ready?symbols=XAUUSD,EURUSD`, {
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 200
{
  "account": "pepperstone-12345678",
  "checked_at": 1792300000123,
  "ready_to_read": true,
  "ready_to_trade": true,
  "reasons": [],
  "link": {
    "connected": true,
    "since": 1792290000,
    "connected_for_s": 10000,
    "ping_ms": 12.4,
    "reconnects": 2,
    "last_frame_age_ms": 800,
    "ping_pending_ms": null,
    "pings_missed": 0,
    "last_error": null,
    "retry_at": null
  },
  "login": {
    "logged_in": true,
    "rejected": false
  },
  "server": {
    "build": 6090,
    "build_verified": true,
    "verified_builds": [
      6090,
      6182,
      6230
    ]
  },
  "trading": {
    "allowed": true,
    "account_trade_allowed": true,
    "investor": false,
    "demo": true,
    "real_money": "demo",
    "key_can_trade": true
  },
  "prices": [
    {
      "symbol": "XAUUSD",
      "watched": true,
      "asked": true,
      "last_tick_age_ms": 812,
      "market_open": true,
      "market_source": "sessions",
      "fresh": true
    },
    {
      "symbol": "EURUSD",
      "watched": true,
      "asked": false,
      "last_tick_age_ms": 240,
      "market_open": true,
      "market_source": "sessions",
      "fresh": true
    }
  ],
  "undecoded_last_hour": 0
}

Get account statistics

GET/api/v1/accounts/{id}/stats

The trades closed in a range (0.7.0): trades, wins and losses, win rate, profit factor, average win and loss, the largest drawdown of the closed results and the profit of each day (the forex day from 17:00 New York with a clock rule, else the server's date). An answer is kept while the account's trade log has not moved, at most 5 minutes.

Scope read

Path parameters

  • id string required

    Account id.

Query parameters

  • from integer

    Range start, unix seconds, server time.

  • to integer

    Range end; defaults to now.

  • days integer min 1, max 366

    Instead of from: this many days before to (1 to 366; default 30).

Headers

  • X-Request-Id string

    Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.

Response 200 Statistics.

A Stats object.

  • trades integer required

    Positions with a closing deal in the range.

  • wins integer required

    Trades that made money.

  • losses integer required

    Trades that lost money.

  • win_rate number or null required

    Percent of trades won; null with no trades.

  • profit_factor number or null required

    What the wins made over what the losses lost; null with no losses.

  • avg_win number or null required

    Per winning trade.

  • avg_loss number or null required

    Per losing trade (negative).

  • gross_profit number required

    What the wins made.

  • gross_loss number required

    What the losses lost (negative).

  • net number required

    The trades' results together.

  • max_drawdown number required

    The largest fall of the closed results from a high, in time order (positive).

  • by_day array of StatsDay required

    Each day with a closed trade, oldest first.

    StatsDay fields
    • day string required

      YYYY-MM-DD: the forex day under a clock rule, else the server's date.

    • profit number required

      What the trades closed that day made.

    • trades integer required

      Trades closed that day.

  • from integer required

    Range start, unix seconds, server time.

  • to integer required

    Range end.

  • from_utc integer

    Range start in UTC; only with the account's clock rule (0.7.1).

  • to_utc integer

    Range end in UTC; only with the account's clock rule (0.7.1).

  • from_utc_ambiguous boolean

    true when from falls in New York's repeated autumn hour (0.7.1).

  • to_utc_ambiguous boolean

    true when to falls in New York's repeated autumn hour (0.7.1).

  • currency string or null required

    The account's currency.

Errors

  • 400 bad_request A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; key= is accepted anywhere).
  • 401 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
  • 502 broker_error The broker's server failed or answered with something unexpected.
  • 503 disconnected busy stopping disconnected: the account is not connected (it reconnects on its own; the route waits up to 2 s first) or is turned off; retry with backoff (on a trade route it was never sent: a trade's Idempotency-Key is let go). busy: requests of one command go to the broker one at a time per account, and this one waited its whole turn (20 s) behind earlier ones and was never sent, so sending it again is safe (a trade's Idempotency-Key is let go, so the retry with the same key is sent).
  • 504 timeout unconfirmed timeout: the broker did not answer a request that was sent (one broker call is given 20 s), or the whole request ran past 30 s (TERMLESS_REQUEST_TIMEOUT). unconfirmed (trades, since 0.6.0): the broker took the trade but its final result did not come, so it may have been carried out; the body adds request_id, retcode (null or the last in-between state, 10001 to 10003) and retcode_text. Retry with the same Idempotency-Key: the stored answer is replayed (the real result once it came late), so the broker never sees it twice; then check positions and orders.
curl
curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/stats?days=30" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os
import requests

base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

r = requests.get(f"{base}/accounts/pepperstone-12345678/stats", headers=auth, params={"days": 30})
r.raise_for_status()
print(r.json())
Python, stdlib
import json
import os
import urllib.error
import urllib.request

base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}

req = urllib.request.Request(f"{base}/accounts/pepperstone-12345678/stats?days=30", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
    print(json.load(r))
JavaScript
const base = `${process.env.TERMLESS_URL}/api/v1`;

const res = await fetch(`${base}/accounts/pepperstone-12345678/stats?days=30`, {
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());
Response 200
{
  "trades": 5,
  "wins": 3,
  "losses": 2,
  "win_rate": 60.0,
  "profit_factor": 2.02,
  "avg_win": 29.0,
  "avg_loss": -21.5,
  "gross_profit": 87.0,
  "gross_loss": -43.0,
  "net": 44.0,
  "max_drawdown": 32.0,
  "by_day": [
    {
      "day": "2026-11-30",
      "profit": 16.0,
      "trades": 2
    },
    {
      "day": "2026-12-01",
      "profit": 28.0,
      "trades": 3
    }
  ],
  "from": 1793780000,
  "to": 1796372000,
  "currency": "USD"
}