Alpha Vantage provides enterprise-grade financial market data through a set of powerful and developer-friendly APIs. We can use the Alpha Vantage API to import data from Alpha Vantage into Google Sheets. In this tutorial, I’ll show you how to connect the Alpha Vantage REST API to Google Sheets in 5 steps:
Apipheny is a free API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to API data sources, easily.
1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install
2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.
In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
Go to https://www.alphavantage.co/ and click the GET YOUR FREE API KEY TODAY button:
In the Claim your Free API Key section, complete all the fields and then click the GET FREE API KEY button:
Your API key will be displayed on the net window:
Copy your key to a safe location because you’ll need it later.
In this section, I’ll show you how to browse the Alpha Vantage API documentation to find an API endpoint that retrieves the specific information you need from your Alpha Vantage 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 Alpha Vantage API documentation page: https://www.alphavantage.co/documentation/
The menu on the left contains general information about the Alpha Vantage API and a list of APIs, each with its endpoints:
For example, the Fundamental Data API has 8 endpoints: Company Overview, Earnings, Income Statement, Balance Sheet, Cash Flow, Listing & Delisting Status, Earnings Calendar and IPO Calendar.
An example endpoint is Company Overview that returns the company information, financial ratios, and other key metrics for the equity specified:
https://www.alphavantage.co/query?function=OVERVIEW&symbol=IBM&apikey=API_KEY
If you use this URL, don’t forget to replace API_KEY with your API key!
The documentation for this endpoint contains the API parameters, the endpoint URL and the Language-specific guides:
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 Alpha Vantage API endpoint. For this example, we are using the GET method.
API URL: In Step 3, I explained how you can find the Alpha Vantage API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path (JSON / CSV), followed by any GET parameters required for your query.
For this example, we are using the TIME_SERIES_INTRADAY endpoint that returns intraday time series of the equity specified, covering extended trading hours where applicable. The corresponding URL for this endpoint is:
https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=IBM&interval=5min&apikey=api_key
If you use this URL, don’t forget to replace api_key with your previously obtained API key from Step 2.
Headers: Headers aren’t required for this API, you can leave that section blank in Apipheny.
The last step is to click the Run button at the bottom of the Apipheny add-on and then your Alpha Vantage data will be imported into your Google Sheet.
After making a successful request to the Alpha Vantage API, try querying a different Alpha Vantage API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:
Schedule requests for automatic updates
Reference cell values in requests
Stack multiple URLs in a single request
Crypto API Tutorials: