Step By Step: Pull Stock Order History With TD Ameritrade API and Python

Paul Lee
The Startup
Published in
8 min readJul 26, 2020

--

There isn’t very good documentation out there on how to connect and use TD Ameritrade’s APIs. In this blog, I’ll be connecting to TD Ameritrade’s APIs with Python to automatically pull order history transactions and store it into a local MySQL database.

Getting Started

All my code is posted on my Github repo for reference. Please feel free to follow my instructional guide below and contact me for improvements or help.

Target Audience:

Non-Brogrammers. I’m a mechanical engineer by discipline so a lot of this stuff wasn’t intuitive to me at first. I believe this guide will serve as a tool for beginner programmers, like me, in getting started.

Instructions

Step 1: Set up a “TD Ameritrade for developers” account

One of the first steps is to create a TDA developer account. Once created, you’ll be able to create an “app.” This app will generate a consumer key in order to connect to their API’s. Below are the steps to get your consumer key:

Navigate to “My Apps” in the navigation bar and click on “Add a new App”

  • App Name: Name_of_your_choice

--

--

Paul Lee
The Startup

M.S. in CS — GaTech | B.S. in ME — UT Austin