Automate Importing Financial Market Data To Google Sheets Using Polygon.io API

Reading Time: 5 minutes

Polygon.io is a platform that provides data about various financial markets like stock, forex, cryptocurrency, and options chains. The key data endpoints include market data endpoints like aggregates, gainers/losers, technical indicators, etc. These data endpoints can help one to make well-informed trading decisions. 

You can automate importing financial market data to Google Sheets in just a matter of a few seconds by using an extension Amigo Data. Amigo data saves you from manually retrieving data, set up once and let Amigo data do the job for you. 

In this tutorial, we will learn how to import the Relative Strength Index (RSI) of a stock. RSI helps one understand if a particular stock is overbought or oversold. Below are the steps to import the RSI data of stock into Google Sheets:

Automate Importing financial market data to Google Sheets

Install the Amigo Data add-on

Install the Amigo Data Google Sheets add-on from the Google Workspace Marketplace. Click here to install.

Amigo Data in Google Workspace Marketplace

Alternatively, you can get it from Google Sheets.

  • Open a new sheet
  • Go to Extensions→Add-ons→Get add-ons
  • Search for Amigo Data and install

Generate Polygon.io API key

Visit Polygo.io and click on the Get your Free API Key option.

Automate importing financial market data to Google Sheets using Polygon.io API

You will be asked to enter your credentials and sign up.

Sign up to create an account

You will be redirected to the dashboard after getting logged in.

Welcome to the dashboard

On the left side, click the API Keys option to view your API key. 

Select API Keys option

Your API key gets displayed.

You will find the API key here

Get the endpoint of the data to import to Google Sheets

On the dashboard page, click RESTful Docs option under the Documentation header.

Select RESTful Docs option

You will be redirected to the Stocks documentation by default. You can also explore options, forex, and crypto tabs.

Select the stocks tab

We will stay on the stocks tab as we wish to import RSI data for Google Stock. On the left side, from the list of options select Technical Indicators -> Relative Strength Index (RSI).

Under the technical indicators section, select Relative Strength Index (RSI)

In the stockTicker parameter, AAPL (Apple) stock is passed by default. We wish to import RSI data for Google, so we will pass GOOGL (Google ticker symbol) in the stockTicker parameter. You can also query by timestamp (YYYY-MM-DD). Window is used to adjust the span of RSI indicator, by default it is 14 days. 

Enter the stock ticker symbol

You can tune in the RSI indicator according to our requirements by simply adjusting the parameters. For the sake of simplicity, we won’t change the default parameters.

Scroll down a bit and you will come across a URL link. The URL link gets dynamically modified with the change in parameters. Before proceeding, you can run the query to test the endpoint. If it shows success with response code 200, then it means that the endpoint it working perfectly and the passed parameters are valid. 

Copy the URL using the copy option. 

Import the data to Google Sheets

Now to back to Google Sheets and launch Amigo Data by clicking Extensions→Amigo Data→Connect.

Launching Amigo Data in Google Sheets

Then select Custom API from the list of sources.

Selecting the source in Amigo Data

Paste the endpoint URL in the API URL field.

Pasting the endpoint

Click on the Preview option.

Click the button to preview

Flatten the data and click on IMPORT.

Flatten and import the data

The data will be imported into Google Sheets in a short while. Below is the snippet of the data imported.

Snippet of the imported data

Other types of data can also be imported to Google Sheets in the similar manner. 

Daily Open/Close options data

Select the options tab to view the options documentation.

Click on options tab

Under the market data endpoints, select the daily open/close option. Enter the options contract ticker symbol along with the date. An options contract ticker symbol comprises of the stock ticker symbol, expiry date and strike price. To know about the structure of options contract ticker symbol, click here. You may wish to add optional parameters to fine tune your result. 

Enter the options contract ticker symbol

Scroll down and copy the endpoint URL to import data using the Amigo Data add-on.

Click this button to copy the URL

Previous close Forex data

This endpoint gives the exchange rate data at the time of close. In the parameter section enter the ticker symbol of currency pair to fetch the data. 

For example, for the EURUSD currency pair (EUR for base currency and USD for target currency), the URL link is as follows:

Similarly, you can also explore other endpoints. Some endpoints may require a premium subscription. Polygon.io has so much to offer. You can import any kind of financial market data using this interface. To explore more endpoints go through the documentation of Polygon.io. 

After importing the data, you can also set a refresh schedule so that the data are updated automatically at regular intervals. By this you can automate importing financial market data to Google Sheets. To learn how to set a refresh schedule, follow this link.

There are several other types of data that you can import into Google Sheets using Amigo Data such as Marketstack data,  Coinmarketcap data, Nasdaq data, and many more. 

Some related articles you may be interested in:

Get Real-time Stock Data In Google Sheets Using MarketStack API

Import CoinMarketCap Data To Google Sheets

Import Data From Nasdaq To Google Sheets