Print

Import Yahoo Finance Data to Google Sheets

In this guide, we will walk through how to pull data from the Yahoo Finance API directly into Google Sheets, using the API Connector add-on for Sheets.

Yahoo Finance doesn't have an official API, so we'll access data through some unofficial APIs. There are a couple of these we can choose from:

  1. The unofficial Yahoo Finance API listed in the RapidAPI marketplace.
  2. The API used by https://finance.yahoo.com/ itself. This API populates the data on the actual website and is totally free to access, which certainly makes it interesting. However, it's not intended for public data requests, has no documentation, and can be unreliable.

This article will focus on the unofficial Yahoo Finance API from RapidAPI, since it's well maintained and generally easier to use. However, for those curious, I've also included a section on navigating through the unofficial data API used by the Yahoo Finance website.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Subscribe to the Yahoo Finance API

  1. Create an account at RapidAPI and log in. While logged in, navigate to the YH Finance API located at https://rapidapi.com/apidojo/api/yh-finance
    yahoofinance-documentation
  2. Click Subscribe to Test
    yahoofinance-subscribe
  3. You will now see a list of pricing plans, including a free plan if you're just getting started. Click Subscribe on plan for which you'd like to subscribe.
  4. Whichever plan you choose (even the free one), you'll need to enter your credit card details at this point, and can then return to the documentation.

Part 2: Create Your API Request

  1. Available endpoints are listed in the lefthand sidebar. Let's start with GET market/v2/get-quotes
    yahoofinance-endpoints
  2. Scroll down and fill out any required parameters.
    yahoofinance-parameters
  3. If you like, click the Test Endpoint button to see the response in the RapidAPI window, and visually verify that your request has fetched the data you're looking for.
  4. Now click the Code Snippets tab, and choose (Shell) cURL from the dropdown. Click Copy Code to grab the entire curl snippet; we'll use that next.
    yahoofinance-copycode

Part 3: Pull Yahoo Finance API Data into Sheets

We can now enter this cURL snippet into API Connector using API Connector's cURL import tool.

  1. Open up Google Sheets and click Extensions > API Connector > Import/Export > Import cURL
  2. Paste in the cURL snippet we retrieved above. Click Import.
    yahoofinance-importcurl
  3. You'll see the entire request pre-configured in the sidebar.
  4. Create a new tab and click Set current to use that tab as your data destination.
  5. Name your request and click Run. A moment later you’ll see the response from the Yahoo Finance API appear in your sheet.
    yahoofinance-response
  6. To get other financial data, play around with the endpoint list in the left pane in RapidAPI to retrieve other information. Each time you click an endpoint, the new URL will appear in the code snippet box, where you can copy and paste it into API Connector.

Part 4: API Documentation

Unofficial Yahoo API documentation: https://rapidapi.com/apidojo/api/yh-finance/

Part 5: Fetch Data from Finance.yahoo.com

As mentioned, Yahoo Finance doesn't provide an official data API.

However, you can see the data requests they make to populate their website through the following:

  • Navigate to the page on https://finance.yahoo.com/ for which you'd like to fetch data
  • Open Developer Tools in your browser (F12 on Windows/Linux or option + ⌘ + J on OSX)
  • Click on the Network tab
  • In the filter box type the word query to filter the list of network requests
  • Check the requests that appear on the right

Clicking into any of those network requests will reveal the full URL that was used to generate the report.

Copy/paste that URL into API Connector to see the data:

Useful Examples

  • Stock quotes
    https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US&region=US&corsDomain=finance.yahoo.com&symbols=META,GOOG
  • Time series
    https://query1.finance.yahoo.com/ws/fundamentals-timeseries/v1/finance/timeseries/GOOG?symbol=GOOG&type=quarterlyPegRatio&period1=493590046&period2=1913180947

Leave a Comment

Jump To