Questrade API nodejs wrapper

I wanted to write a script using the Questrade API to help me rebalance my portfolio. I guess wrapping the rest calls behind a function wrapper is a good start. Here is what I started, feel free to help me out, or just take a look:

questrade.js is the wrapper around the REST API. When you instantiate it, pass the result of redeeming the refresh token to the constructor, as shown in questapp.js.

I want to experiment with the API initially so I wrote questapp.js. What I do is load it in the node repl and call functions in questrade.js. Something like this:

ltse@ltse-ubuntu:~/questrade_sample$ node
> .load questapp.js
> ...noise ommitted...
> q.accounts()
> { accounts: 
   [ { type: 'Margin',
       number: '12345678',
       status: 'Active',
       isPrimary: true,
       isBilling: true,
       clientAccountType: 'Individual' },
     { type: 'TFSA',
       number: '2345678',
       status: 'Active',
       isPrimary: false,
       isBilling: false,
       clientAccountType: 'Individual' } ],
  userId: 34567 }


Come to think of it, wouldn’t it be nice if there is something that would auto-generate functions base on a rest api definition? Someone probably has came up with it already…


Questrade.js updated with example


3 thoughts on “Questrade API nodejs wrapper

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s