{"id":7728,"library":"snaptrade-python-sdk","title":"SnapTrade Python SDK","description":"The SnapTrade Python SDK provides a client library to easily interact with the SnapTrade API, enabling applications to connect brokerage accounts for live positions and trading. It abstracts away direct API calls, handling authentication and data formatting. The library is actively maintained with frequent updates, currently at version 11.0.177, and supports Python versions 3.8 and newer.","status":"active","version":"11.0.177","language":"en","source_language":"en","source_url":"https://github.com/passiv/snaptrade-python-sdk","tags":["finance","brokerage","trading","investment","fintech","api-client"],"install":[{"cmd":"pip install snaptrade-python-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary client class changed from SnapTradeAPIClient in older SDK versions to SnapTrade in the current major version. Ensure you are importing from 'snaptrade_client'.","wrong":"from snaptrade.api_client import SnapTradeAPIClient","symbol":"SnapTrade","correct":"from snaptrade_client import SnapTrade"},{"note":"Used for catching API-specific errors.","symbol":"ApiException","correct":"from snaptrade_client import ApiException"}],"quickstart":{"code":"import os\nfrom pprint import pprint\nfrom snaptrade_client import SnapTrade, ApiException\n\nCLIENT_ID = os.environ.get('SNAPTRADE_CLIENT_ID', 'YOUR_CLIENT_ID')\nCONSUMER_KEY = os.environ.get('SNAPTRADE_CONSUMER_KEY', 'YOUR_CONSUMER_KEY')\n\nif not CLIENT_ID or not CONSUMER_KEY:\n    print(\"Please set SNAPTRADE_CLIENT_ID and SNAPTRADE_CONSUMER_KEY environment variables.\")\nelse:\n    try:\n        # 1. Initialize the SnapTrade client\n        snaptrade = SnapTrade(\n            consumer_key=CONSUMER_KEY,\n            client_id=CLIENT_ID,\n        )\n\n        # 2. Check API status\n        api_status_response = snaptrade.api_status.check()\n        print(\"API Status:\")\n        pprint(api_status_response)\n\n        # 3. Register a new user (or use an existing one)\n        # In a real application, you'd associate this user_id with your own user system.\n        # user_id = \"unique-user-id-from-your-app\"\n        # register_response = snaptrade.authentication.register_snap_trade_user(user_id=user_id)\n        # user_secret = register_response.user_secret\n        # print(f\"Registered user: {register_response.user_id}, Secret: {user_secret}\")\n\n        # Example: List existing users (for demonstration)\n        list_users_response = snaptrade.authentication.list_snap_trade_users()\n        if list_users_response and list_users_response.users:\n            print(\"\\nExisting SnapTrade users:\")\n            for user_info in list_users_response.users:\n                pprint(user_info)\n        else:\n            print(\"\\nNo SnapTrade users found yet. Register one to proceed with connections.\")\n\n    except ApiException as e:\n        print(f\"An API error occurred: {e}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the SnapTrade client, check the API status, and interact with user registration/listing. You will need your SnapTrade `CLIENT_ID` and `CONSUMER_KEY` (obtained from your SnapTrade Dashboard) configured as environment variables. For actual user management and connections, you would register a user with a unique `user_id` from your application, obtain a `user_secret`, and then use these credentials to generate a connection portal URL."},"warnings":[{"fix":"Update your imports from `snaptrade.api_client.SnapTradeAPIClient` to `snaptrade_client.SnapTrade`.","message":"The import path for the main client class changed significantly in major version 11. Older versions used `from snaptrade.api_client import SnapTradeAPIClient`, while current versions use `from snaptrade_client import SnapTrade`.","severity":"breaking","affected_versions":"<11.0.0"},{"fix":"Store `CLIENT_ID`, `CONSUMER_KEY`, and `userSecret` securely (e.g., environment variables, AWS Secrets Manager, Google Secret Manager) and retrieve them at runtime. Do not commit these to version control.","message":"The `consumerKey` and `userSecret` are highly sensitive. Never hardcode them directly into your application's source code, especially for public-facing deployments. Use environment variables or a secure secret management system.","severity":"gotcha","affected_versions":"All"},{"fix":"Implement retry logic with exponential backoff for API requests. Design your application to avoid aggressive bursts of requests, especially during data synchronization or high user signup volumes. Contact SnapTrade support if you require higher rate limits.","message":"The SnapTrade API implements rate limiting, typically 250 requests per minute per client. Exceeding this limit will result in HTTP 429 'Too Many Requests' errors.","severity":"gotcha","affected_versions":"All"},{"fix":"Always explicitly install `snaptrade-python-sdk` using `pip install snaptrade-python-sdk` and verify that imports reference `snaptrade_client`.","message":"There might be confusion with an older, deprecated Python package also named 'snaptrade'. Ensure you are installing and using `snaptrade-python-sdk`, which is the actively maintained SDK.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change the import statement to `from snaptrade_client import SnapTrade`.","cause":"Attempting to import the client using an outdated import path from an older major version of the SDK.","error":"ModuleNotFoundError: No module named 'snaptrade.api_client'"},{"fix":"Verify that your `SNAPTRADE_CLIENT_ID` and `SNAPTRADE_CONSUMER_KEY` environment variables are correct and match the credentials from your SnapTrade Dashboard. Ensure the `user_secret` (if applicable) is also correct and not compromised. If the issue persists, contact SnapTrade support.","cause":"This error typically indicates incorrect `CLIENT_ID`, `CONSUMER_KEY`, or `userSecret` used in the request, or an issue with the signature generation (which the SDK handles automatically if credentials are correct).","error":"snaptrade_client.exceptions.ApiException: (401) Reason: Unauthorized HTTP response headers: {'Content-Type': 'application/json'} HTTP response body: {'error': 'Unable to verify signature sent'}"},{"fix":"Implement retry logic with exponential backoff. Distribute API calls over time, especially for bulk operations. Consider contacting SnapTrade support for an increased rate limit if your use case demands it.","cause":"The application has exceeded the API rate limit (default 250 requests per minute).","error":"snaptrade_client.exceptions.ApiException: (429) Reason: Too Many Requests HTTP response headers: {'Content-Type': 'application/json', 'X-RateLimit-Limit': '250', 'X-RateLimit-Remaining': '0', 'X-RateLimit-Reset': 'X'}"}]}