Short answer: The TradeLocker API is a REST API: you log in with your email, password and broker server to get a JWT, then call /trade routes with that token and an accNum header. Rate limits are per route and come from /trade/config, and your broker or prop firm controls the account, leverage and features. Offline tests on 26 November 2026 found the official Python client 0.56.2 resending an order after a timeout and logging the password by default.
Official TradeLocker pages were read on 26 November 2026. No TradeLocker account was used, so login, orders and real limits were not run; the code below ran offline against the reference's example data and mocks. No broker or prop firm is recommended, ranked or linked with a referral.
TradeLocker API documentation: what exists, read 26 November 2026
TradeLocker publishes two separate APIs: the Public API for traders and third-party developers, and the Brand API for brokers and prop firms that run TradeLocker for their clients.
| Item | Public API | Brand API | Python client |
|---|---|---|---|
| Who it is for | Traders and third-party developers | Brokers and prop firms: account provisioning, back office | Wrapper around the Public API |
| Base URL | demo.tradelocker.com/backend-api or live.tradelocker.com/backend-api | Keys issued to the broker | Same as Public API |
| Version or date | Reference: Trading API 2.11.0, pages updated 26 March 2026; Getting Started updated 22 May 2025 | Getting Started updated 28 May 2025 | tradelocker 0.56.2, released 18 December 2024, MIT |
The reference covers accounts, instruments, sessions, market data, trading and a Studio Creator API. It lists no WebSocket or streaming route, so prices and positions are polled.
TradeLocker API authentication: JWT tokens, accNum and accountId
Log in with email, password and broker server to get a JWT pair, then send the access token and an accNum header on every /trade call.
POST /auth/jwt/tokenwithemail,passwordandserver. The server is the one you pick at web login.GET /auth/jwt/all-accountsreturns each account'sidandaccNum.- Send
Authorization: Bearer <accessToken>andaccNumon/traderoutes. Trading paths also take theaccountId. POST /auth/jwt/refreshwith the refresh token returns a new pair.
Per the Getting Started guide (opens in a new tab), accountId is the multi-digit number shown after # in the platform; accNum is the account's position in your list, usually one digit.
- Token lifetimes are not stated. The reference's 26 May 2023 example tokens decode to 3,600 seconds (access) and 7 days (refresh); read
expfrom your own tokens. - Schema conflict. The refresh schema lists
accessTokenas required but defines onlyrefreshToken; the Python client sends only the refresh token. - Password login only. The pages read show no OAuth or scoped key for a trader's account, so anything holding your credentials can trade. Keep them out of code and logs: API key security for trading bots.
TradeLocker API rate limits and data limits
Limits are set per route and published for your account in GET /trade/config, not on a documentation page, so read them at startup.
Each rateLimits entry gives rateLimitType, measure, intervalNum and limit.
| Route type | Example limit |
|---|---|
| PLACE_ORDER, MODIFY_ORDER, MODIFY_POSITION | 5 per 1 second each |
| QUOTES, DEPTH | 10 per 1 second |
| QUOTES_HISTORY | 3 per 1 second |
| GET_ORDERS, GET_ORDERS_HISTORY, GET_POSITIONS | 1 per 1 second |
| GET_ACCOUNTS_STATE | 4 per 2 seconds |
| Data limits: QUOTES_HISTORY_BARS, MAX_ORDERS_COUNT_IN_HISTORY | 30,000 bars; 10,000 orders |
- Bar limit conflict. The history reference says a request that would return more than 20,000 bars is rejected, while the config example shows 30,000. Use the value your
/trade/configreturns and page by time. - Developer key header conflict. Getting Started calls it
tl-developer-api-key; the order reference and the Python client senddeveloper-api-key. The Developer Program key unlocks less restrictive limits for apps serving several users or accounts from one IP address. - Not documented. The reference lists only 200, 401, 403 and 404, no 429 and no error body schema, and does not say whether limits count per token, account or IP. Pace requests client-side (token bucket rate limiter in Python) and back off on any refusal (exponential backoff with jitter).
What your broker or prop firm controls
Your broker or prop firm controls your account, its leverage and much of what the API can do.
- Accounts and leverage. The Brand API (opens in a new tab) lets the broker create and manage accounts; its guides cover changing leverage plans (opens in a new tab) and a Force Close endpoint (opens in a new tab) that closes a position at a broker-set price, even with the market closed.
- Features per account.
/trade/configreturnscustomerAccessflags for orders, order history, executions, positions, symbol info and market depth; when a flag is false, the reference says not to use that endpoint. - Contract. TradeLocker's Terms & Conditions (opens in a new tab), last updated 20 October 2026, say in clause 1.4 that your broker's or prop firm's terms govern your broker account and your trading.
- Automation clauses. Clause 23.2(2) bars collecting data by bots or scripts except through tools TradeLocker provides, such as Studio; it does not name the API, which clause 3.1 lists as part of the platform. Clause 23.2(1) bars commercial use without written agreement, and Demo Access Terms 7.2(a) (effective 1 April 2026) bar using the demo for any commercial purpose, including to develop, test or optimise automated strategies intended for commercial deployment, unless TradeLocker authorises it in writing. If you build a product, get written confirmation first.
Leveraged forex and CFDs can lose money quickly, and automated trading can lose money. For readers in Turkey, the Capital Markets Board said on 23 February 2023 (opens in a new tab) that residents may trade leveraged forex only through firms it has authorized (Law No. 6362 (opens in a new tab) Articles 99(4) and 109(2)). Elsewhere, rules depend on your country.
TradeLocker Python: what testing the official client showed
The official tradelocker package needs its retry and logging defaults changed before it holds real credentials.
Tested on 26 November 2026 with Python 3.11.3, pip install tradelocker==0.56.2, against a patched requests so nothing left the machine. It needs Python 3.11 or later and pins requests==2.32.2 and PyJWT==2.8.0 exactly; the repository's last push was 18 December 2024.
| Finding | Evidence | What to do |
|---|---|---|
| Orders are resent after a network error | Any RequestException, read timeouts included, is retried up to three more times. After a timeout on the first POST, the mock received two market orders and the client returned the second ID | Send orders once; after a timeout, check before resending (client order IDs) |
| Password in the log | Default log_level is debug; the log printed the login body with the password, and the Bearer token, to stderr | Pass log_level="info" |
| One-second wait on every call | Every attempt, the first included, waits 1 second; login plus account lookup took 2.0 seconds | Know this before measuring latency |
| Extra query parameters | Every request adds ref=py_c and a version string (0.56.1 in 0.56.2) | Expect them in proxies and logs |
| strategyId length | The client allows 32 characters; the order reference says up to 31 | Keep tags to 31 |
Unofficial wrappers also hold your password: read one before use, and never use one to get around a broker's or TradeLocker's terms.
Offline-tested code: limits, columns and order bodies
This standard-library module reads limits from /trade/config, names array rows, and rejects bad order inputs.
Positions and orders come back as arrays of strings in the column order /trade/config defines, so reading by index breaks when columns change. The reference types IDs as integers but one example shows "123", so the module accepts both. After a timeout, search orders and history for your strategyId before resending; the reference does not say it is unique.
import math, time
from collections import deque
def data(resp):
if not (isinstance(resp, dict) and resp.get("s") == "ok" and "d" in resp):
raise RuntimeError(f"unexpected TradeLocker body: {repr(resp)}")
return resp["d"]
def rate_limits(config):
unit = {"SECONDS": 1, "MINUTES": 60}
out = {}
for r in data(config).get("rateLimits", []):
name = r.get("rateLimitType")
if not name or name in out:
raise ValueError(f"missing or repeated rateLimitType {repr(name)}")
limit, window = int(r["limit"]), int(r["intervalNum"]) * unit[r["measure"]]
if limit < 1 or window < 1:
raise ValueError(f"{name}: limit and interval must be positive")
out[name] = (limit, window)
return out
class Throttle:
def __init__(self, limits, clock=time.monotonic):
self.limits, self.clock, self.sent = limits, clock, {}
def wait(self, route):
limit, window = self.limits[route] # unknown route: fail loudly
q = self.sent.setdefault(route, deque())
while q and self.clock() - q[0] >= window:
q.popleft()
return 0.0 if len(q) < limit else window - (self.clock() - q[0])
def record(self, route):
self.sent.setdefault(route, deque()).append(self.clock())
def table(config, panel, rows):
cols = [c["id"] for c in data(config)[panel]["columns"]]
if len(set(cols)) < len(cols):
raise ValueError(f"{panel}: repeated column id")
if {len(r) for r in rows} - {len(cols)}:
raise ValueError(f"{panel}: row length differs from {len(cols)} columns")
return [dict(zip(cols, r)) for r in rows]
def instrument(instruments, name, route_type="TRADE"):
hits = [i for i in instruments if i.get("name") == name]
routes = [r["id"] for h in hits for r in h.get("routes", []) if r.get("type") == route_type]
if len(hits) == 1 and len(routes) == 1:
return hits[0]["tradableInstrumentId"], routes[0]
raise LookupError(f"{repr(name)}: {len(hits)} matches, {len(routes)} {route_type} routes")
def order_body(inst_id, route_id, side, qty, kind="market", price=0.0, tag=""):
ids = [int(i) if str(i).isdecimal() else 0 for i in (inst_id, route_id)]
if min(ids) < 1:
raise ValueError(f"bad instrument or route id {repr(inst_id)}, {repr(route_id)}")
inst_id, route_id = ids
if bool in (type(qty), type(price)):
raise ValueError("bool qty or price")
qty, price = float(qty), float(price)
if not math.isfinite(qty) or qty <= 0:
raise ValueError(f"bad qty {qty}")
if side not in ("buy", "sell") or kind not in ("market", "limit", "stop"):
raise ValueError("bad side or type")
if kind in ("limit", "stop") and not (math.isfinite(price) and price > 0):
raise ValueError(f"{kind} order needs a finite price")
if len(tag) > 31:
raise ValueError("strategyId is limited to 31 characters")
body = {"tradableInstrumentId": inst_id, "routeId": route_id, "side": side,
"qty": qty, "type": kind, "validity": "IOC" if kind == "market" else "GTC",
"stopPrice" if kind == "stop" else "price": price}
if tag:
body["strategyId"] = tag
return bodyOutput from the offline test run, 26 November 2026 (example config and position from the reference; other inputs synthetic; no HTTP calls):
18 routes; PLACE_ORDER (5, 1) GET_ACCOUNTS_STATE (4, 2)
waits for 6 orders in the same instant: [0.0, 0.0, 0.0, 0.0, 0.0, 1.0]
position: buy 10 90415.16 stopLossId None
EURUSD -> (206, 1152263)
duplicate name -> LookupError: 'XAUUSD': 2 matches, 2 TRADE routes
empty route id -> ValueError: bad instrument or route id 206, ''
qty 1e400 -> ValueError: bad qty inf
limit without price -> ValueError: limit order needs a finite price
error body -> RuntimeError: unexpected TradeLocker body: {'s': 'error'}
limit 0 -> ValueError: QUOTES: limit and interval must be positive
short row -> ValueError: positionsConfig: row length differs from 11 columns
unknown route -> KeyError: 'PLACE_ORDERS'
{'tradableInstrumentId': 206, 'routeId': 1152263, 'side': 'buy', 'qty': 0.1, 'type': 'market', 'validity': 'IOC', 'price': 0.0, 'strategyId': 'run-2026-11-26-0001'}The KeyError is deliberate: a misspelt route should stop the program. More tests: how to test trading bots.
Orders, positions and closing: the documented behavior
An order and the position it opens have different IDs, and closing a position is an order that may not fill at once.
- Required fields.
qty,routeId,side,validity,typeandtradableInstrumentId; validity must beIOCformarketandGTCforlimitandstop. - Routes. Quote and history calls take the instrument's INFO route ID; orders take its TRADE route ID.
- orderId vs positionId. Once filled, an order leaves
/orders, appears in/ordersHistory, and a new position gets its own ID. Match them through order history. - Closing.
DELETE /trade/positions/{positionId}withqty0 closes all of it, a smallerqtycloses part. The reference says closing is not guaranteed to be complete or immediate: it tries an IOC order, then GTC.
Read positions again after closing; seeorder state machine and cTrader API. Fincode's broker API integration page describes custom integration work in general; naming TradeLocker here does not mean Fincode integrates it or has built on it.
Related guide: TradeStation API.
Frequently asked questions
How do I get a TradeLocker API key?
A trader's account uses JWT tokens from email, password and server, not an API key. An optional developer key from the TradeLocker Developer Program unlocks less restrictive rate limits.
What are the TradeLocker API rate limits?
Each route has its own limit, returned by GET /trade/config for your account; the reference example shows 5 orders and 1 positions request per second.
Does the TradeLocker API support WebSocket streaming?
No streaming route appears in the Public API reference read on 26 November 2026, so prices and positions are polled. Brokers using the Brand API can ask TradeLocker to enable Brand Sockets, which stream changes to their traders' accounts.
Can I use a trading bot on a prop firm TradeLocker account?
That depends on the prop firm. TradeLocker's terms say the broker's or prop firm's terms govern your account and trading, so read the firm's rules on automation first.
Sources
- TradeLocker Public API: Getting Started (base URLs, JWT, accNum, rate and data limits, developer key) (opens in a new tab)
- TradeLocker Public API reference: Fetch JWT token (opens in a new tab)
- TradeLocker Public API reference: Refresh JWT token (opens in a new tab)
- TradeLocker Public API reference: Get configuration (rate limits, data limits, customerAccess) (opens in a new tab)
- TradeLocker Public API reference: Get the historical bars (20,000-bar rule) (opens in a new tab)
- TradeLocker Public API reference: Place a new order (opens in a new tab)
- TradeLocker Public API reference: Close a position (opens in a new tab)
- TradeLocker Public API: Difference between orderId and positionId (opens in a new tab)
- TradeLocker Brand API: Getting Started (broker and prop firm integration) (opens in a new tab)
- TradeLocker Brand API: Forcefully closing positions (opens in a new tab)
- TradeLocker Terms & Conditions and Demo Access Terms (last update 20 October 2026) (opens in a new tab)
- PyPI: tradelocker 0.56.2 (official Python client) (opens in a new tab)
- GitHub: TradeLocker/tradelocker-python (opens in a new tab)
- SPK press release on unauthorized leveraged trading, 23 February 2023 (Turkish) (opens in a new tab)
- Capital Markets Law No. 6362 (Turkish) (opens in a new tab)
This guide is general information about software and markets, not investment, legal or tax advice. Automated trading can lose money, past or backtested performance does not guarantee future results, and the rules that apply depend on your jurisdiction and your exchange's terms. Sources, checks and corrections: see the editorial policy.