Short answer: The TradeStation API is TradeStation's REST and HTTP streaming interface (v3) for equities, options and futures, reached at api.tradestation.com/v3 for live accounts and sim-api.tradestation.com/v3 for the simulator. Its documentation, read 26 November 2026, describes OAuth 2.0 with 20-minute access tokens; funded TradeStation account holders request a key by email. Quotas return HTTP 429, and an order reply with HTTP 200 can still contain errors.
No TradeStation account was available: the sample code ran offline on synthetic data. Official pages were read on 26 November 2026; where two disagree, both versions are given. Nothing here recommends TradeStation; automated trading can lose money. Other brokers are in the stock and broker API guides.
TradeStation API documentation: what it covers and who gets a key
The v3 API covers market data, accounts and order execution, and keys go only to TradeStation account holders.
| Item | What the docs say |
|---|---|
| Live base URL | https://api.tradestation.com/v3 |
| Simulator base URL | https://sim-api.tradestation.com/v3 |
| Asset classes | Equities, options and futures with a single key (developer FAQ) |
| Getting a key | FAQ: you must have a TradeStation account; funded account holders request one by email to Client Experience |
| Business use | Multi-user apps apply through a Fintech Solutions form; issuing a key "requires internal review and onboarding" |
| Limits without partner status | Your own TradeStation logins only; 15 logins per application |
The pages read state no minimum balance and no API or data costs (the consumer Trading API page did not open). An undated TradeStation booklet lists cryptocurrency; the developer pages do not, so treat crypto access as unconfirmed.
TradeStation API authentication: OAuth 2.0 and 20-minute tokens
TradeStation uses the OAuth 2.0 authorization code flow, and access tokens expire after 20 minutes.
- Endpoints. Authorize at
https://signin.tradestation.com/authorize, exchange the code athttps://signin.tradestation.com/oauth/token, withaudience=https://api.tradestation.com. - Scopes.
openidis always required andoffline_accessis needed for a refresh token. Defaults:MarketData,ReadAccountandTrade, plusOptionSpreadsandMatrixon the scopes page; others on request. - Callbacks. Allowed by default:
http://localhostand ports 80, 3000, 3001, 8080 and 31022. Other URLs go through Client Experience. - PKCE. For single-page and native apps, on request to Client Experience.
- Access tokens.
expires_inis 1200 seconds; reuse a token and refresh near expiry, not before every request.
Refresh tokens: two pages, two numbers
By default refresh tokens never expire. On request they can be made to rotate, but the authentication overview says every 40 minutes while the refresh token page says every 30 minutes; with rotation on, a 24-hour absolute lifetime forces a new sign-in daily. Ask which applies to your key. Rotating the client secret does not invalidate earlier non-expiring refresh tokens.
The revocation trap. The refresh token page says one call to /oauth/revoke revokes all refresh tokens for the API key, not just the one you send. A logout button wired to it signs out every user of the key. Its example body also uses a token field while its table names refresh_token, so test which one is accepted. Store them as secrets (see API key security for trading bots).
TradeStation simulator API: what SIM shows and what it hides
SIM is the live API on another host, with fake money and instant simulated fills: it tests code paths, not execution.
The SIM vs. LIVE page says SIM is identical to the live API except for those points, and warns that TradeStation is not liable for mistakes by apps that let users switch between SIM and live. It does not say whether market data differs or whether one token works on both hosts. TradeStation's undated API booklet says the simulator is only available to customers who have funded their brokerage account.
Instant fills hide the partial-fill states your order logic must handle (see the paper trading API guide). Make the live host an explicit setting that defaults to SIM.
TradeStation API rate limits: rolling quotas and bar credits
Each key has per-user quotas by resource category over rolling intervals, and going over returns HTTP 429 with "Rate quota exceeded" or "Stream quota exceeded".
| Category | Quota | Interval |
|---|---|---|
| Accounts, Balances, Positions, Order Details, Option Spread Name, Position Groups | 320 each | 5 minutes |
| Quote Snapshot; Quote Change, Barchart and TickBar streams | 500 each | 5 minutes |
| Each other option endpoint | 90 | 1 minute |
| MarketDepth stream (quotes and aggregates combined) | 30 | 1 minute |
Capacity refills gradually; the page's example, 500 requests over 300 seconds, returns one request every 0.6 seconds, so 320 per 5 minutes is about one every 0.94 seconds. Open streams are capped separately: 10 each for MarketDepth, option quote and option chain streams, 40 each for order and position streams. Responses carry X-RateLimit-Limit, -Period, -Remaining, -Reset and -Resource, plus X-Concurrency-* headers for streams. If headers differ from this table, trust them; a token bucket limiter fits rolling refill.
Historical bars cost credits
Minute bar requests also draw on a pool of 200 credits that refills at 200 a minute. A bars-back request costs barsback x interval / 100,000; a date-range request costs inclusive days / 365, both rounded down to two decimals, with 0.25 or less counting as zero. One intraday request returns at most 57,600 bars (40 days of 24-hour one-minute bars), at most 500,000 minutes by bars back (barsback x interval) and at most 3 calendar years by date range. The docs' examples, recomputed: 2,000 60-minute bars cost 1.20 credits; 3,000 five-minute bars cost 0; 1 January 2023 to 30 June 2024 (547 days) costs 1.49.
TradeStation streaming API: chunked HTTP, not WebSocket
Streams are long-lived HTTP/1.1 responses with Transfer-Encoding: chunked, and the docs say chunk boundaries are not reliable: one chunk can hold part of an object or several.
- Content types.
application/vnd.tradestation.streams.v2+jsonfor market data;v3+jsonfor orders and positions. - Heartbeat. The spec says one is sent after 5 seconds on an idle stream; longer silence is suspect.
- Snapshot. Order and position streams send
{"StreamStatus":"EndSnapshot"}after the initial state. - GoAway, in two shapes. The streaming page documents
{"StreamStatus":"GoAway"}; the spec's market data examples use{"Error":"GoAway","Message":"The server is about to shut down."}. Handle both and reopen the stream. - Errors. After an error such as
{"Symbol":"AAPL","Error":"DualLogon"}the client must end the request.
The page offers newline splitting after de-chunking and recommends a streaming JSON parser; the code below decodes from a buffer, so objects cut across chunks survive. Backoff rules from heartbeat and reconnect apply to HTTP streams too.
TradeStation API Python: placing orders safely, tested offline
Send quantities and prices as strings, set an OrderConfirmID, and read both the Orders and Errors arrays, because the documented 200 reply to Place Order can contain both.
- Duplicates.
OrderConfirmIDis 1 to 22 characters and "used to prevent duplicates", unique per API key, per order, per user. Reuse the same ID when retrying one order; how a duplicate is reported is undocumented (see client order IDs). - Estimate first.
POST /v3/orderexecution/orderconfirmreturns estimated cost and commission without placing the order. - Spec inconsistencies. A single-option example sends
AccountIdwhile the schema requiresAccountID, and examples sendBuyToOpenwhere the enum listsBUYTOOPEN. Place Order's 200 schema is an array; its example is one object. Use the schema's spelling and test in SIM.
The code ran on Python 3.11.3 on 26 November 2026 with synthetic replies shaped like the spec's; the OAuth exchange, real streams and orders need an account and were not run. The docs read here name no Python SDK; TradeStation packages on PyPI and GitHub are community code, a third-party risk.
import json, re
from decimal import Decimal, InvalidOperation
class StreamClosed(Exception): pass # GoAway: open a new stream
class StreamError(Exception): pass # e.g. DualLogon: stop, do not loop
def stream_objects(chunks):
"""Yield JSON objects from chunks split anywhere, as the docs warn."""
dec, buf = json.JSONDecoder(), ""
for chunk in chunks:
buf += chunk
while True:
buf = buf.lstrip()
if not buf:
break
if buf[0] not in "{[" or len(buf) > 1_000_000:
raise StreamError("not JSON, or an object that never ends")
try:
obj, end = dec.raw_decode(buf)
except json.JSONDecodeError:
if "\n" in buf: # a full line that is not JSON
raise StreamError("malformed object")
break # incomplete: wait for more bytes
buf = buf[end:]
if not isinstance(obj, dict):
raise StreamError(f"unexpected item: {repr(obj)}")
if "Heartbeat" in obj:
continue
if obj.get("StreamStatus") == "GoAway" or obj.get("Error") == "GoAway":
raise StreamClosed("server going away")
if "Error" in obj:
raise StreamError(f"{obj.get('Error')}: {obj.get('Message', '')}")
yield obj
def price_text(p, cap=Decimal("1000000")):
try:
d = Decimal(str(p))
except InvalidOperation:
raise ValueError(f"bad price {repr(p)}")
if not d.is_finite() or not 0 < d <= cap: # cap: your own sanity limit
raise ValueError(f"bad price {repr(p)}")
return format(d, "f") # the spec types prices as strings
def confirm_id(raw):
cid = (raw or "").strip()
if not (cid.isascii() and re.fullmatch(r"\S{1,22}", cid)):
raise ValueError("OrderConfirmID: 1 to 22 visible characters")
return cid
def read_place_reply(status, body):
"""A 200 can carry Orders and Errors together; never assume success."""
if status == 401:
return "reauth", []
if status == 429:
return "rate_limited", []
if status >= 500:
return "unknown", [] # the order may exist anyway
try:
data = json.loads(body)
except (TypeError, ValueError):
return "unknown", []
if status >= 300:
msg = data.get("Message", data) if isinstance(data, dict) else data
return "rejected", [str(msg)]
# schema: array; example: one object
replies = [r for r in (data if isinstance(data, list) else [data])
if isinstance(r, dict)]
def rows(key):
return [x for r in replies for x in
(r.get(key) if isinstance(r.get(key), list) else [])
if isinstance(x, dict)]
ok = [o["OrderID"] for o in rows("Orders") if o.get("OrderID")]
bad = [f"{e.get('OrderID', '?')}: {e.get('Message', e.get('Error', '?'))}"
for e in rows("Errors")]
if ok and bad:
return "partial", ok + bad
if ok:
return "accepted", ok
return ("rejected", bad) if bad else ("unknown", [])
def place(send, order, cid):
order = dict(order, OrderConfirmID=confirm_id(cid))
try:
status, body = send(order)
except OSError as e: # urllib's HTTPError is an OSError
if not isinstance(getattr(e, "code", None), int):
return "unknown", [] # lost reply: the order may exist
status, body = e.code, e.read()
return read_place_reply(status, body)Results from the final code: an object split across two chunks plus a heartbeat yielded ['1', 'EndSnapshot', '2']; both GoAway shapes raised StreamClosed; DualLogon, non-JSON and a malformed line raised StreamError. float("1e400"), "1e400", "nan", 0 and -1 were refused as prices, and empty, blank, missing and 23-character confirm IDs as IDs. The spec's Place Order example gave partial (orders 286179829, 286179830 and 286179831, error on 1234567) as an object and as an array; a 503 with HTML, a 502 with JSON, an empty 200 and a dropped connection gave unknown; 401, also raised as urllib's HTTPError, gave reauth, 429 rate_limited. On unknown, look for your OrderConfirmID in the order stream first (see order state machine).
EasyLanguage vs API: which one runs your rules
EasyLanguage runs inside the TradeStation platform; the API serves your own program outside it.
| Question | EasyLanguage | TradeStation API |
|---|---|---|
| Where code runs | In the platform's Chart Analysis, RadarScreen and OptionStation windows | Your server or app |
| Language | TradeStation's own programming language | Any language with HTTP |
| Typical use | Technical indicators and trading strategies | Custom apps, dashboards, multi-user products |
Moving rules from EasyLanguage to the API means rebuilding bar handling, order state and recovery yourself; backtests guarantee nothing. NinjaTrader's similar split is in the NinjaTrader API guide.
Who can use the TradeStation API, and rules by country
API access follows account access, and TradeStation's pages read here do not list which countries' residents it accepts.
Rules depend on your country; check eligibility with TradeStation directly. Options, futures and leverage carry a high risk of loss.
For readers in Turkey, the Capital Markets Board (SPK) said on 23 February 2023 that residents may trade leveraged products such as forex only through institutions it has authorized, that offering them otherwise is a crime, and that it acts to block websites offering them (Law No. 6362 Articles 99(4) and 109(2)). For integration work in general, see Fincode's broker API integration page; naming TradeStation here does not mean Fincode integrates it or has built on it.
Related guide: DXtrade API · TradeLocker API.
Frequently asked questions
How do I get a TradeStation API key?
TradeStation's API FAQ, read 26 November 2026, says you must have a TradeStation account, and funded account holders request a key by email to Client Experience. Business apps apply through a Fintech Solutions form and go through review.
Does TradeStation have a paper trading API?
Yes. Change the base URL to sim-api.tradestation.com/v3 to use fake accounts with simulated money and instant fills. An undated TradeStation booklet says SIM is only for customers who funded their account.
How long do TradeStation API tokens last?
Access tokens last 20 minutes (expires_in 1200). Refresh tokens do not expire by default; rotation can be enabled on request, with a 24-hour absolute lifetime.
Does the TradeStation API use WebSockets?
No. The docs describe streaming over chunked HTTP/1.1 responses, with a heartbeat after 5 seconds of idle time and GoAway messages before the server closes a stream.
Sources
- TradeStation API Docs: Authentication overview (scopes, callbacks, refresh token setting, login limit), read 26 November 2026 (opens in a new tab)
- TradeStation API Docs: Auth Code Flow (endpoints, audience, expires_in) (opens in a new tab)
- TradeStation API Docs: Scopes (required and default scopes) (opens in a new tab)
- TradeStation API Docs: Refresh Tokens (lifetime, rotation, revocation) (opens in a new tab)
- TradeStation API Docs: SIM vs. LIVE (opens in a new tab)
- TradeStation API Docs: Rate Limiting overview (quotas, concurrency, headers) (opens in a new tab)
- TradeStation API Docs: Limits for large minute-based historical bar requests (opens in a new tab)
- TradeStation API Docs: HTTP Streaming (opens in a new tab)
- TradeStation API Specification v3 (Place Order, Order Confirm, stream schemas), read 26 November 2026 (opens in a new tab)
- TradeStation API Docs: FAQ (how to get an API key) (opens in a new tab)
- TradeStation Developer: Brokerage Trading API (asset classes, key review) (opens in a new tab)
- TradeStation: The TradeStation API booklet (PDF, undated) (opens in a new tab)
- TradeStation Help: What Is EasyLanguage (opens in a new tab)
- SPK (Capital Markets Board): Notice on unauthorized leveraged transactions, 23 February 2023 (Turkish) (opens in a new tab)
- Capital Markets Law No. 6362, consolidated text, Articles 99 and 109 (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.