Short answer: The E*TRADE API is E*TRADE's REST API for accounts, quotes and orders, signed with OAuth 1.0a (HMAC-SHA1) and usable from Python with any correct signer. As read on 26 November 2026, its developer agreement (dated 10/2026) bars algorithmic or automated order generation: each order needs a specific, contemporaneous instruction from the account holder.
Sources: E*TRADE's v1 API reference and developer agreement, read on 26 November 2026, and the OAuth 1.0a specification. No E*TRADE account or key was used. Nothing here recommends E*TRADE or a strategy.
Can you build an automated trading bot on the E*TRADE API?
No: section 4.9 of E*TRADE's API Developer License Agreement (dated 10/2026, read 26 November 2026) prohibits algorithmic or automated order generation through the API.
Section 1.19 covers any logic, rule set, signal, trigger or workflow that submits, modifies, cancels or manages an order without a discrete, contemporaneous and affirmative instruction for that specific order. Such an order is deemed unauthorized and may cost you API access.
| Section | Rule |
|---|---|
| 1.7, 7.1(c) | Individual keys: one Developer ID, personal non-commercial use; vendor keys serve multiple users |
| 4.8 | Orders for others need explicit, contemporaneous instructions or a power of attorney |
| 9.1 | Access can be suspended or ended at any time, with or without notice |
Reading data, analytics and orders a person approves one by one remain possible. How a stop order you enter yourself that triggers later is treated is not stated; ask E*TRADE in writing. Section 7.2 says the Customer Protection Guarantee does not apply.
E*TRADE API key: sandbox and live keys
You need an E*TRADE account, a sandbox consumer key for testing and a separate live key issued under the developer agreement.
The developer portal (developer.etrade.com) returned HTTP 403 to automated requests on 26 November 2026, so its key steps could not be read. Under section 4.1 of the agreement you complete a questionnaire as an individual or vendor developer and receive the consumer key as a message in your E*TRADE account. Sandbox calls go to https://apisb.etrade.com/v1/..., live calls to https://api.etrade.com/v1/.... Store keys and tokens as in API key security for trading bots.
E*TRADE OAuth 1.0a: tokens and the daily login
E*TRADE uses three-legged OAuth 1.0a with HMAC-SHA1 as the only signature method, so a person logs in and approves the application at least once a day.
| Step | Live URL | Rule |
|---|---|---|
| Request token | api.etrade.com/oauth/request_token | oauth_callback=oob; expires in 5 minutes |
| Authorize | us.etrade.com/e/t/etws/authorize?key=...&token=... | User approves; a verification code is shown or sent to a callback |
| Access token | api.etrade.com/oauth/access_token | Expires by default at the end of the day, US Eastern time |
| Renew | api.etrade.com/oauth/renew_access_token | Reactivates a token idle for two hours |
| Revoke | api.etrade.com/oauth/revoke_access_token | Recommended when done |
Timestamps must be accurate within five minutes. The sandbox URL on all five pages has a blank host (https:///request_token). Signing in general: API signature generation.
E*TRADE API documentation: v1 endpoints and limits
The v1 reference, read 26 November 2026, covers accounts, alerts, market data and orders.
| Call | Path | Documented limit |
|---|---|---|
| List accounts | GET /v1/accounts/list | Returns the accountIdKey other calls need |
| Quotes | GET /v1/market/quote/{symbols} | 25 symbols, 50 with overrideSymbolCount=true |
| List orders | GET /v1/accounts/{accountIdKey}/orders | Up to 100 per page; two years of history |
| Preview, place | POST .../orders/preview, .../orders/place | Place within 3 minutes of preview |
| Cancel | PUT .../orders/cancel | Refused once the order has been sent to market |
Check each quote's quoteStatus (such as REALTIME, DELAYED). Option chains: see options trading API.
Preview then place: previewId, clientOrderId and quirks
Each order is previewed, then placed with the returned previewId and identical parameters.
- Expiry. A
previewIdmust be used within 3 minutes. - Shape. The schema says int64, yet the equity sample returns
PreviewIdsas a list of objects with numeric IDs and the options sample as one object holding a string. - clientOrderId. Up to 20 alphanumeric characters, unique within the account, and it "does not appear in any API responses", so after a timeout match recent orders by symbol, side, quantity and price, and stop if two match. See client order ID.
Order error codes, read 26 November 2026: 900 Invalid Preview Id; 1028 duplicate order; 99990 Duplicate Client ID; 1033 order request timed out; 1027 market closed, queued for review (a 200 warning). No error body sample is given.
E*TRADE API Python: OAuth signing tested on a local mock
Standard-library code: an RFC 5849 signer check, then preview-then-place with confirmation on a local mock (Python 3.11.3, 26 November 2026).
import base64, hashlib, hmac, json, re, secrets, threading, time
from decimal import Decimal, InvalidOperation
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.error import HTTPError
from urllib.parse import parse_qsl, quote, unquote, urlsplit
from urllib.request import Request, urlopen
def enc(s):
return quote(str(s), safe="~")
def sign(method, url, params, consumer_secret, token_secret):
u = urlsplit(url)
pairs = sorted((enc(k), enc(v)) for k, v in parse_qsl(u.query, keep_blank_values=True) + list(params))
base = "&".join([method, enc(f"{u.scheme}://{u.netloc.lower()}{u.path}"),
enc("&".join(f"{k}={v}" for k, v in pairs))])
key = f"{enc(consumer_secret)}&{enc(token_secret)}".encode()
return base64.b64encode(hmac.new(key, base.encode(), hashlib.sha1).digest()).decode()
p = [("oauth_consumer_key", "9djdj82h48djs9d2"), ("oauth_token", "kkk9d7dh3k39sjv7"),
("oauth_signature_method", "HMAC-SHA1"), ("oauth_timestamp", "137131201"),
("oauth_nonce", "7d8f3e4a"), ("c2", ""), ("a3", "2 q")]
s = sign("POST", "http://example.com/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b", p, "j49sk3j29djd", "dh893hdasih9")
print("RFC value as printed:", s == "bYT5CMsGcbgUdFHObYMEfcx6bsw=")
print("erratum 2550 value:", s == "r6/TJjbCOr97/+UU0NsvSne7s5g=")
print("quote() default escapes '/':", quote("/iQRg=") == enc("/iQRg="))
class EtradeError(Exception):
pass
def amount(v):
try:
d = Decimal(str(v))
if d.is_finite() and d > 0:
return format(d, "f")
except InvalidOperation:
pass
raise ValueError(f"bad amount {repr(v)}")
def account_key(accounts, account_id):
hits = [a["accountIdKey"] for a in accounts if account_id and a.get("accountId") == account_id]
if len(hits) == 1:
return hits[0]
raise EtradeError(f"{len(hits)} accounts match {repr(account_id)}")
def preview_id(resp):
ids = (resp.get("PreviewOrderResponse") or {}).get("PreviewIds")
ids = ids if isinstance(ids, list) else [ids] if ids else []
found = {int(i["previewId"]) for i in ids if isinstance(i, dict) and str(i.get("previewId")).isdigit()}
if len(found) == 1:
return found.pop()
raise EtradeError(f"expected one previewId, got {sorted(found)}")
class Client:
def __init__(self, base, ck, cs, token, token_secret):
if not all((ck, cs, token, token_secret)): # fail before any network call
raise ValueError("credentials missing")
self.base, self.ck, self.cs, self.tok, self.ts, self.clock = base, ck, cs, token, token_secret, time.monotonic
def call(self, method, path, body=None):
o = {"oauth_consumer_key": self.ck, "oauth_nonce": secrets.token_hex(16), "oauth_token": self.tok,
"oauth_signature_method": "HMAC-SHA1", "oauth_timestamp": str(int(time.time()))}
o["oauth_signature"] = sign(method, self.base + path, o.items(), self.cs, self.ts) # body unsigned
auth = 'OAuth realm="",' + ",".join(f'{k}="{enc(v)}"' for k, v in o.items())
req = Request(self.base + path, json.dumps(body).encode() if body else None, method=method,
headers={"Authorization": auth, "Content-Type": "application/json"})
try:
with urlopen(req, timeout=10) as r:
return json.loads(r.read())
except HTTPError as e:
text = e.read().decode(errors="replace")
try:
err = json.loads(text)
except ValueError:
err = None
err = err.get("Error") if isinstance(err, dict) else None
err = err if isinstance(err, dict) else {}
raise EtradeError(f"HTTP {e.code} code {err.get('code')}: {err.get('message') or text[:40]}")
def preview_then_place(self, key, order, client_order_id, confirm):
if not re.fullmatch(r"[A-Za-z0-9]{1,20}", client_order_id or ""):
raise ValueError(f"bad clientOrderId {repr(client_order_id)}")
req = {"orderType": "EQ", "clientOrderId": client_order_id, "Order": [order]}
resp = self.call("POST", f"/v1/accounts/{key}/orders/preview.json", {"PreviewOrderRequest": req})
pid, started = preview_id(resp), self.clock()
if not confirm(resp["PreviewOrderResponse"]): # a person approves this one order
raise EtradeError("not confirmed, nothing placed")
if self.clock() - started > 170: # docs: place within 3 minutes
raise EtradeError("preview expired")
req["PreviewIds"] = [{"previewId": pid}]
return self.call("POST", f"/v1/accounts/{key}/orders/place.json", {"PlaceOrderRequest": req})
class Mock(BaseHTTPRequestHandler): # checks HMAC-SHA1; not E*TRADE's server
previews, used = set(), set()
log_message = lambda *a: None
def reply(self, code, obj):
self.send_response(code)
self.end_headers()
self.wfile.write((obj if isinstance(obj, str) else json.dumps(obj)).encode())
def do_POST(self):
if self.path == "/limited":
return self.reply(400, "<html>Number of requests exceeded the rate limit set</html>")
o = {k: unquote(v) for k, v in re.findall(r'(\w+)="([^"]*)"', self.headers.get("Authorization", ""))}
sig, realm = o.pop("oauth_signature", ""), o.pop("realm", None)
good = sign("POST", base + self.path, o.items(), "cs1", "ts1")
if not hmac.compare_digest(sig, good):
return self.reply(401, {"Error": {"code": "mock", "message": "signature rejected"}})
req = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
if "PreviewOrderRequest" in req:
self.previews.add(str(2785277279 + len(self.previews)))
return self.reply(200, {"PreviewOrderResponse": {"PreviewIds": {"previewId": max(self.previews)}}})
req = req["PlaceOrderRequest"]
if str(req["PreviewIds"][0]["previewId"]) not in self.previews:
return self.reply(400, {"Error": {"code": 900, "message": "Invalid Preview Id."}})
if req["clientOrderId"] in self.used:
return self.reply(400, {"Error": {"code": 99990, "message": "Duplicate Client ID."}})
self.used.add(req["clientOrderId"])
self.reply(200, {"PlaceOrderResponse": {"OrderIds": [{"orderId": 5}]}})
server = HTTPServer(("127.0.0.1", 0), Mock)
threading.Thread(target=server.serve_forever, daemon=True).start()
base = f"http://127.0.0.1:{server.server_port}"
c = Client(base, "ck1", "cs1", "tok1", "ts1")
order = {"priceType": "LIMIT", "orderTerm": "GOOD_FOR_DAY", "marketSession": "REGULAR", # hypothetical
"limitPrice": amount("100.15"), "Instrument": [{"Product": {"securityType": "EQ", "symbol": "XYZ"},
"orderAction": "BUY", "quantityType": "QUANTITY", "quantity": amount(10)}]}
yes = lambda preview: True # stands in for a person typing "yes"
late = lambda preview: setattr(c, "clock", lambda: time.monotonic() + 200) or True
tests = {
"float 1e400": lambda: amount(float("1e400")),
"no access token": lambda: Client(base, "ck1", "cs1", "", ""),
"empty clientOrderId": lambda: c.preview_then_place("k", order, "", yes),
"two accounts, one ID": lambda: account_key([{"accountId": "1", "accountIdKey": "a"},
{"accountId": "1", "accountIdKey": "b"}], "1"),
"not confirmed": lambda: c.preview_then_place("k", order, "a1", lambda preview: False),
"confirmed": lambda: c.preview_then_place("k", order, "a2", yes),
"confirmed after 200 s": lambda: c.preview_then_place("k", order, "a3", late),
"same clientOrderId": lambda: c.preview_then_place("k", order, "a2", yes),
"wrong secret": lambda: Client(base, "ck1", "bad", "tok1", "ts1").call("POST", "/v1/x", {}),
"HTML error page": lambda: c.call("POST", "/limited"),
}
for name, t in tests.items():
try:
print(f"{name}: {t()}")
except (ValueError, EtradeError) as e:
print(f"{name}: rejected, {e}")
server.shutdown()Output:
RFC value as printed: False
erratum 2550 value: True
quote() default escapes '/': False
float 1e400: rejected, bad amount inf
no access token: rejected, credentials missing
empty clientOrderId: rejected, bad clientOrderId ''
two accounts, one ID: rejected, 2 accounts match '1'
not confirmed: rejected, not confirmed, nothing placed
confirmed: {'PlaceOrderResponse': {'OrderIds': [{'orderId': 5}]}}
confirmed after 200 s: rejected, preview expired
same clientOrderId: rejected, HTTP 400 code 99990: Duplicate Client ID.
wrong secret: rejected, HTTP 401 code mock: signature rejected
HTML error page: rejected, HTTP 400 code None: <html>Number of requests exceeded the raTest vector trap. The signature printed in RFC 5849 section 3.4.1.1 is wrong: verified erratum 2550 says it was calculated as if the method were GET. The signer's base string matched the RFC's printed one exactly.
Python's quote() leaves / unescaped by default, and E*TRADE's sample tokens contain /, so such a signer fails only for some tokens. A confirm that always approves is what section 4.9 forbids. No call to E*TRADE was run (no key).
Rate limits, unofficial libraries and country rules
The v1 pages read on 26 November 2026 state no rate limits, so pace requests and expect non-JSON error pages.
E*TRADE's 2012 PDF for the retired v0 API set per-second and per-hour limits and answered excess requests with an HTML page and status 400; that is unconfirmed for v1. pyetrade 2.1.1 (PyPI, 6 November 2024) comes from an individual, not E*TRADE, and changes nothing in the agreement. Compare Schwab API Python and paper trading API.
Rules depend on your country, and account types and API access vary. Options, futures and leverage carry high risk. For readers in Turkey, the Capital Markets Board (SPK) said on 23 February 2023 that residents may trade on leverage only through institutions it has authorized, with access blocks and criminal penalties for unauthorized offers (Law No. 6362 Articles 99(4) and 109(2)). For integration work, see Fincode's broker API integration page; naming E*TRADE here does not mean Fincode integrates it or has built on it.
Frequently asked questions
Does E*TRADE allow automated trading through its API?
No. Section 4.9 of the developer agreement (dated 10/2026) prohibits algorithmic or automated order generation.
How do I get an E*TRADE API key?
With an E*TRADE account, complete the API questionnaire as an individual or vendor developer; the key arrives as a message in your E*TRADE account. Sandbox and live keys differ.
How long does an E*TRADE access token last?
Until the end of the day, US Eastern time, by default; after two idle hours it needs renewing.
Is there an official E*TRADE Python library?
None was found on readable official pages on 26 November 2026; the developer portal could not be read. Packages such as pyetrade come from individuals.
Sources
- E*TRADE API reference: Get Request Token (opens in a new tab)
- E*TRADE API reference: Authorize Application (opens in a new tab)
- E*TRADE API reference: Get Access Token (opens in a new tab)
- E*TRADE API reference: Renew Access Token (opens in a new tab)
- E*TRADE API reference: Revoke Access Token (opens in a new tab)
- E*TRADE API reference: Order API v1 (preview, place, error codes) (opens in a new tab)
- E*TRADE API reference: Accounts API v1 (opens in a new tab)
- E*TRADE API reference: Get Quotes (opens in a new tab)
- E*TRADE from Morgan Stanley: API Developer License Agreement, CRC 5569530 (10/2026) (opens in a new tab)
- E*TRADE Developer Platform technical documentation, v0 API, 24 October 2012 (legacy rate limits) (opens in a new tab)
- RFC 5849: The OAuth 1.0 Protocol (opens in a new tab)
- RFC Editor: errata for RFC 5849 (erratum 2550, verified) (opens in a new tab)
- PyPI: pyetrade 2.1.1 (unofficial, uploaded 6 November 2024) (opens in a new tab)
- Capital Markets Law No. 6362, consolidated text, Articles 99 and 109 (Turkish) (opens in a new tab)
- SPK (Capital Markets Board): Notice on unauthorized leveraged transactions, 23 February 2023 (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.