Connecting the Yahoo Finance API to Google Sheets

Yahoo Finance provides financial news, data and commentary including stock quotes, press releases, financial reports, and original content. We can use the Yahoo Finance API to import data from Yahoo Finance into Google Sheets. In this tutorial, I’ll show you how to connect the Yahoo Finance REST API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Obtain an API key
  3. Choose a Yahoo Finance API Endpoint
  4. Enter the Yahoo Finance API request into the Apipheny add-on
  5.  Run the Yahoo Finance API request in your Google Sheets

Step 1.) Install and open the Apipheny add-on in Google Sheets

To pull data from the Yahoo Finance API to Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more. 

1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the page: https://apipheny.io/install

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons or Extensions option in the top menu. In this menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

Step 2.) Obtain an API key

After logging into your Rapid API developer account (https://rapidapi.com/hub), go to the Yahoo Finance API pricing page (https://rapidapi.com/apidojo/api/yahoo-finance1/pricing ) and select a pricing plan. In this tutorial we used the Basic plan.

Developer account section
Developer account section

After signing up for a plan, navigate to the Endpoints menu item to find the X-RapidAPI-Key and X-RapidAPI-Host:

Endpoints menu item
Endpoints menu item

Copy these values to a safe location because you’ll need them later.

Step 3.) Choose a Yahoo Finance API Endpoint

In this section, I’ll show you how to browse the Yahoo Finance API documentation to find an API endpoint URL that retrieves the specific information you need from your Yahoo Finance account. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the Yahoo Finance API documentation page: https://rapidapi.com/apidojo/api/yahoo-finance1/

The menu on the left contains the Yahoo Finance API’s endpoints:

Yahoo Finance API documentation page
Yahoo Finance API documentation page

In this case, we will describe the GET conversation/list endpoint which lists conversations relating to a symbol:

https://apidojo-yahoo-finance-v1.p.rapidapi.com/conversations/list?symbol=AAPL&messageBoardId=finmb_24937&region=US&userActivity=true&sortBy=createdAt&off=0

In the Code Snippets section, choose Shell => cURL to display the cURL command for the endpoint.

The documentation for this endpoint contains its HTTP method and URL path, a short description of the endpoint’s purpose, the header parameters, the required and optional parameters and the cURL command:

Get conversations/list endpoint
Get conversations/list endpoint

All API calls to the Yahoo Finance API should be made using the https://apidojo-yahoo-finance-v1.p.rapidapi.com/ base domain. All endpoints and parameters would be appended to this base domain.

Step 4.) Enter the Yahoo Finance API request into the Apipheny add-on

Okay, we’re in the home stretch. Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import Tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) as required by your Yahoo Finance API endpoint. For this example, we are using the GET method.

API URL: In Step 3, I explained how you can find the Yahoo Finance API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.

For this example, we are using the GET auto-complete endpoint, that gets auto complete suggestions by term or phrase. The corresponding URL for this endpoint is:

https://apidojo-yahoo-finance-v1.p.rapidapi.com/auto-complete?q=tesla&region=US

If you use this same URL, don’t forget to replace the q and region values with your own!

In the Headers of the Apipheny add-on section, add two rows with the following keys and values:

Header 1
Key
X-RapidAPI-Host
Value
apidojo-yahoo-finance-v1.p.rapidapi.com

Header 2
Key
X-RapidAPI-Key
Value
your_API_key

Don’t forget to replace your_API_Key with the key you previously obtained in Step 2.

  Yahoo Finance API request entered into Apipheny
Yahoo Finance API request entered into Apipheny

Step 5.) Run the Yahoo Finance API Request in your Google Sheets


The last step is to click the Run button at the bottom of the Apipheny add-on and then your Yahoo Finance data will be imported into your Google Sheet.

  Yahoo Finance data imported into Google Sheets
Yahoo Finance data imported into Google Sheets

After making a successful request to the Yahoo Finance API, try querying a different Yahoo Finance API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:

  • Save and schedule your Yahoo Finance API request
  • Make a POST request to the Yahoo Finance API (if available)
  • Use the custom =APIPHENY() function to call the Yahoo Finance API request inside your spreadsheet
  • Create an API request by referencing the value of a cell in the API URL with three curly braces eg. {{{Sheet1!A1}}}

More API Tutorials

Related Posts