MacroTrends is a premier research platform for long-term investors that enables users to fetch real-time and historical data related to stocks, commodities, exchange rates, inflation rates, and many more. It’s a one-stop solution for fetching all sorts of financial data to make data-driven decisions.
In this article, we will learn how to import MacroTrends data to Google Sheets using MacroTrends API using Amigo Data, a Google Sheets extension. You will be able to import various kinds of financial statement data like cash statement, balance sheet, and income statement. Amigo Data gives you the flexibility to update your data automatically–just set it up once and let Amigo Data do the job for you.
Here is a snippet of Amazon’s annual cash statement imported from MacroTrends to Google Sheets.
To import MacroTrends data to Google Sheets using MacroTrends API, we will follow the steps below:
- Install the Amigo Data add-on
- Generate API key
- Get the data endpoint
- Import the data to Google Sheets
How to automate MacroTrends data imports to Google Sheets
Here’s the step-by-step guide to import MacroTrends 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 the API key
We’ll use a third-party on RapidAPI since MacroTrends does not have an official API–it’s not public in any case.
Sign up to RapidAPI.
Once you’ve signed up and are logged in, go to the MacroTrends Finance API in RapidAPI.
Choose a subscription plan from the Pricing menu post which we’ll be able to use the MacroTrends API. We’ll choose the Basic plan; it can always be upgraded.
Click on Endpoints and scroll down a bit to find the RapidAPI key. You will find your API key under the Header Parameters. This will be used as they key for MacroTrends.
Choose an endpoint
On the left of the “API Playground” is the list of all data endpoints.
For this tutorial, let us import balance sheet data using the FinancialBalanceSheet endpoint. This endpoint provides us with 15+ years of balance sheet data cash on hand, inventory, prepaid expenses, and many more.
In the required parameters section, you can enter frequency details (A: annual, Q: quarterly) and the ticker symbol. Let us retrieve Apple’s annual balance sheet statement.
Click the Test Endpoint option to run the query and verify if the parameters are valid.
The success message indicates that the endpoints are functioning correctly.
On the right side under Code Snippets can be found the MacroTrends API endpoint URL for the data with our query parameters.
Change the language from (Node.js) Axios to Shell->cURL from the dropdown menu.
Copy the URL excluding the apostrophes and also note the headers. This is the endpoint URL for the data to import to Google Sheets.
Import data to Google Sheets
Go back to Google Sheets and launch the Amigo Data extension.
Select Custom API from the list of sources.
Paste the MacroTrends API endpoint URL in the API URL bar.
Then expand the Details tab and enter the following as headers:
Name: X-RapidAPI-Host, Value: macrotrends-finance.p.rapidapi.com
Name: X-RapidAPI-Key, Value: your_key
Replace your_key with your RapidAPI key.
Then click the PREVIEW button.
Flatten the nested data points and then click IMPORT.
The balance sheet data for Apple will be imported into Google Sheets in a moment.
A snippet of the imported data.
You can likewise import other types of data from MacroTrends Finance API. Following are some other examples.
Financial cash statement data
Using the FinancialCashStatement endpoint, you can import the 15+ years of data of cash statements of an corporation. In the required parameters section, you can enter freq (A: annual, Q: quarterly) and the ticker symbol.
Financial Income Statement
With the FinancialIncomeStatement endpoint, you can import the 15+ years of data of income statements of an organization. In the required parameters section, you can enter freq (A: annual, Q: quarterly) and the ticker symbol.
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.
And not only automate the data import but also receive alerts via email (or Slack) of the updated data.
There are several other types of data that you can import into Google Sheets using Amigo Data such as CNBC data, Trading View data, Coinranking data, and many more. Visit our blog to find out the kinds of data you can import to Google Sheets.
Some related articles you may be interested in: