google finance api not working from 6/september/2017

16k views Asked by At

I was using google finance api to get the stock quotes and display the contents on my site. All of a sudden from 6/september/2017 this stopped working. The url i used to get the stock quotes is https://finance.google.com/finance/info?client=ig&q=SYMBOL&callback=?.

Previously, i was using yahoo finance api and it was inconsistent. So, i switched over to google finance api.

Could you please help me on this?

Thanks, Ram

8

There are 8 answers

1
Ramaprasad Palanichamy On BEST ANSWER

In the end i started using yahoo finance. The data is not live, there is a 20 minutes delay. I thought it will be helpful to people who are facing issues like me.

The yahoo api url is https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%3D%22MSFT%22&env=store://datatables.org/alltableswithkeys

This will return the stock data in xml format. You can parse the xml to get your desired fields.

Thanks, Ram

2
dev-sonnyk On

I was dying to look for thread like this yesterday when I faced the issue!

Like Salketer said, Google Finance API was officially "closed" in 2012. However, for some reason it was still working until September 5, 2017. I built a program to manage my portfolio that uses GF API to get live quotes for US stocks. It stopped working on Sep 6, 2017, so I am assuming that engineers behind "secretly providing" API now "actually" stopped the service.

I found an alternative https://www.alphavantage.co/documentation/ , and this seems like the best alternative for free live US equity quotes. They just require your email, nothing else. It's a bit slow because it doesn't have multi-symbol query yet, but beggars can't be choosers.

0
Andrew On

I had to switch to Google finance after using Yahoo finance for a long time after Verizon bought yahoo this May and ended the free API service. I went back and re-researched this issue and someone created a new Yahoo finance API call that works with the new yahoo API. https://stackoverflow.com/a/44092983/8316350

The python source and installer can be found here: https://github.com/c0redumb/yahoo_quote_download

The arguments are (ticker, start_date, and end_date) where dates are yyyymmdd format and returns a list of unicode strings. The following test will download a couple weeks worth of data and then extract only the adjusted close price to return a list called adj_close:

from yahoo_quote_download import yqd
import string
quote = yqd.load_yahoo_quote('AAPL', '20170515', '20170530')
print(quote[0]) # print the column headers
print(quote[1]) # print a couple rows of data
print(quote[2]) # just to make sure it looks right
quote.pop()  # get rid of blank string at end of data
quote = [row.encode("utf-8") for row in quote]  # convert to byte data
quote = [string.split(row, ',') for row in quote] # split the string to create a list of lists
adj_close = [row[5] for row in quote]  # grab only the 'adj close' data and put into a new list
print(adj_close)

Returns:

Date,Open,High,Low,Close,Adj Close,Volume
2017-05-15,156.009995,156.649994,155.050003,155.699997,155.090958,26009700
2017-05-16,155.940002,156.059998,154.720001,155.470001,154.861862,20048500
['Adj Close', '155.090958', '154.861862', '149.662277', '151.943314', '152.461288', '153.387650', '153.198395', '152.740189', '153.268112', '153.009140', '153.068893']
0
ATOzTOA On

I was manually reading from Google Finance page for each stock before I got the ?info link. As this is not working anymore, I am going back to the webpage.

Here is my python snippet:

def get_market_price(symbol):
    print "Getting market price: " + symbol

    base_url = 'http://finance.google.com/finance?q='

    retries = 2

    while True:
        try:
            response = urllib2.urlopen(base_url + symbol)
            html = response.read()
        except Exception, msg:
            if retries > 0:
                retries -= 1
            else:
                raise Exception("Error getting market price!")

        soup = BeautifulSoup(html, 'lxml')

        try:
            price_change = soup.find("div", { "class": "id-price-change" })
            price_change = price_change.find("span").find_all("span")
            price_change = [x.string for x in price_change]

            price = soup.find_all("span", id=re.compile('^ref_.*_l$'))[0].string
            price = str(unicode(price).encode('ascii', 'ignore')).strip().replace(",", "")

            return (price, price_change)
        except Exception as e:
            if retries > 0:
                retries -= 1
            else:
                raise Exception("Can't get current rate for scrip: " + symbol)

Example:

Getting market price: NSE:CIPLA
('558.55', [u'+4.70', u'(0.85%)'])
2
Shyamal Patel On

We had a same issue & we found below alternative API provided by Microsoft Bing API for Stock Markets. Below API returns the stock data in JSON format.

https://finance.services.appex.bing.com/Market.svc/ChartAndQuotes?symbols=139.1.500209.BOM&chartType=1d&isETF=false&iseod=False&lang=en-IN&isCS=false&isVol=true

Thanks, Shyamal

1
Frank On

You can simply parse the result of this request:

https://finance.google.com/finance/getprices?q=GOOG&x=NASD&p=1d&i=60&f=d,c,o,h,l,v

(GOOG at NASDAQ, one day, frequency 60 seconds, DATE,CLOSE,HIGH,LOW,OPEN,VOLUME)

1
Gitesh On

This url works. I think just the url changed from www.google.com to finance.google.com

https://finance.google.com/finance/getprices?q=ACC&x=NSE&p=15&i=300&f=d,c,o,h,l,v

1
Surya Adhikari On

I had a same problem in PHP.

I replace the URL https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency

to

https://finance.google.com/finance/converter?a=1&from=$from_Currency&to=$to_Currency

Works fine for me.