In the past I’ve wrote this post on the different options you can use with Yahoo Finance API. It is time (4 years later!) to a followup post on how to gain more data but this time with nodeJS. The first idea was to be able to gain information by using different parameters and downloading csv files from Yahoo finance. Something like this GET request will do the magic:
http://finance.yahoo.com/d/quotes.csv?s=NFLX&f=snd1l1yr and from there you can work with the data.
However, there are cases, where you wish to have information that is not part of this set of arguments. Here are two quick examples for such cases:
- Key statistics for a company – http://finance.yahoo.com/q/ks?s=LVS
- Check for competitors of company X – http://finance.yahoo.com/q/co?s=LVS+Competitors
In the code below you could see that with the power of NodeJS community and the powerful google sheet API, you can fetch this data and use it in your google sheets. You will need to install NodeJS (of course) and on top of it 3 packages:
- npm install request – So we could work with URLs in an easy way.
- npm install cheerio – jQuery for the server side. This will make the code 10x shorter.
- npm install edit-google-spreadsheet – to integrate with Google docs/sheets with 2-3 lines of code.
After you finish the installation process, you should download the gist and open it in your favorite editor. Now, if you have a good sheet you wish to use, just add its name to the places I’ve wrote TODO. The results will be a sheet that is full with interesting data in two columns. You can take this example and fork it so it will bring you the information you wish to see.