Yahoo Finance Stock API

Yahoo Finance Stock API?

The Yahoo Finance Stock API appears to be both commonly and uncommonly known to the public.  The API is most easily seen by performing a stock quote search on the Yahoo Finance website and then selecting the “Download Data” link in the page details.  Looking at the link would show a url that looks similar to http://download.finance.yahoo.com/d/quotes.csv?s=DELL&f=sl1d1t1c1ohgv&e=.csv, this is the Yahoo Finance Stock API.

Deciphering the URL

We can break up the url into 4 distinct elements:

  1. Base URL of the request
    http://download.finance.yahoo.com/d/quotes.csv
  2. Stock Symbols that you want to obtain information are is passed by a plus (+) delimited string set to the s parameter of the query.
    s=DELL+RHI
  3. Fields that you want are passed by obscure letter codes sent by the f parameter of the query. A sample of values that can be obtained are found at the end of this entry. One important item to notice is that there is no space or delimiting characters between the options.
    f=sl1d1t1c1ohgv
  4. Return Format of the data which will most likely always be csv is set by the e query parameter
    e=.csv

Placing all that information together you can easily obtain financial information on any stock including but not limited to such information as the latest stock quote, daily high + low, 52 week high + low, the day’s range, previous day’s close, and today’s open price.  Creating a simple PHP or AJAX script would allow you to quickly show your website visitors how stocks are doing.

Sample list of data codes

  • g : Day’s Low
  • h:  Day’s High
  • o: Open
  • p: Previous Close
  • n: name
  • w2: 52 Week Range
  • l1: Latest Stock Quote

Resources

Comments & Questions

  1. You da man!!! I searched over an hour for something like this! Thank you!

Add Your Comment