Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get stock quotes using Google Finance API?

People also ask

How can I get GOOGLEFINANCE API stock price?

Once at the Google finance search engine, type the ticker name into the financial data API engine and the result will be displayed.

Can you download stock data from GOOGLEFINANCE?

You can use URLs like https://www.google.com/finance//historical?q=GOOGL to open pages with historical prices directly. You can download the historical prices to a CSV file using the 'Download to spreadsheet' link on the right panel. You can download data for the required selected period.


The Google Finance Gadget API has been officially deprecated since October 2012, but as of April 2014, it's still active:

http://www.google.com/finance/info?q=NASDAQ:GOOG
http://www.google.com/finance/info?q=CURRENCY:GBPUSD
http://finance.google.com/finance/info?client=ig&q=AAPL,YHOO

You can also get charts: https://www.google.com/finance/getchart?q=YELP

Note that if your application is for public consumption, using the Google Finance API is against Google's terms of service.

Check google-finance-get-stock-quote-realtime for the complete code in python


There's a whole API for managing portfolios. *Link removed. Google no longer provides a developer API for this.

Getting stock quotes is a little harder. I found one article where someone got stock quotes using Google Spreadsheets.

You can also use the gadgets but I guess that's not what you're after.

The API you mention is interesting but doesn't seem to be documented (as far as I've been able to find anyway).

Here is some information on historical prices, just for reference sake.


I found this site helpful.

http://benjisimon.blogspot.com/2009/01/truly-simple-stock-api.html

It links to an API yahoo seems to offer that is very simple and useful.

For instance:

http://finance.yahoo.com/d/quotes.csv?s=GOOG+AAPL&f=snl1

Full details here:

http://www.gummy-stuff.org/Yahoo-data.htm


Edit: the api call has been removed by google. so it is no longer functioning.

Agree with Pareshkumar's answer. Now there is a python wrapper googlefinance for the url call.

Install googlefinance

$pip install googlefinance

It is easy to get current stock price:

>>> from googlefinance import getQuotes
>>> import json
>>> print json.dumps(getQuotes('AAPL'), indent=2)
[
  {
    "Index": "NASDAQ", 
    "LastTradeWithCurrency": "129.09", 
    "LastTradeDateTime": "2015-03-02T16:04:29Z", 
    "LastTradePrice": "129.09", 
    "Yield": "1.46", 
    "LastTradeTime": "4:04PM EST", 
    "LastTradeDateTimeLong": "Mar 2, 4:04PM EST", 
    "Dividend": "0.47", 
    "StockSymbol": "AAPL", 
    "ID": "22144"
  }
]

Google finance is a source that provides real-time stock data. There are also other APIs from yahoo, such as yahoo-finance, but they are delayed by 15min for NYSE and NASDAQ stocks.