spaceX from above
Chrome, JavaScript, webdev

Yahoo Finance API With NodeJS

nodejs logoIn 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: 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:

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:

  1. npm install requestSo we could work with URLs in an easy way.
  2. npm install cheerio – jQuery for the server side. This will make the code 10x shorter.
  3. 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.

The code

view of mountains with trees in the snow

Happy Hacking.


2 thoughts on “Yahoo Finance API With NodeJS

  1. Awesome!!!!
    Really liked the speed. One query though, when i ran the code google api mentioned it didnt find the spreadsheet and then the sheet, wont the api create a new spreadsheet and new worksheet and fill the data accordingly.

  2. Pingback: APIs, NodeJS and Google Docs (GDL-Israel) - TI Nacional

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s