schwab-rs
Rust client library for the Schwab API.
Wraps the Schwab Market Data and Trader REST APIs with typed methods and models so callers don't need to build URLs or parse raw JSON.
[!IMPORTANT]
schwab-rsis an unofficial project. It is not affiliated with, endorsed by, or sponsored by Charles Schwab & Co., Inc., Schwab brokerage services, or thinkorswim.
Features
- Market Data - quotes, option chains, expiration chains, instruments, market hours, movers, price history
- Trader - accounts, orders (place/replace/cancel/preview), transactions, user preferences
- OAuth2 auth - PKCE authorization code flow, file-backed token storage, automatic refresh via
Provider - Async - built on
tokioandreqwestwithrustlsfor TLS
Quick start
Add schwab from crates.io:
[]
= "0.1"
use ;
async
Authentication
Schwab requires OAuth2 with a browser approval step. For local development, set the app credentials in environment variables and run the auth example:
SCHWAB_CLIENT_ID='your-app-key' \
SCHWAB_CLIENT_SECRET='your-app-secret' \
SCHWAB_CALLBACK_URL='https://127.0.0.1:8182/callback' \
SCHWAB_TOKEN_PATH='schwab-token.json' \
The auth example writes a token file that Provider::from_token_file can refresh and turn into a ready-to-use Client. See docs/auth.md, examples/auth.rs, and examples/quotes.rs for the full flow.
Do not commit Schwab client secrets, authorization codes, access tokens, refresh tokens, token files, or account data. Prefer environment variables or a secret manager for credentials, and see SECURITY.md for reporting and token-handling guidance.
Feature flags
| Feature | Default | Purpose |
|---|---|---|
decimal |
No | Enables rust_decimal support for models where decimal precision is preferable to floating-point values. |
test_online |
No | Enables live integration tests that call the Schwab API. Use only with explicit credentials and never in untrusted CI. |
Enable optional features with Cargo:
Run live tests only when you intentionally want network access:
API stability
schwab-rs is pre-1.0. Public APIs may change while the crate tracks Schwab API behavior and fills out coverage for Market Data and Trader endpoints. Pin an exact crate version for production use.
Minimum supported Rust version
This crate requires Rust 1.95 or later and uses Edition 2024.
License
Apache-2.0. See LICENSE for details.