question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google Finance API change?

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:7
  • Comments:7

github_iconTop GitHub Comments

13reactions
leikahingcommented, 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.

1reaction
bkcollectioncommented, 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
Read more comments on GitHub >

github_iconTop Results From Across the Web

GOOGLEFINANCE - Google Docs Editors Help
Fetches current or historical securities information from Google Finance. ... "change" - The price change since the previous trading day's close.
Read more >
Google Data APIs Frequently Asked Questions
Finance Data API, http://finance.google.com/finance/feeds/ ... Google Data APIs you must do two things: set an "Accept-Encoding" header and modify your user ...
Read more >
GoogleFinance Function Advanced Tutorial 2023
Read a detailed tutorial about the power of GOOGLEFINANCE function in Google ... How to retrieve data from Yahoo Finance API without coding....
Read more >
Google Finance API and Its Alternatives (Updated for 2022)
Overview of the Google Finance API & some alternatives such as Yahoo Finance, Tradier, and more. Get started today for Free!
Read more >
Google Finance API and 9 Alternatives
Google Finance API was a tool which allowed us to extract data about stocks and financial assets from Google Finance. The API is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found