Get near Real-Time Stock Data From Yahoo Finance

Yahoo’s YQL API gives you access to a huge number of stocks and tons of great data for each.

Download Code

Here is a list of the data available:


  • Earnings Per Share
  • EPS Estimate for the Current Year
  • EPS Estimate for Next Year
  • EPS Estimate for Next Quarter
  • Price EPS Estimate for the Current Year
  • Price EPS Estimate for Next Year

Price Fields

  • Last Trade Price
  • Bid Price
  • Ask Price
  • Open Price
  • Previous Close
  • Change Percent
  • Change Amount
  • Daily Low
  • Daily High
  • Yearly Low
  • Yearly High
  • Change from Yearly Low
  • Change from Yearly High
  • Change In Percent
  • Percent Change from Yearly Low
  • Percent Change from Yearly High

Volume Fields

  • Volume
  • Average Daily Volume

Dividends Fields

  • Dividend Per Share
  • Dividend Yield
  • Dividend Pay Date
  • Ex Dividend Date

Moving Average Fields

  • 50 Day Moving Average
  • 200 Day Moving Average
  • Percent Change from 200 Day Moving Average

Ratio Fields

  • PEG Ratio
  • Short Ratio
  • PE Ratio

General Stock Info

  • Name
  • Symbol
  • Book Value
  • Stock Exchange
  • Last Update
  • Market Capitalization
  • Last Trade Date
  • Price Of Sales
  • Price Of Book
  • One Year Price Target

This Yahoo Stock API is completely REST based so you can call it from anywhere, your phone, desktop whatever you like. Also being REST based means it works great with C#.

I’ve created a c# YahooStockEngine class that you can give a list of equities and it will return all the data listed above in a C# class with all those properties.
The code is very easy to understand, and really doesn’t do much but map XML to a C# class, but is very useful if your working with stocks.

I’ve included a small client called CardStock. This client is WPF and uses Model-View-ViewModel (MVVM) and displays a list of equities that it pulled from the Yahoo Finance API using YQL and REST.


Categories:   Code, Finance


  • Posted: October 6, 2011 10:17

    Sarin Na Wangkanai

    Your work is what i'm look for to develop something on my person trading. I tried getting quote ticker for stock options, but i'm not getting any pricing. Do you know where i could get that data feed?
    • Posted: October 6, 2011 10:27


      Not sure exactly what your looking for. But if you look at the YahooStockEngine.cs class you will see it's calling a REST based service. For example to get a quote for Apple (AAPL) it does this: http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22AAPL%22)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys The YahooStockEngine.cs also sends multiple quotes at once, but this is basically what it is doing. Once it gets the XML from that it parses it into an object. To get a new quote you need to call again to refresh.
  • Posted: October 6, 2011 10:39

    Sarin Na Wangkanai

    Well, i'm trying to get option chain quote of SPY, http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22SPY111007C00116000%22)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys which delay csv is possible at; http://download.finance.yahoo.com/d/quotes.csv?s=SPY111007C00116000&f=sl1d1t1c1ohgv&e=.csv Do you have any idea where to get this real time data. thanks there mate. :)
    • Posted: October 6, 2011 10:43


      Sorry but I'm not aware of a free source for real-time option data. I know you can get it with accounts at brokerages such as Interactive Brokers, but you need to setup an account and have 15k or so to set it up. Xignite is one source of the data and offer a free trial. I haven't used them myself but they look good.
  • Posted: November 15, 2011 04:55


    Hi, I have been exploring YQL recently, I wonder whether it can be used to get real-time (yes, I know its a delayed data) tick to tick stock quotes? I have tried and I think that YQL doesn't have any tables that stores/returns tick-to-tick stock quotes.... May be I'm wrong.. does any one have looked at it earlier? Awaiting your reply. You(admin)can also send me email. Thanks
    • Posted: November 15, 2011 19:42


      No that is not really what YQL is best at. It's basically just polling a website and scraping it in the background. You could do it yourself but with an increased frequency if that is what your really looking for. If you really want real-time stock data I would look at the BATS Exchange. I know FreeStockCharts.com uses it. (great free charting service imo.)
  • Posted: December 6, 2011 16:19


    Do you know how to access the after-hours data using YQL?
  • Posted: February 23, 2012 13:22


    Great Code! thanks for sharing, One quick question, if YahooStockEngine is used on a .Net app with a grid view that refreshes periodically, do I still need "PropertyChanged" ? since it's not silver light it won't refresh the UI so why use it ? Thanks again!
    • Posted: February 23, 2012 14:02


      The PropertyChanged from IPropertyNotify is only used in this case so that an ObservableCollection will be notified when an item changes. If your not using an ObservableCollection, then it is not needed and can safely be removed. You could also then change the properties to Auto-Properties.
  • Posted: February 23, 2012 17:29


    Hello, I posted this ? a while back, seems to have been missed...so this is a repost Do you know how to access the after-hours data using YQL? Thanks
  • Posted: July 10, 2012 12:22

    Jason Rennie

    Hi, I'm trying to get live prices through Yahoo and I found your pages - how cool ! Only problem is that I dont seem to be getting live prices.. A query like this is showing the LastTradeTime as 15 minutes ago http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22AMZN%22)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys Additional proof is that for the first 15 minutes of the day my price is from yesterdays close.. and requests after the market is closed are still updating for 15 minutes after... I've tried this from 2 machines - 2 different IP addresses and I get the same results.. And I triued signing up for a Yahoo developer account to see if that changed things.. But no luck.. Do you think Yahoo have simply stopped their real-time price feed ? Any help you can offer is greatly appreciated. -Jason
  • Posted: September 10, 2012 23:30


    Yahoo login should be signed in to get realtime feed. otherwise Yahoo will provide 15 mins delays data. The request should be a web browser request with the yahoo email already signed in.
  • Posted: October 31, 2012 04:48

    Beachfront Rentals Hawaii

    I am new to the financial market and love reading about articles related to it. Yours is a very informative post. I got what I was looking for. Thank you so much!
  • Posted: January 25, 2013 13:30


    How do I use your code on a Linux Mint 14 machine, running C/C++ with gnu compilers? Thanks.
    • Posted: January 25, 2013 20:27

      Kelly Elias

      You don't. This is c# not c++. Can probably get it working on Linux using Mono but keep in mind this complies to intermediate language (IL) and requires the .NET framework to run.
  • Posted: January 27, 2013 09:49


    Thanks for the information. I will make the necessary adjustments.
  • Posted: January 14, 2014 20:42

    Keith Cwiok

    I'm looking for a reliable and free 1 minute or 15 minute stock market data feed API. I'm using the Yahoo Feed but it is unstable and causes a lot of application errors. Thank You
  • Posted: May 6, 2014 08:45


    Thanks for your source code, if I want to have historical information of the stock details above, for example PE ratio for several quarters back or one year back, then what parameter should I add? Thank you.
    • Posted: September 10, 2015 15:30


      unfortunately, Yahoo does not provide historical series of PE; just prices & dividends. However, you can get historical data for the financial statements (up to 4 quarters), and then construct historical PE series
  • Posted: May 9, 2014 09:08


    I tried to use the yahoo API to query a Hong Kong stock info, but seems the dividend are not the same as the yahoo listed... the stock code is 1881.hk ... on the yahoo page is showing 0.15 (which is correct) and when I used the API to query "d" it returns 0.067 which is the value of the first dividend delivered, any help, many thanks.
  • Posted: March 11, 2016 15:45


    Hey, just wondering how close to real-time is yahoo finance yql? Also, this was developed many years ago, is there a new alternative to real-time stock quote now? I don't see to find anything better than this. Thanks for your work.
    • Posted: March 16, 2016 22:28

      Kelly Elias

      It's around 5-8 minutes late. BATS exchange is a much better source. It's complete RT. Handles about 15-20% of transactions, so the volume it lists is off, but you can do the math and get it close however. Another source of RT data will be https://www.robinhood.com/ but the API is not out yet. I've asked to be in it, but it just doesn't seem to be ready yet. Very excited about this since there are $0 brokerage fees! Yeah $0! Swing traders rejoice!
  • Posted: January 3, 2017 09:40


    Hi. How can I get real time stock data? I tried the Yahoo CSV API but it doesn't give real time data. I get the volume of the stock and immediately check Yahoo Finance for the same stock volume and I see that there is a significant delay. Help. ty
  • Posted: January 17, 2017 04:38


    Hi Admin I am looking for API of " Real time or Delayed 'current price' update of BSE in PHP " . Please assist me .
  • Posted: February 14, 2017 06:26

    john constable

    I'm trying to get data from the API for the UK stock British Telecom. Up to last week I was using 'BT.L' for the ticker and it worked fine. This week it looks like the ticker has changed to 'BT.A' and I'm getting 'N/A' returned so I tried to send: BT.A BT.A.L BTA.L Nothing works. Please can someone tell me what I need to send or is there a problem with the yahoo finance API?
    • Posted: February 14, 2017 10:19

      john constable

      after some digging it seems to be 'BT-A.L'