TermlessDocs

Reference

Broker servers

The directory of known broker servers and a check for any address. Used when adding an account.

Search broker servers

GET/api/v1/servers

Searches 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.

Scope admin

Query parameters

  • q string

    Text to match, for example black bull. Empty for the top of the list.

  • limit integer default 20 min 1, max 200

    Most rows to return, at most 200.

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 Matching servers.

A JSON array of Server objects.

  • server string required

    Trade server name exactly as the broker spells it, for example Pepperstone-Demo.

  • company string required

    Broker company name.

  • host string required

    Host that serves the broker's MT5 web terminal.

  • port integer required

    Port, usually 443.

  • type string required

    Demo or real money server.

    demoreal
  • build integer or null required

    MT5 web terminal build seen on the host. null until this install has checked it.

  • verified_at integer or null required

    Unix seconds (UTC) when this install last checked the host. null for a built-in entry it has not checked.

  • tls_name string or null required

    For 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_sha256 string or null required

    SHA-256 of the certificate key an admin pinned for this host (64 hex), or null.

  • prop_firm boolean required

    A prop firm's server (from the built-in directory).

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/servers?q=pepperstone&limit=20" \
  -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}/servers", headers=auth, params={"q": "pepperstone", "limit": 20})
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}/servers?q=pepperstone&limit=20", 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}/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());
Response 200
[
  {
    "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

POST/api/v1/servers/check

Reads 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).

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 ServerCheckRequest

  • host string required

    Host 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.

  • port integer default 443

    Port. Defaults to 443.

  • tls_name string

    For an IP access point: the name on its certificate (sent as SNI and checked). Defaults to the directory's for that host.

  • fingerprint string

    Pin 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.

  • ok boolean required

    True when the host serves an MT5 web terminal.

  • host string required

    The host that was checked.

  • port integer required

    The port that was checked.

  • company string required

    Broker company name from the terminal page.

  • build integer required

    Web terminal build.

  • servers array of object required

    Trade servers this host answers for. They are saved to the directory.

    Fields
    • server string required

      Trade server name.

    • type string required

      demo or real, from the server's name (Demo, Trial or Contest in it means demo), not from the page.

      demoreal
  • tls_name string or null required

    The TLS name used, for an IP access point.

  • pin_sha256 string or null required

    The pinned key the host was checked with, if any.

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.
  • 502 untrusted_certificate browser_only broker_error (generic), untrusted_certificate or certificate_changed (with the certificate), or browser_only.
curl
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"}'
Python
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())
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 = {
    "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))
JavaScript
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());
Response 200
{
  "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

POST/api/v1/servers/{server}/trust

Pins 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.

Scope admin

Path parameters

  • server string required

    Trade server name as in the directory (spaces are allowed; encode them).

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 TrustRequest

  • fingerprint string required

    The key to pin: spki_sha256 from a refused check (64 hex; sha256: and colons allowed).

Response 200 Pinned.

A TrustResult object.

  • ok boolean required

    True: pinned.

  • server string required

    The server named in the path.

  • host string required

    Its host.

  • port integer required

    Its port.

  • tls_name string or null required

    Its TLS name, if any.

  • pin_sha256 string required

    The pinned key.

  • accounts_restarted integer required

    Accounts on that gateway that logged in again with the pin.

  • servers array of object required

    Servers the host's page lists (saved with the pin).

    Fields
    • server string required

      Trade server name.

    • type string required

      demo or real.

      demoreal

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 certificate_changed (the host shows another key), or another failure reading the host.
curl
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"}'
Python
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())
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 = {
    "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))
JavaScript
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

DELETE/api/v1/servers/{server}/trust

Removes 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.

Scope admin

Path parameters

  • server string required

    Trade server name as in the directory (spaces are allowed; encode them).

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/servers/Alpari-MT5-Demo/trust" \
  -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}/servers/Alpari-MT5-Demo/trust", 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}/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 body
JavaScript
const 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 body
Response
HTTP/1.1 204 No Content