Get Real-Time Stock Data In Google Sheets Using Marketstack API

Reading Time: 5 minutes

Being able to fetch real-time stock data in Google Sheets can help you build your trading strategies. 

Here in this article, we’re going to learn how to import real-time stock data to Google Sheets using a real-time stock API called Marketstack. The Marketstack API allows us to retrieve information such as intra-day data, EOD data, dividends data, and real-time updates among others.

Using Amigo Data, a data retrieval and automation tool, we can easily import real-time stock data into Google Sheets with Marketstack API.

Below is a snippet of EOD data for Apple imported into Google Sheets.

Real-time stock data in Google Sheets

Steps get real-time stock data in Google Sheets.

How to get real-time stock data in Google Sheets

1. Install the Amigo Data add-on

Get the Amigo Data add-on from Google Workspace Marketplace.

Click here to install.

Install Amigo to get real-time stock data in Google Sheets

2. Get the Marketstack API key

There are several stock quotes API that let us import real-time stock data into Google Sheets. We’ll use the Marketstack API.

Go to Marketstack API documentation and click “GET API KEY”.

Marketstack API documentation page

Fill in the details and click “Sign Up”.

Signing up to Marketstack to get real-time stock data in Google Sheets

After successfully signing up, you will be redirected to a new page where you can see your API access key. This is the key we’ll use to get real-time stock data in Google Sheets.

Marketstack API access key

3. Choose the data endpoint

Navigate to the Documentation page by clicking Documentation 

Marketstack API access key page

On the left side, under the Features section, choose any of the categories of stock data to import to Google Sheets. We’ll choose End-of-day Data. 

Choose End-of-day from the features section

Note: Some of these data are restricted to the paid plans. So if you’re on the free plan, then you won’t be able to access them.

An example endpoint URL is given with Apple ticker symbol as the default.

Select the endpoint URL

We can modify the URL using any or all of the objects under HTTP GET Request Parameters.

Query parameters

We can append the query parameters either in the endpoint URL or enter them in the “Query” field in Amigo (on this later).

For example, to fetch Apple EOD data from 1 Dec 2022 to 31 Dec 2022, we’ll modify the URL as follows.

To add additional parameters, use the ampersand and append the parameter names and their values.

Having got the endpoint URL and modified it with our preferred values, we can now begin to import the stock data from Marketstack to Google Sheets.

4. Import data to Google Sheets

Open a new spreadsheet and launch Amigo Data.

Launch Amigo to import stock data to Google Sheets

Select Custom API from the list of sources.

Selecting the source in Amigo Data

Enter the stock API endpoint URL API URL field.

Pasting the endpoint

In the Details section, delete the access_key as it contains a dummy API key placeholder and add your stock API key obtained from Marketstack.

Click on the delete button

We need to add the original API key to make a valid request.  Click on the “+Query” option

Click to add a query

Enter the “access_key” as the name and your API key in the value section. Click “+ADD QUERY”

Enter the API key in value section

Instead of appending the parameters in the URL, we can enter them here as queries. Enter the parameter name and the values and click “Add Query”.

Entering the query parameters

Click the PREVIEW button to retrieve the data and preview them.

Then flatten and expand the dataset so that they are organized suitably. Once that is done, click the IMPORT button.

Preview of the stock data to import to Google sheets

A few moments later, you’ll have a spreadsheet populated with the data from Marketstack with the high, close, volume, etc.

Shown below is a snippet of the real-time stock data in Google Sheets.

Snippet of the data imported from the marketstack to Google Sheets

You can likewise import dozens of other types of data using the Marketstack real-time stock data API. Following are some other examples.

Real-time stock quotes API endpoint

This end-point gives you real-time updates about the Apple stock. The key-value pair is separated by “&” sign. In the symbols parameter, you can add a symbol of any stock to fetch the data of that particular stock. You can also set the interval (1min, 5min, or 10min) as per your requirements by simply changing the numeric value. 

You can track multiple stocks by adding the tickers you want to track in the symbols parameter separating the tickers by commas.

Note: Replace YOUR_ACCESS_KEY in the URL with your key.

Historical data endpoint

Along with the symbols parameter, you can also change the date_from (YYYY-MM-DD) and date_to (YYYY-MM-DD) parameter according to your requirements. 

Dividends data endpoint

In the Marketstack documentation page, you can explore more endpoints and try them out. 

After importing the data, you can also set a refresh schedule so that the data are updated automatically at regular intervals. 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 Spotify data, Wikipedia data, Reddit data, and many more. 

Some related questions

How to automatically update stock prices in Google Sheets?

What are some stock data APIs to get real-time stock data?

Why do I get “Invalid JSON” error?

Some related articles you may be interested in:

Import data from Spotify to Google Sheets

Import Wikipedia data to Google Sheets

Import Yahoo Finance Data Into Google Sheets

Leave a Reply