Search API Connector Documentation
Import TD Ameritrade Data to Sheets
In this guide, we’ll walk through how to pull data from the TD Ameritrade API directly into Google Sheets, using the API Connector add-on for Sheets.
There are 2 ways to connect to the TD Ameritrade API:
- Preset “Connect” button (OAuth) premium
- API Key. Please check the appendix for detailed instructions to retrieve your token. Please note that this method will work only for their public stock and options endpoints, not for your private account data.
- Before You Begin
- Part 1: Connect to the TD Ameritrade API
- Part 2: Fetch Data from TD Ameritrade
- Part 3: Create a Custom API Request
- Part 4: Example API Requests
- Part 5: API Documentation
- Appendix: Connect with a Personal API Key
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Connect to the TD Ameritrade API
The easiest way to get started with the TD Ameritrade API is through API Connector’s built-in integration.
- Select TD Ameritrade from the drop-down list of applications
- Under Authorization, click Connect to TD Ameritrade
- You will see a modal asking you to approve the connection. Click Allow.
- You’ll then be returned to your Google Sheet, and can verify that your connection is active.
Part 2: Fetch Data from TD Ameritrade
Now that we’re connected, let’s pull some data into Sheets.
- Under Endpoint, choose
/accountsto get information about your accounts
- Select a destination sheet, name your request, and click Run.
- Note the accountId as you can plug that into other requests.
Part 3: Create a Custom Request
Alternatively, you can create a custom request instead of using API Connector’s built-in integration. When you create a custom request, you add your complete URL into the request URL field, and choose TD Ameritrade from the OAuth menu.
Part 4: Example Custom API Requests
- Option chains (set to ‘grid’ report style)
- User Principals (OAuth only)
- User Transactions (OAuth only)
Part 5: API Documentation
To see more API endpoints and example responses, check out out the TD Ameritrade docs located at https://developer.tdameritrade.com/apis.
They also provide URL generator forms, you can see an example here: https://developer.tdameritrade.com/option-chains/apis/get/marketdata/chains
Appendix: Get Your TD Ameritrade API Key
This section is presented as a free alternative to the above. Instead of clicking Connect, you will get your own API key. However, the API key does not permit access to private account endpoints.
- Register a TD Ameritrade Developer account at https://developer.tdameritrade.com/user/register
- Navigate to https://developer.tdameritrade.com/user/me/apps and click Add a new App
- Fill in your app details. The callback URL can be anything. Here I’ve used https://google.com
- Click Create App and then click on the App name
- You’ll now see your app details displayed.
- To make a request, append your API key like this:
- Since you’re using your own API key, leave OAuth set to None.