Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Finance API change? #39

Open
edward-dauvergne opened this issue Aug 29, 2017 · 7 comments
Open

Google Finance API change? #39

edward-dauvergne opened this issue Aug 29, 2017 · 7 comments

Comments

@edward-dauvergne
Copy link

The URLs such as https://finance.google.com/finance/info?client=ig&q=EURUSD now return the response:

httpserver.cc: Response Code 400

Has the Google Finance API changed?

@ccampbell
Copy link

Now they are returning 404

@arnaudsj
Copy link

arnaudsj commented Sep 6, 2017

Yes, any getQuotes request for me returns 404 since this morning. Anybody else still able to use this library?

@lashkapolta
Copy link

me having 404 too with the method below in python 2.7
print json.dumps(getQuotes('AAPL'), indent=2)

@leikahing
Copy link

leikahing commented Sep 6, 2017

It seems like that endpoint itself has changed or gone away (temporarily? permanently? can't say), which is the unfortunate nature of this system since it has no official API anymore.

I helped someone on StackOverflow with a 'workaround' of basically parsing the full response to get information.

https://stackoverflow.com/a/46081537/297696

Code from answer below:

import json
import requests

rsp = requests.get('https://finance.google.com/finance?q=AAPL&output=json')
if rsp.status_code in (200,):

    # This magic here is to cut out various leading characters from the JSON 
    # response, as well as trailing stuff (a terminating ']\n' sequence), and then
    # we decode the escape sequences in the response
    # This then allows you to load the resulting string
    # with the JSON module.
    fin_data = json.loads(rsp.content[6:-2].decode('unicode_escape'))

    # print out some quote data
    print('Opening Price: {}'.format(fin_data['op']))
    print('Price/Earnings Ratio: {}'.format(fin_data['pe']))
    print('52-week high: {}'.format(fin_data['hi52']))
    print('52-week low: {}'.format(fin_data['lo52']))

A derivative of this could integrated into the library assuming the other endpoint doesn't come back (and a better endpoint isn't found), though there are limitations of the normal endpoint, like it not supporting multiple quotes in the same request.

@valenciakarlos
Copy link

Can google be contacted for a solution? this was a pretty useful API.

@bkcollection
Copy link

bkcollection commented Sep 7, 2017

This url will not work if you want to get the quotes for more than one stocks.
https://finance.google.com/finance?q=AAPL,MSFT&output=json will not return any of the stock quotes

Also, a few ticker will not work with the above url

  1. currency such as CURRENCY:USDEUR
  2. Last trade time missing

@PassHours
Copy link

PassHours commented Oct 25, 2017

@bkcollection it's works but asking for a download. Do you know how to use it in javascript. Or how the print the output in browser window instead of download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants