Reference
Market data
Symbols, their full specs, quotes, candles, the recent ticks the server kept and order books. Times are in the trade server's clock; subtract the account's server_offset for UTC.
Search symbols
/api/v1/accounts/{id}/symbolsSymbols the broker offers on this account: the exact name first, then names starting with q, then the rest (names or descriptions containing it).
Path parameters
idstring requiredAccount id.
Query parameters
qstringText to match in the name or description. Empty lists every symbol.
limitinteger default50min 1, max 10000Most rows to return, at most 10000.
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 Symbols.
A JSON array of SymbolBrief objects.
namestring requiredSymbol name, for example XAUUSD.
descriptionstring requiredBroker's description.
pathstring requiredFolder in the broker's symbol tree.
digitsinteger requiredPrice decimals.
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/symbols?q=xau&limit=50" \
-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/symbols", headers=auth, params={"q": "xau", "limit": 50})
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/symbols?q=xau&limit=50", 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/symbols?q=xau&limit=50`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());[
{
"name": "XAUUSD",
"description": "Gold vs US Dollar",
"path": "Metals\\XAUUSD",
"digits": 2
}
]Get a symbol's spec
/api/v1/accounts/{id}/symbols/{symbol}Everything needed to size and place an order: digits, contract size, tick size and value, lot limits, stop levels, swaps and their unit and triple day, margin settings with every order type's rate (margin_rates), the expiry modes and order types the symbol takes, and sessions, with the broker's group overrides applied, plus tradeable: whether a trade can be opened now, as on /quotes. tick_value is the broker's, else worked out as the terminal does (null when it cannot be). sessions.quote and sessions.trade are 7 lists (Sunday first) of [open_min, close_min] minutes from midnight, server time. The specs of the watchlist, order books, positions and pending orders are read in one request after each connect, so the first read of one does not wait a broker round trip for its spec.
Path parameters
idstring requiredAccount id.
symbolstring requiredSymbol name (exact, else matched case-insensitively).
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 Symbol spec.
A SymbolSpec object.
namestring requiredSymbol name.
descriptionstring requiredBroker's description.
pathstring requiredFolder in the broker's symbol tree.
digitsinteger requiredPrice decimals.
pointnumber requiredSmallest price step, 10^-digits.
contract_sizenumber requiredUnits per 1.00 lot.
tick_sizenumber requiredSmallest price change. The point when the broker does not send one.
tick_valuenumber or null requiredValue of one tick_size move for 1.00 lot, in the account currency. The broker's own figure, else worked out as the terminal does: tick_size x contract_size, converted from currency_profit to the account currency, for forex, CFD, leveraged CFD and exchange stock symbols. null when the broker sends none and it cannot be worked out (futures and index CFDs, or no conversion symbol). Pepperstone sends neither tick value nor tick size.
currency_basestring requiredBase currency.
currency_profitstring requiredProfit currency.
currency_marginstring requiredMargin currency.
volume_minnumber requiredSmallest order, in lots.
volume_maxnumber requiredLargest order, in lots.
volume_stepnumber requiredLot step.
volume_limitnumber requiredLargest total of open positions and pending orders in one direction, in lots. 0 = no limit.
trade_modestring requiredWhether trading is allowed. unknown only for a value MetaTrader does not define.
fulllong_onlyshort_onlyclose_onlydisabledunknownexecutionstring requiredExecution mode. unknown only for a value MetaTrader does not define.
marketinstantrequestexchangeunknownfillingarray of string requiredFilling modes the symbol allows.
fokiocreturnstops_levelinteger requiredMinimum distance of SL and TP from the price, in points.
freeze_levelinteger requiredDistance in points inside which orders cannot be changed.
swap_longnumber requiredSwap for long positions, in the unit swap_mode names.
swap_shortnumber requiredSwap for short positions, in the unit swap_mode names.
swap_modestring requiredThe unit of swap_long and swap_short. unknown only for a value MetaTrader does not define.
disabledpointssymbol_currencymargin_currencydeposit_currencyinterest_currentinterest_openreopen_currentreopen_bidprofit_currencyunknownswap_3daystring or null requiredThe day the swap is charged three times: sunday, monday, tuesday, wednesday, thursday, friday or saturday. null for none (crypto CFDs send none).
margin_initialnumber requiredInitial margin setting of the symbol, as the broker sends it.
margin_maintenancenumber requiredMaintenance margin setting, as the broker sends it.
margin_hedgednumber requiredMargin for a hedged pair of positions (one lot each way), as the broker sends it.
margin_rate_buynumber requiredInitial margin rate for a buy (the same as margin_rates.buy).
margin_rate_sellnumber requiredInitial margin rate for a sell (the same as margin_rates.sell).
margin_ratesobject requiredEvery order type's initial margin rate, as the broker sends it. A pending type's rate is what the broker holds while such an order waits: the brokers seen send 0 there (nothing is held), and once the order fills the position needs its side's market rate. A market rate of 0 counts as 1.
Fields
buynumber requiredInitial margin rate for a buy.
sellnumber requiredInitial margin rate for a sell.
buy_limitnumber requiredInitial margin rate for a buy limit.
sell_limitnumber requiredInitial margin rate for a sell limit.
buy_stopnumber requiredInitial margin rate for a buy stop.
sell_stopnumber requiredInitial margin rate for a sell stop.
buy_stop_limitnumber requiredInitial margin rate for a buy stop limit.
sell_stop_limitnumber requiredInitial margin rate for a sell stop limit.
expirationarray of string requiredThe expiry modes a pending order on this symbol may use.
gtcdayspecifiedspecified_dayorder_typesarray of string requiredThe order types the symbol takes.
marketlimitstopstop_limitsltpclose_bysessionsobject requiredFields
quotearray of array of array of integer requiredQuote sessions: 7 lists, one per weekday, Sunday first, each a list of [open_min, close_min] in minutes from midnight, trade server time.
tradearray of array of array of integer requiredTrade sessions, same shape as quote.
tradeableboolean or null requiredWhether a trade can be opened now, as on /quotes: the trade_mode is full, long_only or short_only, and one of today's trade sessions is open by the server's clock. null when the broker sent no trade sessions.
book_depthintegerThe levels a side of the symbol's order book may hold (0 when the broker sends none); a book past it is renewed (0.7.0).
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/symbols/XAUUSD" \
-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/symbols/XAUUSD", 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/symbols/XAUUSD", 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/symbols/XAUUSD`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"name": "XAUUSD",
"description": "Gold vs US Dollar",
"path": "Metals\\XAUUSD",
"digits": 2,
"point": 0.01,
"contract_size": 100,
"tick_size": 0.01,
"tick_value": 1.0,
"currency_base": "XAU",
"currency_profit": "USD",
"currency_margin": "XAU",
"volume_min": 0.01,
"volume_max": 100,
"volume_step": 0.01,
"volume_limit": 0,
"trade_mode": "full",
"execution": "market",
"filling": [
"fok",
"ioc"
],
"stops_level": 0,
"freeze_level": 0,
"swap_long": -6.2,
"swap_short": 1.4,
"swap_mode": "points",
"swap_3day": "wednesday",
"margin_initial": 0.0,
"margin_maintenance": 0.0,
"margin_hedged": 50.0,
"margin_rate_buy": 1.0,
"margin_rate_sell": 1.0,
"margin_rates": {
"buy": 1.0,
"sell": 1.0,
"buy_limit": 0.0,
"sell_limit": 0.0,
"buy_stop": 0.0,
"sell_stop": 0.0,
"buy_stop_limit": 0.0,
"sell_stop_limit": 0.0
},
"expiration": [
"gtc",
"day",
"specified",
"specified_day"
],
"order_types": [
"market",
"limit",
"stop",
"stop_limit",
"sl",
"tp",
"close_by"
],
"sessions": {
"quote": [
[],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[]
],
"trade": [
[],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[
[
0,
1440
]
],
[]
]
},
"tradeable": true
}Get many symbol specs
/api/v1/accounts/{id}/specsMany specs in one broker request (0.7.0), each with when it was read; a cached spec is read again once it is a day old (TERMLESS_SPEC_MAX_AGE_S).
Path parameters
idstring requiredAccount id.
Query parameters
namesstring requiredComma-separated symbols, 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 Specs, in the order asked.
A JSON array of SpecItem objects.
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/specs?names=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/specs", headers=auth, params={"names": "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/specs?names=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/specs?names=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());Get quotes
/api/v1/accounts/{id}/quotesThe latest bid and ask, and tradeable: whether a trade can be opened now (trade mode and today's trade sessions, by the server's clock; null when the broker sent no sessions). The first request for a symbol subscribes it and waits up to 3 s for a first price; later ones answer at once. A symbol with no price yet (a closed market) has null prices. For a steady feed use the stream instead of polling. Since 0.7.0 a read leases its symbols for hold seconds after the caller's last read, then lets them go (0.6.3 kept them until a restart); a lease is the caller's own and never stops a symbol a stream holds or the watchlist pins.
Path parameters
idstring requiredAccount id.
Query parameters
symbolsstringComma-separated symbols, at most 200. Defaults to the account's watchlist (400 when that is empty too).
holdinteger default600min 0, max 3600Seconds the symbols stay subscribed after this read (0.7.0; 0 to 3600, default 600). 0 answers from prices already streaming and subscribes nothing.
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 Quotes, in the order asked.
A JSON array of Quote objects.
symbolstring requiredSymbol name.
bidnumber or null requiredBid price. null when the symbol has no price yet.
asknumber or null requiredAsk price. null when the symbol has no price yet.
lastnumber or null requiredLast deal price. 0 for most forex and CFD symbols; null when the symbol has no price yet.
timeinteger or null requiredUnix seconds, trade server clock.
time_mscinteger or null requiredUnix milliseconds, trade server clock.
tradeableboolean or null requiredWhether a trade can be opened now: the symbol's trade_mode is full, long_only or short_only, and one of today's trade sessions is open by the server's clock. null when the broker sent no trade sessions.
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/quotes?symbols=XAUUSD,EURUSD&hold=600" \
-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/quotes", headers=auth, params={"symbols": "XAUUSD,EURUSD", "hold": 600})
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/quotes?symbols=XAUUSD,EURUSD&hold=600", 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/quotes?symbols=XAUUSD,EURUSD&hold=600`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());[
{
"symbol": "XAUUSD",
"bid": 2391.42,
"ask": 2391.6,
"last": 0,
"time": 1790981179,
"time_msc": 1790981179473,
"tradeable": true
}
]Let quotes go
/api/v1/accounts/{id}/quotesThe caller's leases on these symbols end now (0.7.0).
Path parameters
idstring requiredAccount id.
Query parameters
symbolsstring requiredComma-separated symbols.
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 What was let go.
releasedarray of string requiredThe symbols.
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 -X DELETE "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/quotes?symbols=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.delete(f"{base}/accounts/pepperstone-12345678/quotes", headers=auth, params={"symbols": "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/quotes?symbols=EURUSD", data=None, headers=headers, method="DELETE")
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/quotes?symbols=EURUSD`, {
method: "DELETE",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"released": [
"EURUSD"
]
}Get candles
/api/v1/accounts/{id}/candlesBars for one symbol and timeframe, oldest first, at most 50000. Ask by count (the latest N bars, or the N ending at to; with offset, the N ending that many bars before the newest, as copy_rates_from_pos's start_pos) or by range (from and to, unix seconds in trade server time; to defaults to now). A range over 100,000 bars is 400 ("that range holds more than 100000 bars; narrow it (a range over 50000 bars keeps the newest 50000) or use count"); one over 50,000 keeps the newest 50,000. Each bar says whether it is complete (closed by the server's clock): read that rather than dropping the last bar, which at a weekend or a daily break is closed too. spread is always 0 (the web protocol's bars carry none). The broker serves candle requests one at a time, so requests from many callers on one account queue rather than fail. Requests of more than 10,000 bars take turns per account, one at a time; the account's others wait their turn. History reaches about 100,000 bars back per timeframe through the web protocol (M1 about three months); older bars are not served. A range read's settled bars (closed at least 15 minutes ago) come from a cache shared by every account (0.7.0, TERMLESS_CANDLE_CACHE_MB, default 32); younger bars always from the broker. With the account's clock rule (0.7.0), UTC fields come beside it (see the account's clock).
Path parameters
idstring requiredAccount id.
Query parameters
symbolstring requiredSymbol name.
timeframestring default"M5"Bar size. MN works for MN1.
M1M2M3M4M5M6M10M12M15M20M30H1H2H3H4H6H8H12D1W1MN1countinteger default500min 1, max 50000Latest N bars, 1 to 50000. Ignored when from is given.
offsetinteger default0min 0, max 49999With count: end the bars this many bars before the newest (or before to), like copy_rates_from_pos's start_pos. count plus offset at most 50000. Ignored when from is given.
fromintegerRange start, unix seconds, trade server time.
tointegerRange end (or the end of the count), unix seconds, trade server time. Defaults to now.
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 Candles.
A Candles object.
symbolstring requiredSymbol name, as the broker spells it.
timeframestring requiredTimeframe.
M1M2M3M4M5M6M10M12M15M20M30H1H2H3H4H6H8H12D1W1MN1candlesarray of Candle requiredBars, oldest first. Each says whether it is complete.
Candle fields
timeinteger requiredBar open time, unix seconds, trade server clock.
opennumber requiredOpen.
highnumber requiredHigh.
lownumber requiredLow.
closenumber requiredClose.
tick_volumeinteger requiredTick count in the bar.
real_volumeinteger requiredExchange volume. 0 for most CFD symbols.
spreadinteger requiredAlways 0: the web protocol's bars carry no spread (MetaTrader builds bars from the bid).
completeboolean requiredThe bar has closed, by the server's clock (a month bar closes at the next month's start). The newest bar is usually still forming, but at a weekend or a daily break it may be closed too: read this rather than dropping the last bar.
time_utcintegerBar open time in UTC, unix seconds; only with the account's clock rule (0.7.0).
time_utc_ambiguousbooleantrue when the time falls in New York's repeated autumn hour (0.7.0).
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/candles?symbol=XAUUSD&timeframe=M5&count=500" \
-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/candles", headers=auth, params={"symbol": "XAUUSD", "timeframe": "M5", "count": 500})
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/candles?symbol=XAUUSD&timeframe=M5&count=500", 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/candles?symbol=XAUUSD&timeframe=M5&count=500`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"symbol": "XAUUSD",
"timeframe": "M5",
"candles": [
{
"time": 1790980500,
"open": 2394.31,
"high": 2395.1,
"low": 2390.58,
"close": 2392.41,
"tick_volume": 2330,
"real_volume": 0,
"spread": 0,
"complete": true
},
{
"time": 1790980800,
"open": 2392.41,
"high": 2394.19,
"low": 2392.29,
"close": 2393.97,
"tick_volume": 834,
"real_volume": 0,
"spread": 0,
"complete": false
}
]
}Get candles for many ranges
/api/v1/accounts/{id}/candles/batchUp to 20 ranges read one after another through the candle cache (0.7.0), each answered with its candles or its own error. A bad timeframe or range in any item, or more than 200,000 bars in all, refuses the whole batch (400).
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 CandleBatchRequest
itemsarray of object required1 to 20 ranges, at most 200,000 bars in all (each item's whole range counts).
Fields
symbolstring requiredSymbol name.
timeframestringTimeframe (default M5).
M1M2M3M4M5M6M10M12M15M20M30H1H2H3H4H6H8H12D1W1MN1frominteger requiredRange start, unix seconds, server time.
tointeger requiredRange end.
Response 200 One result per range.
A CandleBatch object.
itemsarray of CandleBatchItem requiredOne per range asked, in order.
See CandleBatchItem.
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 -X POST "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/candles/batch" \
-H "Authorization: Bearer $TERMLESS_KEY" \
-H "Content-Type: application/json" \
-d '{"items": [{"symbol": "XAUUSD", "timeframe": "M5", "from": 1790894400, "to": 1790980800}, {"symbol": "EURUSD", "timeframe": "H1", "from": 1790376000, "to": 1790980800}]}'import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.post(f"{base}/accounts/pepperstone-12345678/candles/batch", headers=auth, json={
"items": [
{
"symbol": "XAUUSD",
"timeframe": "M5",
"from": 1790894400,
"to": 1790980800
},
{
"symbol": "EURUSD",
"timeframe": "H1",
"from": 1790376000,
"to": 1790980800
}
]
})
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 = {
"items": [
{
"symbol": "XAUUSD",
"timeframe": "M5",
"from": 1790894400,
"to": 1790980800
},
{
"symbol": "EURUSD",
"timeframe": "H1",
"from": 1790376000,
"to": 1790980800
}
]
}
headers["Content-Type"] = "application/json"
req = urllib.request.Request(f"{base}/accounts/pepperstone-12345678/candles/batch", 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/pepperstone-12345678/candles/batch`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"items": [
{
"symbol": "XAUUSD",
"timeframe": "M5",
"from": 1790894400,
"to": 1790980800
},
{
"symbol": "EURUSD",
"timeframe": "H1",
"from": 1790376000,
"to": 1790980800
}
]
})
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());Get an order book
/api/v1/accounts/{id}/bookmarket_book_add and market_book_get in one call: the symbol's order book (depth of market), sells from the highest price down, then buys. The first request for a symbol asks the broker for its book and waits up to 3 s for the snapshot that brings; termlessd keeps the book for every caller until DELETE /book releases it, and asks again by itself after a reconnect. At most 32 books per account (400 past that). Brokers may send changes rarely or never (Pepperstone sent none for BTCUSD in 90 s while its price ticked), so a book older than max_age_ms is renewed first: that symbol alone is taken out of the subscribed set and put back, which brings a fresh snapshot, waited for up to 3 s (the other books stay). When none comes, the kept book is answered and its time says how old it is, and the symbol is not asked again for 30 s; one the broker never sent a book for is answered with time: 0 and no levels, and asked again only after 5 minutes. A broker that refuses a change of the set gets the kept book answered, not an error. A symbol whose market is closed has an empty book.
Path parameters
idstring requiredAccount id.
Query parameters
symbolstring requiredSymbol name.
max_age_msinteger default1000min 100, max 60000The oldest book answered without asking the broker again, in milliseconds, 100 to 60000; outside that is 400.
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 book.
A Book object.
symbolstring requiredSymbol name, as the broker spells it.
timeinteger requiredThe trade server's time of this book, unix seconds, server time. 0 when the broker has sent no book for the symbol (it likely has no depth there; it is asked again after 5 minutes); an old time means the broker sent no fresh book within 3 s when asked again (asked again after 30 s).
time_mscinteger requiredThe same to the millisecond (a change the broker pushed carries its milliseconds; a full snapshot 0 of them). 0 when time is 0.
levelsarray of BookLevel requiredSells from the highest price down, then buys from the highest price down. Empty when the market is closed, or when the broker sent no book (time 0).
BookLevel fields
typeinteger requiredMetaTrader's BOOK_TYPE_*: 1 sell, 2 buy, 3 sell market, 4 buy market.
1234sidestring requiredsell for types 1 and 3, buy for 2 and 4.
sellbuypricenumber requiredThe level's price.
volumeinteger requiredVolume at this price in the broker's units (units of the base, as the web terminal shows them; 0.7.0, it was called lots), whole (the official volume).
volume_dblnumber requiredThe same, exactly.
lotsnumber requiredThe units over the symbol's contract size (0.7.0).
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. - 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. - 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/book?symbol=XAUUSD" \
-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/book", headers=auth, params={"symbol": "XAUUSD"})
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/book?symbol=XAUUSD", 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/book?symbol=XAUUSD`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"symbol": "XAUUSD",
"time": 1790981179,
"time_msc": 1790981179629,
"levels": [
{
"type": 1,
"side": "sell",
"price": 2391.8,
"volume": 250,
"volume_dbl": 250.0,
"lots": 2.5
},
{
"type": 1,
"side": "sell",
"price": 2391.6,
"volume": 100,
"volume_dbl": 100.0,
"lots": 1.0
},
{
"type": 2,
"side": "buy",
"price": 2391.42,
"volume": 120,
"volume_dbl": 120.0,
"lots": 1.2
},
{
"type": 2,
"side": "buy",
"price": 2391.2,
"volume": 300,
"volume_dbl": 300.0,
"lots": 3.0
}
]
}Release an order book
/api/v1/accounts/{id}/bookmarket_book_release: the broker stops sending the symbol's book and it no longer counts toward the 32. released is false when the book was not added. Releasing the last book succeeds even on a broker that refuses an empty set (its pushes for that symbol are then dropped here).
Path parameters
idstring requiredAccount id.
Query parameters
symbolstring requiredSymbol name.
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 Released.
symbolstring requiredSymbol name, as the broker spells it.
releasedboolean requiredTrue when the book was added and is now released.
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 -X DELETE "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/book?symbol=XAUUSD" \
-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/book", headers=auth, params={"symbol": "XAUUSD"})
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/book?symbol=XAUUSD", data=None, headers=headers, method="DELETE")
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/book?symbol=XAUUSD`, {
method: "DELETE",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"symbol": "XAUUSD",
"released": true
}Get recent ticks
/api/v1/accounts/{id}/tickscopy_ticks_from and copy_ticks_range over the ticks this server kept for the symbol, oldest first. The web protocol has no tick-history request, so these are the ticks the broker pushed since the account's current broker connection subscribed the symbol: the newest 1,000 per streaming symbol (TERMLESS_TICK_HISTORY, at most 100,000; 0 keeps none), and at most 100,000 over all of the account's streaming symbols, shared evenly (500 symbols keep 200 each). A reconnect starts the history again; kept_from_msc says how far back it reaches. Without from, the newest count (up to to when given); with from, the first count from there on (up to to when given). The first request for a symbol not streaming yet subscribes it, like /quotes, but does not wait for a price, so it may answer no ticks. To keep every tick, record them from a stream. Since 0.7.0 a symbol's ticks are kept from its first read on, so the first answer is often empty; the read leases the symbol like /quotes.
Path parameters
idstring requiredAccount id.
Query parameters
symbolstring requiredSymbol name.
countinteger default1000min 1, max 20000Most ticks to return: the newest when from is not given, else the first ones from from on.
fromintegerStart, unix seconds, trade server time (copy_ticks_from's date_from).
tointegerEnd, unix seconds, trade server time; ticks within that second are included.
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 Ticks.
A TickHistory object.
symbolstring requiredSymbol name, as the broker spells it.
kept_from_mscinteger or null requiredtime_msc of the oldest tick kept for the symbol, whatever the request asked: how far back GET /ticks can reach right now. null while none is kept (a symbol subscribed just now, or TERMLESS_TICK_HISTORY=0).
ticksarray of HistoryTick requiredTicks, oldest first.
HistoryTick fields
timeinteger requiredUnix seconds, trade server clock.
time_mscinteger requiredUnix milliseconds, trade server clock.
bidnumber requiredBid after the tick (the previous one when the tick did not change it).
asknumber requiredAsk after the tick (the previous one when the tick did not change it).
lastnumber requiredLast deal price after the tick. 0 for most forex and CFD symbols.
volumeinteger requiredThe tick's volume; 0 unless the tick changed it (flag 16).
flagsinteger requiredMetaTrader's TICK_FLAG_* for what the tick changed, added together: 2 bid, 4 ask, 8 last, 16 volume.
volume_rawinteger requiredThe broker's volume number (lots times 10^8), as volume (0.7.0).
volume_realnumber requiredThe volume in lots (0.7.0).
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/ticks?symbol=XAUUSD&count=100" \
-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/ticks", headers=auth, params={"symbol": "XAUUSD", "count": 100})
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/ticks?symbol=XAUUSD&count=100", 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/ticks?symbol=XAUUSD&count=100`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"symbol": "XAUUSD",
"kept_from_msc": 1790980874102,
"ticks": [
{
"time": 1790981179,
"time_msc": 1790981179473,
"bid": 2391.42,
"ask": 2391.6,
"last": 0,
"volume": 0,
"volume_raw": 0,
"volume_real": 0.0,
"flags": 6
},
{
"time": 1790981179,
"time_msc": 1790981179688,
"bid": 2391.45,
"ask": 2391.6,
"last": 0,
"volume": 0,
"volume_raw": 0,
"volume_real": 0.0,
"flags": 2
}
]
}