Polygon.io is a platform that provides data about various financial markets like stock, forex, cryptocurrency, and options chains. The key data include market data endpoints like aggregates, gainers/losers, technical indicators, etc.
You can automate importing financial market data to Google Sheets using Polygon.io API. in just a matter of a few seconds with an extension called Amigo Data. Amigo is a data integration and automation tool that you can use to automate data imports to Google Sheets.
Below is a snippet of dividends data imported into Google Sheets with Polygon API.
So let’s learn how to automatically import financial market data to Google Sheets using Polygon.io API.
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 market data of stock into Google Sheets with Polygon.io API:
- Install the Amigo Data add-on
- Generate Polygon.io API key
- Get the data endpoint
- Import the data to Google Sheets
How to 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.
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 Polygon.io and click Get your Free API Key.
Sign up to Polygon.io to get your Polygon API key.
Upon signing up to Polygon.io, your Polygon.io API key will be created, and you’ll be redirected to the Polygon API dashboard.
On the left side of the dashboard, click the API Keys option to view your API key.
You’ll find the Polygon.io API key under API Keys.
Get the endpoint of the data
On the Polygon API dashboard, click RESTful Docs under the Documentation header to go to the Polygon.io API documentation.
You will be taken to the Stocks API documentation. To explore other APIs such as options API, and forex API, click the respective APIs.
For this article, we’ll import the relative strength index of a stock using the Stock API.
Under Market Data Endpoints, expand Technical Indicators and select Relative Strength Index (RSI).
In the stockTicker parameter, AAPL (Apple) stock is added by default. Let us import the RSI data for Google, so we will enter 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.
You can tune in the RSI indicator according to your requirements by simply adjusting the parameters. For the sake of simplicity, keep the default parameters as they are.
Scroll down a bit and you will find the Polygon API endpoint URL link. The URL gets dynamically modified with the change in parameters. Before proceeding, you can run the query to verify if the parameters you’ve inputted are valid. 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 Polygon.io API endpoint URL using the copy option. This is the URL we’ll use to import Polygon stock data to Google Sheets.
Import the data to Google Sheets
Now to back to Google Sheets and launch Amigo Data to import stock data to Google Sheets with Polygon.io API by clicking Extensions→Amigo Data→Connect.
Then select Custom API from the list of sources.
Paste the Polygon.io API endpoint URL in the API URL field.
Click the PREVIEW button to retrieve the data and preview the data to import to Google Sheets.
Flatten the nested datasets and click IMPORT.
The Polygon market data will be imported into Google Sheets in a short while. Below is the snippet of the data imported to Google Sheets using Polygon API.
Other types of data can also be imported to Google Sheets in a similar manner. You can also likewise import option data to Google Sheets using the Options API, crypto data with the Crypto API, and forex data using the Forex API.
Examples of few other endpoints
Daily Open/Close options data
Select the Options tab to view the options API documentation.
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 the stock ticker symbol, expiry date and strike price. To know about the structure of options contract ticker symbol, click here. Add the optional parameters to filter the result.
Scroll down and copy the endpoint URL to import data using the Amigo Data add-on.
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 the 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 API.
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