{"id":18005592,"url":"https://github.com/areed1192/td-ameritrade-api","last_synced_at":"2025-10-23T23:24:43.411Z","repository":{"id":40376083,"uuid":"354356063","full_name":"areed1192/td-ameritrade-api","owner":"areed1192","description":"The unofficial Python API client library for the Charles Schwab API. This library allows for easy access of the Standard REST API and Streaming API.","archived":false,"fork":false,"pushed_at":"2025-01-15T16:07:55.000Z","size":242,"stargazers_count":125,"open_issues_count":1,"forks_count":37,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-04T01:28:32.187Z","etag":null,"topics":["charles-schwab","charles-schwab-api","finance","investing","python","stocks"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/areed1192.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["areed1192"],"patreon":"sigmacoding"}},"created_at":"2021-04-03T17:44:01.000Z","updated_at":"2025-03-05T03:01:11.000Z","dependencies_parsed_at":"2025-02-27T11:41:25.212Z","dependency_job_id":"ed5978a6-f72f-42b8-888a-9331d18fd3a8","html_url":"https://github.com/areed1192/td-ameritrade-api","commit_stats":{"total_commits":43,"total_committers":3,"mean_commits":"14.333333333333334","dds":"0.046511627906976716","last_synced_commit":"9c112d8668a89cdcd7c16898fb0a8f18cafae378"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":"areed1192/sigma-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/areed1192%2Ftd-ameritrade-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/areed1192%2Ftd-ameritrade-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/areed1192%2Ftd-ameritrade-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/areed1192%2Ftd-ameritrade-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/areed1192","download_url":"https://codeload.github.com/areed1192/td-ameritrade-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248639294,"owners_count":21137819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["charles-schwab","charles-schwab-api","finance","investing","python","stocks"],"created_at":"2024-10-30T00:20:44.076Z","updated_at":"2025-10-23T23:24:38.363Z","avatar_url":"https://github.com/areed1192.png","language":"Python","funding_links":["https://github.com/sponsors/areed1192","https://patreon.com/sigmacoding","https://www.patreon.com/sigmacoding"],"categories":[],"sub_categories":[],"readme":"# Unofficial TD Ameritrade Python API Library\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Setup](#setup)\n- [Usage](#usage)\n- [Support These Projects](#support-these-projects)\n\n## Overview\n\nCurrent Version: **0.1.1**\n\nThe unofficial Python API client library for TD Ameritrade allows individuals with\nTD Ameritrade accounts to manage trades, pull historical and real-time data, manage\ntheir accounts, create and modify orders all using the Python programming language.\n\nTo learn more about the TD Ameritrade API, please refer to\nthe [official documentation](https://developer.tdameritrade.com/apis).\n\n## Setup\n\n**Setup - Requirements Install:***\n\nFor this particular project, you only need to install the dependencies, to use the project. The dependencies\nare listed in the `requirements.txt` file and can be installed by running the following command:\n\n```console\npip install -r requirements.txt\n```\n\nAfter running that command, the dependencies should be installed.\n\n**Setup - Local Install:**\n\nIf you are planning to make modifications to this project or you would like to access it\nbefore it has been indexed on `PyPi`. I would recommend you either install this project\nin `editable` mode or do a `local install`. For those of you, who want to make modifications\nto this project. I would recommend you install the library in `editable` mode.\n\nIf you want to install the library in `editable` mode, make sure to run the `setup.py`\nfile, so you can install any dependencies you may need. To run the `setup.py` file,\nrun the following command in your terminal.\n\n```console\npip install -e .\n```\n\nIf you don't plan to make any modifications to the project but still want to use it across\nyour different projects, then do a local install.\n\n```console\npip install .\n```\n\nThis will install all the dependencies listed in the `setup.py` file. Once done\nyou can use the library wherever you want.\n\n**Setup - PyPi Install:**\n\nTo **install** the library, run the following command from the terminal.\n\n```console\npip install py-tda-api\n```\n\n**Setup - PyPi Upgrade:**\n\nTo **upgrade** the library, run the following command from the terminal.\n\n```console\npip install --upgrade py-tda-api\n```\n\n## Usage\n\nHere is a simple example of using the `td` library.\n\n```python\nfrom pprint import pprint\nfrom configparser import ConfigParser\nfrom td.credentials import TdCredentials\nfrom td.client import TdAmeritradeClient\n\n\n# Initialize the Parser.\nconfig = ConfigParser()\n\n# Read the file.\nconfig.read('config/config.ini')\n\n# Get the specified credentials.\nclient_id = config.get('main', 'client_id')\nredirect_uri = config.get('main', 'redirect_uri')\n\n# Intialize our `Credentials` object.\ntd_credentials = TdCredentials(\n    client_id=client_id,\n    redirect_uri=redirect_uri,\n    credential_file='config/td_credentials.json'\n)\n\n# Initalize the `TdAmeritradeClient`\ntd_client = TdAmeritradeClient(\n    credentials=td_credentials\n)\n\n# Initialize the Quotes service.\nquote_service = td_client.quotes()\n\n# Grab a single quote.\npprint(\n    quote_service.get_quote(instrument='AAPL')\n)\n\n# Grab multiple quotes.\npprint(\n    quote_service.get_quotes(instruments=['AAPL', 'SQ'])\n)\n```\n\n## Support These Projects\n\n**Patreon:**\nHelp support this project and future projects by donating to my [Patreon Page](https://www.patreon.com/sigmacoding). I'm\nalways looking to add more content for individuals like yourself, unfortuantely some of the APIs I would require me to\npay monthly fees.\n\n**YouTube:**\nIf you'd like to watch more of my content, feel free to visit my YouTube channel [Sigma Coding](https://www.youtube.com/c/SigmaCoding).\n\n**Questions:**\nIf you have questions please feel free to reach out to me at [coding.sigma@gmail.com](mailto:coding.sigma@gmail.com?subject=[GitHub]%20Fred%20Library)\n\n## Authentication Workflow\n\n**Step 1 - Start the Script:**\n\nWhile in Visual Studio Code, right click anywhere in the code editor while in the file that contains your code.\nThe following dropdown will appear:\n\n![Terminal Dropdown](https://raw.githubusercontent.com/areed1192/td-ameritrade-python-api/master/samples/instructions/photos/terminal_dropdown.jpg \"Terminal Dropdown\")\n\nFrom the dropdown, click `Run Python file in Terminal`, this will start the python script.\n\n**Step 2 - Go to Redirect URL:**\n\nThe TD Library will automatically generate the redirect URL that will navigate you to the TD website for for\nyou authentication. You can either copy the link and paste it into a browser manually or if you're using Visual\nStudio Code you can press `CTRL + Click` to have Visual Studio Code navigate you to the URL immeditately.\n\n![Redirect URI](https://raw.githubusercontent.com/areed1192/td-ameritrade-python-api/master/samples/instructions/photos/redirect_uri.jpg \"Redirect URI\")\n\n**Step 3 - Login to the TD API:**\n\nOnce you've arrived at the login screen, you'll need to provide your credentials to authenticate the session.\nPlease provide your Account Username and Account Password in the userform and then press enter. As a reminder\nthese, are the same username/password combination you use to login to your regular TD Account.\n\n![\"TD Login](https://raw.githubusercontent.com/areed1192/td-ameritrade-python-api/master/samples/instructions/photos/td_login.jpg \"TD Login\")\n\n**Step 4 - Accept the Terms:**\n\nAccept the Terms of the API by clicking `Allow`, this will redirect you.\n\n![TD Terms](https://raw.githubusercontent.com/areed1192/td-ameritrade-python-api/master/samples/instructions/photos/td_terms.jpg \"TD Terms\")\n\n**Step 5 - Copy the Authorization Code:**\n\nAfter accepting the terms, you'll be taken to the URL that you provided as your `redirect URI`. However, at\nthe end of that URL will be `authorization code`. To complete the authentication workflow, copy the URL as\nit appears below. Don't worry if the numbers don't match, as you will have a different code.\n\n![Auth Code](https://raw.githubusercontent.com/areed1192/td-ameritrade-python-api/master/samples/instructions/photos/auth_code.jpg \"Auth Code\")\n\n**Step 6 - Paste the Authorization Code in the Terminal:**\n\nTake the URL and copy it into the Terminal, after you have pasted it, press `Enter`. The authentication workflow\nwill complete and the script will start running. At this stage, we are exchanging your authorization code for\nan access token. That access token is valid only for 30 minutes. However, a refresh token is also stored that\nwill refresh your access token when it expires.\n\n![Paste URL](https://raw.githubusercontent.com/areed1192/td-ameritrade-python-api/master/samples/instructions/photos/paste_url.jpg \"Paste URL\")\n\nAfter, that the script should run. Additionally, if you go to the location you specified in the `credentials_path`\narugment you will now see `td_state.json` file. This file contains all the info used during a session. Please\nDO NOT DELETE THIS FILE OR ELSE YOU WILL NEED TO GO THROUGH THE STEPS ABOVE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fareed1192%2Ftd-ameritrade-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fareed1192%2Ftd-ameritrade-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fareed1192%2Ftd-ameritrade-api/lists"}