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
/api/v1/accountsEvery account the key may see, with its live connection status.
Headers
X-Request-IdstringYour 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.
idstring requiredYour id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.
labelstring requiredDisplay name.
logininteger requiredMT5 login number.
serverstring requiredTrade server name, for example Pepperstone-Demo.
hoststring requiredWeb terminal host the session connects to.
portinteger requiredPort, usually 443.
symbolsarray of string requiredSymbols kept subscribed for live prices (the watchlist).
enabledboolean requiredWhen false the server keeps the account but does not connect it.
created_atinteger requiredWhen the account was added, unix seconds (UTC).
tls_namestring or null requiredFor an IP access point: the name on the gateway's certificate. null for a named host.
trade_realboolean requiredWhether 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_pausedboolean requiredNew 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.
pinnedboolean requiredThe gateway's certificate key was pinned by an admin (see the server directory).
statusobject requiredAccountStatus fields
connectedboolean requiredWhether the session to the broker is up right now.
sinceinteger or null requiredUnix seconds (UTC) when the current connection came up. null while disconnected.
reconnectsinteger requiredAutomatic reconnects since the server started.
ping_msnumber or null requiredLast heartbeat round trip in milliseconds. null before the first one.
server_buildinteger or null requiredMT5 build the broker's server reported. null before the first login.
last_errorstring or null requiredWhy the last connection attempt failed or the connection dropped. null while connected.
subscribedinteger requiredNumber of symbols with a live price subscription.
login_rejectedboolean requiredTrue 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_atinteger or null requiredUnix seconds (UTC) of the next connection attempt while disconnected, else null.
clockstring or null requiredHow 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_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/accounts" \
-H "Authorization: Bearer $TERMLESS_KEY"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())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))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());[
{
"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
/api/v1/accountsSaves 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).
Headers
X-Request-IdstringYour 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
idstringYour 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.
labelstringDisplay name. Defaults to the server and login.
logininteger requiredMT5 login number (a numeric string also works).
passwordstring required write-onlyMT5 password (master or investor). Write-only.
serverstring requiredTrade server name exactly as the broker spells it.
hoststringWeb terminal host. Looked up from server (this install's directory, then the built-in list) when omitted; 400 if it cannot be found.
portintegerPort. Defaults to the directory's port, else 443.
tls_namestringFor an IP access point: the name on its certificate. Defaults to the directory's for that host.
symbolsarray of stringSymbols to keep subscribed (the watchlist).
enabledboolean defaulttruefalse saves the account without connecting it.
trade_realboolean defaultfalseAllow trading when the broker reports the account as real money. Off by default; demo and contest accounts trade either way.
clockstring or nullHow 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.
idstring requiredYour id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.
labelstring requiredDisplay name.
logininteger requiredMT5 login number.
serverstring requiredTrade server name, for example Pepperstone-Demo.
hoststring requiredWeb terminal host the session connects to.
portinteger requiredPort, usually 443.
symbolsarray of string requiredSymbols kept subscribed for live prices (the watchlist).
enabledboolean requiredWhen false the server keeps the account but does not connect it.
created_atinteger requiredWhen the account was added, unix seconds (UTC).
tls_namestring or null requiredFor an IP access point: the name on the gateway's certificate. null for a named host.
trade_realboolean requiredWhether 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_pausedboolean requiredNew 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.
pinnedboolean requiredThe gateway's certificate key was pinned by an admin (see the server directory).
statusobject requiredAccountStatus fields
connectedboolean requiredWhether the session to the broker is up right now.
sinceinteger or null requiredUnix seconds (UTC) when the current connection came up. null while disconnected.
reconnectsinteger requiredAutomatic reconnects since the server started.
ping_msnumber or null requiredLast heartbeat round trip in milliseconds. null before the first one.
server_buildinteger or null requiredMT5 build the broker's server reported. null before the first login.
last_errorstring or null requiredWhy the last connection attempt failed or the connection dropped. null while connected.
subscribedinteger requiredNumber of symbols with a live price subscription.
login_rejectedboolean requiredTrue 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_atinteger or null requiredUnix seconds (UTC) of the next connection attempt while disconnected, else null.
clockstring or null requiredHow 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_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 409
conflictThe 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_requestsThis 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 -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"]}'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())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))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());{
"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
/api/v1/accounts/{id}One account with its live connection status.
Path parameters
idstring requiredAccount id.
Headers
X-Request-IdstringYour 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.
idstring requiredYour id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.
labelstring requiredDisplay name.
logininteger requiredMT5 login number.
serverstring requiredTrade server name, for example Pepperstone-Demo.
hoststring requiredWeb terminal host the session connects to.
portinteger requiredPort, usually 443.
symbolsarray of string requiredSymbols kept subscribed for live prices (the watchlist).
enabledboolean requiredWhen false the server keeps the account but does not connect it.
created_atinteger requiredWhen the account was added, unix seconds (UTC).
tls_namestring or null requiredFor an IP access point: the name on the gateway's certificate. null for a named host.
trade_realboolean requiredWhether 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_pausedboolean requiredNew 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.
pinnedboolean requiredThe gateway's certificate key was pinned by an admin (see the server directory).
statusobject requiredAccountStatus fields
connectedboolean requiredWhether the session to the broker is up right now.
sinceinteger or null requiredUnix seconds (UTC) when the current connection came up. null while disconnected.
reconnectsinteger requiredAutomatic reconnects since the server started.
ping_msnumber or null requiredLast heartbeat round trip in milliseconds. null before the first one.
server_buildinteger or null requiredMT5 build the broker's server reported. null before the first login.
last_errorstring or null requiredWhy the last connection attempt failed or the connection dropped. null while connected.
subscribedinteger requiredNumber of symbols with a live price subscription.
login_rejectedboolean requiredTrue 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_atinteger or null requiredUnix seconds (UTC) of the next connection attempt while disconnected, else null.
clockstring or null requiredHow 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_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \
-H "Authorization: Bearer $TERMLESS_KEY"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())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))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());{
"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
/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.
Path parameters
idstring requiredAccount id.
Headers
X-Request-IdstringYour 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.
labelstringDisplay name.
passwordstring write-onlyNew MT5 password. Write-only. Logs in again.
serverstringTrade server name. Logs in again; the host is looked up when host is not sent.
hoststringWeb terminal host. Logs in again.
portintegerPort. Logs in again.
tls_namestringThe name on the gateway's certificate, for an IP access point; an empty string clears it. Logs in again.
symbolsarray of stringReplaces the whole watchlist and starts streaming new symbols without logging in again.
enabledbooleanfalse logs out and parks the account, true connects it again.
trade_realbooleantrue 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_pausedbooleantrue 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.
clockstring or nullHow 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.
idstring requiredYour id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters.
labelstring requiredDisplay name.
logininteger requiredMT5 login number.
serverstring requiredTrade server name, for example Pepperstone-Demo.
hoststring requiredWeb terminal host the session connects to.
portinteger requiredPort, usually 443.
symbolsarray of string requiredSymbols kept subscribed for live prices (the watchlist).
enabledboolean requiredWhen false the server keeps the account but does not connect it.
created_atinteger requiredWhen the account was added, unix seconds (UTC).
tls_namestring or null requiredFor an IP access point: the name on the gateway's certificate. null for a named host.
trade_realboolean requiredWhether 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_pausedboolean requiredNew 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.
pinnedboolean requiredThe gateway's certificate key was pinned by an admin (see the server directory).
statusobject requiredAccountStatus fields
connectedboolean requiredWhether the session to the broker is up right now.
sinceinteger or null requiredUnix seconds (UTC) when the current connection came up. null while disconnected.
reconnectsinteger requiredAutomatic reconnects since the server started.
ping_msnumber or null requiredLast heartbeat round trip in milliseconds. null before the first one.
server_buildinteger or null requiredMT5 build the broker's server reported. null before the first login.
last_errorstring or null requiredWhy the last connection attempt failed or the connection dropped. null while connected.
subscribedinteger requiredNumber of symbols with a live price subscription.
login_rejectedboolean requiredTrue 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_atinteger or null requiredUnix seconds (UTC) of the next connection attempt while disconnected, else null.
clockstring or null requiredHow 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_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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 -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"]}'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())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))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());{
"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
/api/v1/accounts/{id}Logs out and forgets the account. Positions at the broker are not touched.
Path parameters
idstring requiredAccount id.
Headers
X-Request-IdstringYour 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_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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 -s -X DELETE "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \
-H "Authorization: Bearer $TERMLESS_KEY"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 bodyimport 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 bodyconst 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 bodyHTTP/1.1 204 No ContentGet balance and margin
/api/v1/accounts/{id}/summaryBalance, 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).
Path parameters
idstring requiredAccount id.
Headers
X-Request-IdstringYour 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.
logininteger requiredMT5 login number.
namestring requiredAccount holder name at the broker.
serverstring requiredTrade server name.
companystring requiredBroker company name.
currencystring requiredDeposit currency.
leverageinteger requiredLeverage, for example 200 for 1:200.
balancenumber requiredBalance without open positions.
creditnumber requiredCredit from the broker.
profitnumber requiredFloating profit of open positions, live.
equitynumber requiredbalance + credit + profit, live.
marginnumber requiredMargin in use, live.
margin_freenumber requiredequity - margin.
margin_levelnumber requiredequity / margin x 100, in percent. 0 with no margin in use.
margin_so_callnumber requiredMargin call level.
margin_so_sonumber requiredStop out level.
trade_allowedboolean requiredWhether the broker allows trading on this account.
demoboolean requiredTrue for a demo account.
hedgingboolean requiredTrue for a hedging account, false for netting.
server_offsetinteger requiredTrade 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.
positionsinteger requiredOpen positions.
ordersinteger requiredPending orders.
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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_errorThe broker's server failed or answered with something unexpected. - 503
disconnectedbusystoppingdisconnected: 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
timeoutunconfirmedtimeout: 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 -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/summary" \
-H "Authorization: Bearer $TERMLESS_KEY"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())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))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());{
"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
/api/v1/overviewThe 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.
Headers
X-Request-IdstringYour 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.
accountsarray of OverviewAccount requiredEvery enabled account the caller may read.
OverviewAccount fields
idstring requiredAccount id.
summaryobjectSummary fields
logininteger requiredMT5 login number.
namestring requiredAccount holder name at the broker.
serverstring requiredTrade server name.
companystring requiredBroker company name.
currencystring requiredDeposit currency.
leverageinteger requiredLeverage, for example 200 for 1:200.
balancenumber requiredBalance without open positions.
creditnumber requiredCredit from the broker.
profitnumber requiredFloating profit of open positions, live.
equitynumber requiredbalance + credit + profit, live.
marginnumber requiredMargin in use, live.
margin_freenumber requiredequity - margin.
margin_levelnumber requiredequity / margin x 100, in percent. 0 with no margin in use.
margin_so_callnumber requiredMargin call level.
margin_so_sonumber requiredStop out level.
trade_allowedboolean requiredWhether the broker allows trading on this account.
demoboolean requiredTrue for a demo account.
hedgingboolean requiredTrue for a hedging account, false for netting.
server_offsetinteger requiredTrade 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.
positionsinteger requiredOpen positions.
ordersinteger requiredPending orders.
errorobjectFields
codestring requiredError code.
messagestring requiredWhat went wrong.
statusinteger requiredThe HTTP status the summary route would answer.
Errors
- 401
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/overview" \
-H "Authorization: Bearer $TERMLESS_KEY"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())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))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());{
"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
/api/v1/accounts/{id}/readyA 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.
Path parameters
idstring requiredAccount id.
Query parameters
symbolsstringThe 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-IdstringYour 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.
accountstring requiredAccount id.
checked_atinteger requiredWhen this was worked out, unix milliseconds (UTC).
ready_to_readboolean requiredReads of this account work now: false when any reason blocks read.
ready_to_tradeboolean requiredAn order sent now can reach the broker and be accepted on the account side: false when any reason blocks read or trade.
reasonsarray of ReadyReason requiredWhy not, and warnings. Empty when all is well.
ReadyReason fields
codestring requiredWhat 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_pausedblocksstring requiredread (reading and trading both fail), trade, or none (a note).
readtradenonemessagestring requiredOne plain sentence for people and logs.
symbolstringThe symbol, on the per-symbol reasons only.
linkobject requiredFields
connectedboolean requiredWhether the session's link to the broker is up.
sinceinteger or null requiredWhen the current connection came up, unix seconds (UTC); null while disconnected.
connected_for_sinteger or null requiredSeconds since then; null while disconnected.
ping_msnumber or null requiredLast heartbeat round trip; null while disconnected.
reconnectsinteger requiredReconnects since the session started.
last_frame_age_msinteger or null requiredMilliseconds since the last frame of any kind from the broker; null while disconnected.
ping_pending_msinteger or null requiredHow 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_missedinteger requiredPings missed in a row; the link is cut at two (0.6.0).
last_errorstring or null requiredThe last error, only while disconnected.
retry_atinteger or null requiredThe next connection attempt, unix seconds (UTC), only while disconnected.
loginobject requiredFields
logged_inboolean requiredThe session holds a logged-in link.
rejectedboolean requiredThe last refusal was of the login details.
serverobject requiredFields
buildinteger or null requiredThe broker's server build; null before the first connect.
build_verifiedboolean requiredA build Termless's decoding has been checked against live.
verified_buildsarray of integer requiredThe builds checked against live (health::VERIFIED_BUILDS).
tradingobject requiredFields
allowedboolean requiredEvery check on the trade side passes.
account_trade_allowedboolean requiredThe broker allows trading on the account.
investorboolean requiredLogged in with the investor (read-only) password.
demoboolean requiredA demo or contest account.
real_moneystring or null requireddemo, allowed (real money with trade_real on), blocked (real money with it off); null before the account record is read.
demoallowedblockedNonekey_can_tradeboolean requiredThe caller's scope is trade or admin.
pricesarray of ReadyPrice requiredThe watched symbols, then the asked ones that are not watched.
ReadyPrice fields
symbolstring requiredSymbol name.
watchedboolean requiredOn the account's watchlist (streamed).
askedboolean requiredNamed in symbols=.
last_tick_age_msinteger or null requiredMilliseconds since its last tick; null before the first.
market_openboolean or null requiredWhether its market is open now; null when that cannot be told.
market_sourcestring or null requiredsessions (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.
sessionsheuristicNonefreshboolean requiredA 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_hourinteger requiredFrames from this account the client could not decode in the last hour.
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/ready?symbols=XAUUSD,EURUSD" \
-H "Authorization: Bearer $TERMLESS_KEY"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())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))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());{
"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
/api/v1/accounts/{id}/statsThe 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.
Path parameters
idstring requiredAccount id.
Query parameters
fromintegerRange start, unix seconds, server time.
tointegerRange end; defaults to now.
daysinteger min 1, max 366Instead of from: this many days before to (1 to 366; default 30).
Headers
X-Request-IdstringYour 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.
tradesinteger requiredPositions with a closing deal in the range.
winsinteger requiredTrades that made money.
lossesinteger requiredTrades that lost money.
win_ratenumber or null requiredPercent of trades won; null with no trades.
profit_factornumber or null requiredWhat the wins made over what the losses lost; null with no losses.
avg_winnumber or null requiredPer winning trade.
avg_lossnumber or null requiredPer losing trade (negative).
gross_profitnumber requiredWhat the wins made.
gross_lossnumber requiredWhat the losses lost (negative).
netnumber requiredThe trades' results together.
max_drawdownnumber requiredThe largest fall of the closed results from a high, in time order (positive).
by_dayarray of StatsDay requiredEach day with a closed trade, oldest first.
StatsDay fields
daystring requiredYYYY-MM-DD: the forex day under a clock rule, else the server's date.
profitnumber requiredWhat the trades closed that day made.
tradesinteger requiredTrades closed that day.
frominteger requiredRange start, unix seconds, server time.
tointeger requiredRange end.
from_utcintegerRange start in UTC; only with the account's clock rule (0.7.1).
to_utcintegerRange end in UTC; only with the account's clock rule (0.7.1).
from_utc_ambiguousbooleantrue when from falls in New York's repeated autumn hour (0.7.1).
to_utc_ambiguousbooleantrue when to falls in New York's repeated autumn hour (0.7.1).
currencystring or null requiredThe account's currency.
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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_errorThe broker's server failed or answered with something unexpected. - 503
disconnectedbusystoppingdisconnected: 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
timeoutunconfirmedtimeout: 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 -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/stats?days=30" \
-H "Authorization: Bearer $TERMLESS_KEY"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())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))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());{
"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"
}