Free learning tools Test your finance and trading knowledge before you build, buy, or automate.
Charles Schwab API · Python

Charles Schwab API Python Tutorials

Official Schwab REST and streaming APIs, explained through the two Python wrappers that actually work: schwabdev and schwab-py. Every guide is written from the source code — OAuth token lifetimes, endpoint paths, order payloads, WebSocket subscriptions, rate limits and the production failure modes that documentation usually skips.

What the Schwab API actually gives you

APIBase pathWhat it covers
Trader API/trader/v1Account balances, positions, orders, executions, transactions, user preferences and streamer credentials.
Market Data API/marketdata/v1Quotes, option chains, option expirations, price history, movers, market hours and instrument metadata.
OAuth 2.0/v1/oauthAuthorization-code login, access token, refresh token and token rotation.

The commonly cited rate ceilings are 120 market-data calls per minute and 60 trading/account calls per minute. Treat them as ceilings, not targets: option chains and multi-symbol quotes can consume a request budget quickly.

Which wrapper should you start with?

NeedBetter starting point
Fastest first request, automatic token refresh, encrypted token DBschwabdev
Async quote fan-out or concurrent API callsschwabdev (ClientAsync)
WebSocket streaming with automatic restartschwabdev (Stream)
Explicit typed order builders and enum validationschwab-py
Thin, unopinionated access to every endpointschwab-py
Existing tda-api codebaseschwab-py migration path

Production checklist before you trade

  • Keep app_key, app_secret and tokens out of Git. Use environment variables and a secret manager.
  • Use an exact callback URL. https://127.0.0.1:8182 is the practical default; trailing slashes and case matter.
  • Persist tokens securely: SQLite with Fernet encryption in schwabdev, or a permission-restricted JSON token file in schwab-py.
  • Handle 401 (token), 403 (entitlement), 429 (rate limit) and 5xx separately. Never blind-retry an order POST.
  • Reconcile orders and positions from the API before acting; the stream is a notification channel, not the source of truth.
  • The API has no paper-trading environment. Test with small live size, a separate account, or simulated execution from recorded data.

Need a Custom Schwab or Multi-Broker Python Bot?

We build Python execution engines, scanners and dashboards for Charles Schwab, Interactive Brokers and MT5 — with OAuth, risk controls, reconciliation, logging and VPS deployment.

Discuss Your Build MT4/MT5 Development

Disclosure: schwabdev and schwab-py are unofficial, MIT-licensed community projects and are not affiliated with or endorsed by Charles Schwab. API access, entitlements and rate limits are governed by Schwab's developer terms. Nothing on this page is financial advice.

🚀 Invite friends — Earn $5 You both get $5 credit on Go Ad · opencode.ai AI-Powered Coding Agent — Try Free Build apps, fix bugs & ship faster with opencode. Get $5 free credit when you join. × Ad · quo.com QuoPhone — $20 Visa Gift Card Free Sign up to Quo, subscribe 3 months, get a $20 Visa gift card. Atif's referral gift for you. ×