NodeJS Framework to make trades with the private Robinhood API. Using this API is not encouraged, since it's not officially available and it has been reverse engineered. See this blog post for more information on the API.
I have read Robinhood's Terms and Conditions and, without being a lawyer and/or this being valid in any way, it doesn't seem like interacting with their servers using the API is against them.
This framework was inspired by a deprecated Python framework originally developed by @Rohanpai.
Features
- Placing buy orders
Robinhood.place_buy_order
- Placing sell order
Robinhood.place_sell_order
- Quote Information
Robinhood.quote_data
- Get Dividend information
Robinhood.dividends (v0.2+)
- Get User information
Robinhood.user (v0.2+)
- Get Orders
Robinhood.orders (v0.2+)
- Get Fundamentals
Robinhood.fundamentals (v0.4+)
- More coming soon...
Installation
$ npm install --save robinhood
Usage
var credentials = {
username: '',
password: ''
};
var Robinhood = require('robinhood')(credentials, function(){
Robinhood(null).quote_data('GOOG', function(error, response, body) {
if (error) {
console.error(error);
process.exit(1);
}
console.log(body);
});
});
API
Before using these methods, make sure you have initialized Robinhood using the snippet above.
Feel free to send a pull request expanding this with examples or info about the return objects
investment_profile(callback)
Get the current user's investment profile.
var credentials = require("../credentials.js")();
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.investment_profile(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("investment_profile");
console.log(body);
}
})
});
instruments(symbol, callback)
var credentials = require("../credentials.js")();
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.instruments('AAPL',function(err, response, body){
if(err){
console.error(err);
}else{
console.log("instruments");
console.log(body);
}
})
});
Get the user's instruments for a specified stock.
quote_data(stock, callback) // Not authenticated
Get the user's quote data for a specified stock.
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.quote_data('AAPL', function(err, response, body){
if(err){
console.error(err);
}else{
console.log("quote_data");
console.log(body);
}
})
});
accounts(callback)
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.accounts(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("accounts");
console.log(body);
}
})
});
Get the user's accounts.
user(callback)
Get the user information.
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.user(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("user");
console.log(body);
}
})
});
dividends(callback)
Get the user's dividends information.
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.dividends(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("dividends");
console.log(body);
}
})
});
orders(callback)
Get the user's orders information.
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.orders(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("orders");
console.log(body);
}
})
});
place_buy_order(options, callback)
Place a buy order on a specified stock.
var Robinhood = require('robinhood')(credentials, function(){
var options = {
type: 'limit',
quantity: 1,
bid_price: 1.00,
instrument: {
url: String,
symbol: String
}
}
Robinhood.place_buy_order(options, function(error, response, body){
if(error){
console.error(error);
}else{
console.log(body);
}
})
});
For the Optional ones, the values can be:
[Disclaimer: This is an unofficial API based on reverse engineering, and the following option values have not been confirmed]
trigger
A trade trigger is usually a market condition, such as a rise or fall in the price of an index or security.
Values can be:
gfd
: Good For Daygtc
: Good Till Cancelledoco
: Order Cancels Other
time
The time in force for an order defines the length of time over which an order will continue working before it is canceled.
Values can be:
immediate
: The order will be cancelled unless it is fulfilled immediately.day
: The order will be cancelled at the end of the trading day.
place_sell_order(options, callback)
Place a sell order on a specified stock.
var Robinhood = require('robinhood')(credentials, function(){
var options = {
type: 'limit',
quantity: 1,
bid_price: 1.00,
instrument: {
url: String,
symbol: String
},
}
Robinhood.place_sell_order(options, function(error, response, body){
if(error){
console.error(error);
}else{
console.log(body);
}
})
});
For the Optional ones, the values can be:
[Disclaimer: This is an unofficial API based on reverse engineering, and the following option values have not been confirmed]
trigger
A trade trigger is usually a market condition, such as a rise or fall in the price of an index or security.
Values can be:
gfd
: Good For Daygtc
: Good Till Cancelledoco
: Order Cancels Other
time
The time in force for an order defines the length of time over which an order will continue working before it is canceled.
Values can be:
immediate
: The order will be cancelled unless it is fulfilled immediately.day
: The order will be cancelled at the end of the trading day.
fundamentals(symbol, callback)
Get fundamental data about a symbol.
Response
An object containing information about the symbol:
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.fundamentals("SBPH", function(error, response, body){
if(error){
console.error(error);
}else{
console.log(body);
}
})
});
cancel_order(order, callback)
Cancel an order
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.orders(function(error, response, body){
if(error){
console.error(error);
}else{
var orderToCancel = body.results[0];
Robinhood.cancel_order(orderToCancel, function(err, response, body){
if(err){
console.error(err);
}else{
console.log("Cancel Order Successful");
console.log(body)
}
})
}
})
})
watchlists(name, callback)
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.watchlists(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("got watchlists");
console.log(body);
}
})
});
create_watch_list(name, callback)
//Your account type must support multiple watchlists to use this endpoint otherwise will get { detail: 'Request was throttled.' } and watchlist is not created.
Robinhood.create_watch_list('Technology', function(err, response, body){
if(err){
console.error(err);
}else{
console.log("created watchlist");
console.log(body);
// {
// "url": "https://api.robinhood.com/watchlists/Technology/",
// "user": "https://api.robinhood.com/user/",
// "name": "Technology"
// }
}
})
sp500_up(callback)
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.sp500_up(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("sp500_up");
console.log(body);
}
})
});
sp500_down(callback)
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.sp500_down(function(err, response, body){
if(err){
console.error(err);
}else{
console.log("sp500_down");
console.log(body);
}
})
});
splits(instrument, callback)
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.splits("7a3a677d-1664-44a0-a94b-3bb3d64f9e20", function(err, response, body){
if(err){
console.error(err);
}else{
console.log("got splits");
console.log(body);
}
})
})
historicals(symbol, intv, span, callback)
var Robinhood = require('robinhood')(credentials, function(){
Robinhood.historicals("AAPL", '5minute', 'week', function(err, response, body){
if(err){
console.error(err);
}else{
console.log("got historicals");
console.log(body);
}
})
})
Contributors
*** Alejandro U. Alvarez (@aurbano)
This framework is still in a very alpha version and will likely change, so production usage is completely discouraged.
Even though this should be obvious: I am not affiliated in any way with Robinhood Financial LLC. I don't mean any harm or disruption in their service by providing this. Furthermore, I believe they are working on an amazing product, and hope that by publishing this NodeJS framework their users can benefit in even more ways from working with them.