Reference
Broker servers
The directory of known broker servers and a check for any address. Used when adding an account.
Search broker servers
/api/v1/serversSearches the directory of trade servers whose web terminal host is known: the built-in list plus every one this install has checked. Matches server name, company and host, ignoring case, spaces, hyphens, dots and other punctuation (black bull, blackbull and Black-Bull find the same). Servers this install has checked come first; an empty q returns the top of the list. Server names may contain spaces.
Query parameters
qstringText to match, for example black bull. Empty for the top of the list.
limitinteger default20min 1, max 200Most rows to return, at most 200.
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 Matching servers.
A JSON array of Server objects.
serverstring requiredTrade server name exactly as the broker spells it, for example Pepperstone-Demo.
companystring requiredBroker company name.
hoststring requiredHost that serves the broker's MT5 web terminal.
portinteger requiredPort, usually 443.
typestring requiredDemo or real money server.
demorealbuildinteger or null requiredMT5 web terminal build seen on the host. null until this install has checked it.
verified_atinteger or null requiredUnix seconds (UTC) when this install last checked the host. null for a built-in entry it has not checked.
tls_namestring or null requiredFor an IP access point: the name sent (SNI) and checked against the certificate while TCP goes to the IP. null for a named host.
pin_sha256string or null requiredSHA-256 of the certificate key an admin pinned for this host (64 hex), or null.
prop_firmboolean requiredA prop firm's server (from the built-in directory).
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/servers?q=pepperstone&limit=20" \
-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}/servers", headers=auth, params={"q": "pepperstone", "limit": 20})
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}/servers?q=pepperstone&limit=20", 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}/servers?q=pepperstone&limit=20`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());[
{
"server": "Pepperstone-Demo",
"company": "Pepperstone Group Limited",
"host": "mt5-demo01.pepperstone.com",
"port": 443,
"type": "demo",
"build": 6090,
"verified_at": 1790966779,
"tls_name": null,
"pin_sha256": null,
"prop_firm": false
},
{
"server": "Pepperstone-MT5-Live01",
"company": "Pepperstone Group Limited",
"host": "mt5-1.pepperstone.com",
"port": 443,
"type": "real",
"build": null,
"verified_at": null,
"tls_name": null,
"pin_sha256": null,
"prop_firm": false
}
]Check an address
/api/v1/servers/checkReads the public web terminal page on a host and reports which trade servers it answers for, and remembers them in the directory. Use it before adding an account on a server the directory does not know. Gateways must be on the public internet: a host that resolves to loopback, link-local, private, carrier-grade NAT, multicast or documentation space is 400 (unless the server runs with TERMLESS_ALLOW_PRIVATE_GATEWAYS=1). The certificate is always verified: a missing intermediate is fetched from the certificate's own CA Issuers URL (public addresses only) and the chain verified again; tls_name checks an IP access point against the name on its certificate; a certificate for another name or from a private CA is refused with 502 untrusted_certificate and a certificate object (CertificateError) whose spki_sha256 an admin may pin by checking again with fingerprint (audited as server_trust); a pinned host that shows another key is 502 certificate_changed. A terminal behind a Cloudflare challenge (only browsers get in) is 502 browser_only. Any other failure answers one generic 502 broker_error (the route is not a port scanner); the reason is in the server log and the audit trail (server_check).
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 ServerCheckRequest
hoststring requiredHost name to check. A pasted link works: the scheme, path, query, fragment and any user@ are dropped, and host:port works when port is left out.
portinteger default443Port. Defaults to 443.
tls_namestringFor an IP access point: the name on its certificate (sent as SNI and checked). Defaults to the directory's for that host.
fingerprintstringPin this certificate key for the host: the spki_sha256 a refused check reported (64 hex; sha256: and colons allowed). Only for a host you know is the broker's; audited as server_trust.
Response 200 The host serves an MT5 web terminal.
A ServerCheck object.
okboolean requiredTrue when the host serves an MT5 web terminal.
hoststring requiredThe host that was checked.
portinteger requiredThe port that was checked.
companystring requiredBroker company name from the terminal page.
buildinteger requiredWeb terminal build.
serversarray of object requiredTrade servers this host answers for. They are saved to the directory.
Fields
serverstring requiredTrade server name.
typestring requireddemo or real, from the server's name (Demo, Trial or Contest in it means demo), not from the page.
demoreal
tls_namestring or null requiredThe TLS name used, for an IP access point.
pin_sha256string or null requiredThe pinned key the host was checked with, if any.
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. - 502
untrusted_certificatebrowser_onlybroker_error (generic), untrusted_certificate or certificate_changed (with the certificate), or browser_only.
curl -s -X POST "$TERMLESS_URL/api/v1/servers/check" \
-H "Authorization: Bearer $TERMLESS_KEY" \
-H "Content-Type: application/json" \
-d '{"host": "mt5-demo01.pepperstone.com"}'import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.post(f"{base}/servers/check", headers=auth, json={
"host": "mt5-demo01.pepperstone.com"
})
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 = {
"host": "mt5-demo01.pepperstone.com"
}
headers["Content-Type"] = "application/json"
req = urllib.request.Request(f"{base}/servers/check", 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}/servers/check`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"host": "mt5-demo01.pepperstone.com"
})
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"ok": true,
"host": "mt5-demo01.pepperstone.com",
"port": 443,
"company": "Pepperstone Group Limited",
"build": 6090,
"servers": [
{
"server": "Pepperstone-Demo",
"type": "demo"
}
],
"tls_name": null,
"pin_sha256": null
}Pin a certificate key
/api/v1/servers/{server}/trustPins a certificate key for the server's host and port (every directory row on it), for a broker whose certificate cannot be verified (another name, a private CA). The live host is checked with the pin first, so only the key it presents now can be pinned: 502 certificate_changed otherwise. Accounts on that gateway log in again with the pin. Audited as server_trust.
Path parameters
serverstring requiredTrade server name as in the directory (spaces are allowed; encode them).
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 TrustRequest
fingerprintstring requiredThe key to pin: spki_sha256 from a refused check (64 hex; sha256: and colons allowed).
Response 200 Pinned.
A TrustResult object.
okboolean requiredTrue: pinned.
serverstring requiredThe server named in the path.
hoststring requiredIts host.
portinteger requiredIts port.
tls_namestring or null requiredIts TLS name, if any.
pin_sha256string requiredThe pinned key.
accounts_restartedinteger requiredAccounts on that gateway that logged in again with the pin.
serversarray of object requiredServers the host's page lists (saved with the pin).
Fields
serverstring requiredTrade server name.
typestring requireddemo or real.
demoreal
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 certificate_changed (the host shows another key), or another failure reading the host.
curl -s -X POST "$TERMLESS_URL/api/v1/servers/Alpari-MT5-Demo/trust" \
-H "Authorization: Bearer $TERMLESS_KEY" \
-H "Content-Type: application/json" \
-d '{"fingerprint": "94f8fc63b835599dd9a14fbd30445e94040d65b2801597b764aae9bfb779d4e7"}'import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.post(f"{base}/servers/Alpari-MT5-Demo/trust", headers=auth, json={
"fingerprint": "94f8fc63b835599dd9a14fbd30445e94040d65b2801597b764aae9bfb779d4e7"
})
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 = {
"fingerprint": "94f8fc63b835599dd9a14fbd30445e94040d65b2801597b764aae9bfb779d4e7"
}
headers["Content-Type"] = "application/json"
req = urllib.request.Request(f"{base}/servers/Alpari-MT5-Demo/trust", 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}/servers/Alpari-MT5-Demo/trust`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"fingerprint": "94f8fc63b835599dd9a14fbd30445e94040d65b2801597b764aae9bfb779d4e7"
})
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());Remove a pinned key
/api/v1/servers/{server}/trustRemoves the pin for the server's host and port; the host is checked the normal way again and its accounts log in again. Audited as server_trust.
Path parameters
serverstring requiredTrade server name as in the directory (spaces are allowed; encode them).
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/servers/Alpari-MT5-Demo/trust" \
-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}/servers/Alpari-MT5-Demo/trust", 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}/servers/Alpari-MT5-Demo/trust", 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}/servers/Alpari-MT5-Demo/trust`, {
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 Content