A Javascript client for the Charles Schwab Restful API written in Typescript for NodeJs.
- Auto fetch refresh token when access token expires.
- Credentials can be fetched and stored using these providers
- Local cache
- Local file
- Customizable (e.g. connect to datastore such as S3 or DynamoDB)
- Get user account information
- Get watchlist
- Get option chain
- Get quote
- Manage orders
- Get transactions
- Get market hours
- Get price history
- Place/Replace order
$ npm install @pyriter/schwab-client
To gain access to the Schwab (TDA) APIs, you will need to get an access token from your trading account.
At the bare minimum, you will need to provide an access token and client id and client secret in order to instantiate the schwabClient.
- Create a credentials.json file at the package root level with the following information:
{
"client_id": "",
"client_secret": "",
"redirect_uri": "http://localhost/"
}
- Run the script to generate the login url
node ./generateAuthUrl.js
- Open the url provided from the output of step #2 in a browser and login to Schwab.
- After logging in and agreeing to the terms. You will then get to a redirect to
localhost
with the code as part of the query params. Copy this url link in its entirety. - Within the terminal run the script to generate the auth token
node ./extractAuthCode.js [paste-your-url-from-step-4-here]
- Run the tests
npm tests
This command will update the package version and then publish to the public npm repo
$ npm version [patch | minor major]
$ npm publish
Schwab Client is MIT licensed.