TermlessDocs

Guides

Introduction

MetaTrader 5 without the terminal. Termless keeps your MT5 accounts logged in on a Linux box and gives every app, script and AI agent one HTTP API for prices, candles, account state and trading.

Termless is a server, termlessd: one static binary that speaks the MetaTrader 5 protocol straight to your broker, keeps each account connected around the clock, and serves everything over HTTP. There is no MetaTrader terminal, no Windows and no Wine anywhere. Your bots, scripts and agents talk to Termless; Termless talks to the broker.

curl
curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/quotes?symbols=XAUUSD" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
import os, requests

r = requests.get(os.environ["TERMLESS_URL"] + "/api/v1/accounts/pepperstone-12345678/quotes",
                 headers={"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]},
                 params={"symbols": "XAUUSD"})
print(r.json()[0])
JavaScript
const res = await fetch(`${process.env.TERMLESS_URL}/api/v1/accounts/pepperstone-12345678/quotes?symbols=XAUUSD`, {
  headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` },
});
console.log((await res.json())[0]);
Response
[{"symbol": "XAUUSD", "bid": 2391.42, "ask": 2391.6, "last": 0, "time": 1790981179, "time_msc": 1790981179473, "tradeable": true}]

What you get#

Market dataSymbol search, full symbol specs (lot limits, stop levels, sessions, swaps, margin rates), quotes, candles on 21 timeframes (up to about 100,000 bars back on each; M1 reaches about three months), recent ticks and order books.
Live prices and eventsEvery tick, pushed over Server-sent events or a WebSocket, and on the same stream every trade the broker applies, the account's money and the live P/L of its positions, so a bot never polls. One stream carries up to 200 symbols.
Account stateBalance, equity, margin, open positions with live profit, pending orders and deal history, the same numbers MT5 shows.
TradingMarket and pending orders, stop loss and take profit, partial closes, cancels, margin and profit worked out and orders checked before you send them, and a route that takes the official MetaTrader5 order_send request unchanged. An Idempotency-Key on every call makes retries safe.
TrailsAn audit trail of every write with the request id that caused it, each account's connection history, and an equity curve.
Keys and scopesEach app gets its own key with one scope, read, trade or admin, optionally limited to some accounts. Revoke one without touching the rest.
A dashboardAccounts, a live tab with a chart and a ticket, keys, and diagnostics, at / on the same server.

The mental model#

Five ideas carry the whole API. Everything else is detail.

Accounts#

An account is one MT5 login at one broker server. You add it once with its login, password and server name; Termless stores the password encrypted and keeps a session to the broker open. Every account has an id you choose (pepperstone-12345678 by default: the server's first word and the login), and that id appears in every market and trading URL: /api/v1/accounts/{id}/....

Sessions#

Behind each account is a supervised session. It logs in, subscribes the watchlist, answers your requests, and when the link drops it reconnects on its own (1 s, then 2, 4, up to 30 s between tries). While it is reconnecting, routes that need the broker answer 503 disconnected; nothing else changes. You never log in or out yourself.

Two clocks#

Market and trade times (time, time_msc on ticks, candles, positions, orders and deals, and the from and to you send) are in the trade server's clock, exactly as MetaTrader reports them. Most brokers run UTC+2 or UTC+3. Each account's summary tells you the offset as server_offset (seconds east of UTC); subtract it to get UTC. Times about Termless itself (created_at, status.since, last_used_at) are plain UTC. The conventions page has the recipe.

Lots#

Volumes are lots, as in MT5: 0.01 is the smallest order on most symbols, 1.00 is one standard lot (100,000 units of a currency pair, 100 ounces of gold). Each symbol's spec says its volume_min, volume_max and volume_step; read it before you size an order.

Retcodes#

Every trade call returns a trade result with the broker's own return code. 10009 means done, 10008 means placed, 10010 means partly filled; those three set ok: true and answer 200. A placed pending order is 10008 or 10009 depending on the broker, so read ok. Anything else is a refusal: the response is 422 with the same trade result (ok: false, the retcode, its text) so you can read why. Trading safely explains how to act on them.

Where to go next#

  • Quickstart: a key, a quote, candles, a stream and a demo trade in under five minutes.
  • API reference: every route with every field, and copy-ready calls in curl, Python and JavaScript.
  • For AI agents: how an agent should use this API, and how to read these docs without filling its context: llms.txt first, then only the pages it needs.
  • The MetaTrader5 Python mapping: every official MetaTrader5 call and the route that does the same, for porting a script.
  • Running the server: install, settings, the data folder, upgrades, the doctor and diagnostics.
  • Setting up a bot: one login, one key per program, an Idempotency-Key per order, what an unconfirmed trade means, timeouts, and where to watch the link.
  • Health checks for bots: ask /ready before an order, read uptime, outages and order latency from /status, scrape /metrics.
  • Activity and trails: the audit trail, connection history and equity curve, and the request id that ties them to your own log.
  • What's new: what changed in each release, and when the database changed.