Guide
BrokerMarket dataStocksETFsOptions API key

Charles Schwab Trader API guide

When TD Ameritrade moved into Charles Schwab, its popular retail API moved too, as the Schwab Trader API. It is free for Schwab clients and covers stocks, ETFs and options, but authentication is OAuth 2.0 rather than a static key, so the first step is a browser login.

Last verified · Also known as Schwab API, TD Ameritrade API, thinkorswim API

Quick answer

The Schwab Trader API replaced the TD Ameritrade API after the merger. It covers stock, ETF and options trading, account data, quotes, price history and streaming, and it uses OAuth 2.0: you register an app on developer.schwab.com, log in through a browser once, then keep the session alive with refresh tokens.

Charles Schwab Trader API at a glance

Pricing
API free with a Schwab account
Availability
US Schwab brokerage clients
Paper trading
No sandbox
Integration type
OAuth login
In AlgoGP
Design and backtest in AlgoGP, connect the exported code
Portal
developer.schwab.com
Auth
OAuth 2.0 authorization code, then refresh tokens
Products
Accounts and Trading Production; Market Data Production
Markets
US stocks, ETFs, options
Python
Community schwab-py (successor of tda-api)

What the Schwab Trader API covers

Schwab’s individual developer API exposes two products: Accounts and Trading (balances, positions, orders, transactions) and Market Data (quotes, option chains, price history, movers, streaming). It is designed for self-directed Schwab clients building tools for their own accounts.

OAuth 2.0: the part everyone gets stuck on

  1. 1

    Register an app

    Create an app on the developer portal with a callback URL (e.g. https://127.0.0.1). Approval can take a few days.

  2. 2

    Authorize once in a browser

    Open the authorize URL, log in with your Schwab brokerage credentials, approve the accounts, and copy the code from the redirect.

  3. 3

    Exchange for tokens

    POST the code to the token endpoint with your app key and secret (Basic auth) to get an access token (short-lived, about 30 minutes) and a refresh token.

  4. 4

    Refresh on a schedule

    Use the refresh token to get new access tokens. The refresh token itself expires (7 days), after which the browser login must be repeated.

Common problems

App stuck in “Approved – Pending”
New apps need Schwab review before they work; wait for Ready For Use.
invalid_grant on refresh
The refresh token expired or was used after a re-login; redo the browser authorization.
Callback URL mismatch
The redirect must exactly match the URL registered on the app, including trailing slash and scheme.

Build a Charles Schwab Trader API strategy with AlgoGP

AlgoGP does not connect to Charles Schwab Trader API natively yet. Charles Schwab Trader API authenticates with a browser OAuth login and refreshable tokens, so it needs a one-time manual login step that generated code cannot do on its own.

  1. 1

    Design and backtest in AlgoGP

    Describe the strategy to the copilot and backtest it on years of normalized history. The result does not depend on any vendor.

  2. 2

    Export the Python project

    Every project exports strategy.py, market_data.py, brokers.py and live.py. The strategy only sees bars, cash, positions and orders, never a vendor’s wire format.

  3. 3

    Plug in Charles Schwab Trader API

    Implement the four adapter methods (account, positions, submit_market_order and a candle fetcher) with Charles Schwab Trader API’s SDK, or keep a built-in platform for paper trading and add Charles Schwab Trader API when you go live.

Built-in brokers for the same markets: Alpaca, Tradier, OKX.

Charles Schwab Trader API: frequently asked questions

Does Schwab have an API?

Yes. The Schwab Trader API offers trading, account and market data endpoints to Schwab clients through developer.schwab.com.

Does the TD Ameritrade API still work?

No. It was retired after the migration to Schwab; use the Schwab Trader API instead.

Is the Schwab API free?

Yes, for Schwab brokerage clients. Normal trading costs apply.

Why do I have to log in again every week?

Schwab refresh tokens expire after about seven days, so a fresh browser authorization is needed periodically.

Can I use the Schwab API with thinkorswim?

The API works on the same Schwab account that thinkorswim uses, but it does not script the thinkorswim desktop app itself.

Design and backtest your Charles Schwab Trader API strategy first

AlgoGP turns an idea into Python and tests it on years of history before you connect it to Charles Schwab Trader API. The exported code keeps the broker behind four small adapter methods.

  • AI copilot writes and revises the rules
  • Backtests with realistic costs
  • Exported Python ready to wire to Charles Schwab Trader API

Free plan, no card required.

Charles Schwab Trader API alternatives

Independent guide. AlgoGP is not affiliated with Charles Schwab Trader API. Limits, prices and availability change; confirm them in the official documentation. Nothing here is investment advice.