Our great sponsors
-
tda-api
A TD Ameritrade API client for Python. Includes historical data for equities and ETFs, options chains, streaming order book data, complex order construction, and more.
-
td-ameritrade-python-api
Unofficial Python API client library for TD Ameritrade. This library allows for easy access of the Standard API and allows users to build data pipelines for the Streaming API.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Your problem is that you are passing TDA your apikey (consumer key) instead of an access token. The documentation says "Pass your OAuth User ID to make an unauthenticated request for delayed data" and that is what you are doing. You need to use either an access token or a refresh token. This whole OAuth token thing is a little complicated so I suggest using some code that is already working like this. I spent a week debugging my own code for OAuth and then found Alex's code and had it working in a few minutes. This is all I use now.