Package Exports
- tdaclient
- tdaclient/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tdaclient) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
TD Ameritrade Client for Nodejs
Overview
A client that knows how to call the td-ameritrade Restful API written for nodejs and browser.
Features
- Get access token and refresh token
- Get user account information
Install
$ yarn add tdaclient Development Guide
Setup if you want to do development on this package
This setup is only good for testing the package. If you want to use it for your own application you will need to figure out how to pass to this client the required code, access token or refresh token. I will eventually add the documentation for using this package in your own application but for now you'll need to follow the instructions below.
- Run this command and open the output URL from the console.For more info refer to this page
node generateAuthUrl.js - Login and click allow.
- Go to this page to get the access token and
refresh token
- Fill in the form with the follow values:
- grant_type: authorization_code
- access_type: offline
- code: [the value that you receive from following step 1. Make sure it is decoded]
- client_id: [Your app consumer key]
- Note: make sure that this value is not url encoded. You can decode the value that you got from step 1 by
running this command in the javascript console
decodeURIComponent("MY_SECRET_CODE")
- Note: make sure that this value is not url encoded. You can decode the value that you got from step 1 by
running this command in the javascript console
- redirect_uri: [Your app redirect uri]
- Fill in the form with the follow values:
- Create a file in this directory (at the same level as this README.md) and name it
credentials.json - Paste the response from that page to the file create in step 3. Also add the client_id and redirect_uri attributes at the end.
{ "access_token": "example-token", "refresh_token": "example-refresh-token", "scope": "PlaceTrades AccountAccess MoveMoney", "expires_in": 1800, // 30 minutes "refresh_token_expires_in": 7776000, // 90 days "token_type": "Bearer", "client_id": "example-client-id", "redirect_uri": "example-redirect-uri" }
- Now you can run the command
yarn testand it will run the integration tests - The test will keep updating the access_token so you can keep running the tests. If you happen to not run the tests within 90 days, then you will have to manually login and get a new refesh_token and repeat step 4.
Publishing to npm
This command will update the package version and then publish to the public npm repo
$ npm version [patch | minor major]
$ npm publishHow to use
Refer to this page for more info on apis
License
tdaclient is MIT licensed.