{"id":28169,"library":"schwab-py","title":"schwab-py","description":"An unofficial Python API wrapper for the Schwab HTTP API, providing access to trading, account data, market data, and streaming. Current version is 1.5.1, requires Python >=3.10. Active development with frequent releases.","status":"active","version":"1.5.1","language":"python","source_language":"en","source_url":"https://github.com/alexgolec/schwab-py","tags":["schwab","trading","api","stocks","options"],"install":[{"cmd":"pip install schwab-py","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"In v1.0.0+, the auth module is a subpackage; top-level import from schwab.auth is deprecated.","wrong":"from schwab.auth import client_from_token_file","symbol":"auth.client_from_token_file","correct":"from schwab import auth; client = auth.client_from_token_file('/path/to/token.json', 'your-app-key', 'your-app-secret')"},{"note":"easy_client is a function within the auth subpackage, not directly on schwab.","wrong":"from schwab import easy_client","symbol":"auth.easy_client","correct":"from schwab.auth import easy_client"},{"note":"Client class is in the client subpackage.","wrong":"from schwab import Client","symbol":"client.Client","correct":"from schwab.client import Client"}],"quickstart":{"code":"import os\nfrom schwab import auth\nfrom schwab.client import Client\n\n# Set up authentication (first time will open browser for OAuth)\ntoken_path = '/path/to/token.json'\napp_key = os.environ.get('SCHWAB_APP_KEY', 'your-app-key')\napp_secret = os.environ.get('SCHWAB_APP_SECRET', 'your-app-secret')\n\n# On first run, this will prompt for login via browser\ntry:\n    client = auth.client_from_token_file(token_path, app_key, app_secret)\nexcept FileNotFoundError:\n    # Token file doesn't exist yet; perform initial login\n    client = auth.easy_client(app_key, app_secret, token_path)\n\n# Get account info\naccounts = client.get_account_numbers()\nprint(accounts)\n\n# Get a quote\nquote = client.get_quote('AAPL')\nprint(quote)","lang":"python","description":"Initialize client and fetch account numbers and a stock quote."},"warnings":[{"fix":"Use a separate browser profile or incognito window when running easy_client.","message":"The easy_client utility logs you out of all other Schwab API sessions in the browser. Use only on a dedicated browser or incognito window.","severity":"breaking","affected_versions":"all"},{"fix":"Use 'from schwab import auth' and then auth.client_from_token_file().","message":"Importing from schwab.auth (e.g., from schwab.auth import client_from_token_file) is deprecated in favor of from schwab import auth; auth.client_from_token_file(...).","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Store token file securely and back it up. If lost, delete token file and re-run easy_client.","message":"The token file is a JSON file that must be kept secret. The library automatically refreshes tokens, but if the file is deleted or corrupted, you must re-authenticate.","severity":"gotcha","affected_versions":"all"},{"fix":"Implement your own retry logic with exponential backoff for 429 responses.","message":"Schwab's API has rate limits. The library does not handle rate limiting automatically; you may get 429 errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run 'pip install schwab-py' and ensure you are using the correct Python interpreter.","cause":"Library not installed or installed for a different Python environment.","error":"ModuleNotFoundError: No module named 'schwab'"},{"fix":"Run auth.easy_client(app_key, app_secret, token_path) to perform initial OAuth flow and generate the token file.","cause":"Token file path is incorrect or file doesn't exist; first-time setup required.","error":"FileNotFoundError: [Errno 2] No such file or directory: '/path/to/token.json'"},{"fix":"Delete the token file and re-authenticate using easy_client. Ensure system time is accurate.","cause":"Token expired and automatic refresh failed (e.g., network issue or invalid refresh token).","error":"schwab.auth.AuthError: Access token expired"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}