How to connect the GTmetrix API to Google Sheets

GTmetrix is a web-based tool that provides an analysis of website speed. We can use the GTmetrix API to import data from GTmetrix into Google Sheets. In this tutorial, we’ll show you how to connect the GTmetrix REST API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Obtain an API key
  3. Choose a GTmetrix endpoint
  4. Enter your GTmetrix API request into Apipheny
  5. Run the GTmetrix API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on for Google Sheets

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

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.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Obtain an API key

After logging into your GTmetrix account go to your account name and click the Account item from the drop-down menu:

GTmetrix dashboard
GTmetrix dashboard

Click the Generate API Key button:

Generating an API key
Generating an API key

Your API key is now generated. Copy it to a safe location because you’ll need it later:

API key is displayed on the screen
API key is displayed on the screen

Step 3.) Choose an GTmetrix endpoint

In this section, we’ll show you how to browse the GTmetrix API documentation to find an endpoint that retrieves the information you need. 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 GTmetrix API documentation page: https://gtmetrix.com/api/docs/2.0/#  

The menu on the left contains general information about the GTmetrix API and a list of REST requests (endpoints):

GTmetrix API documentation page
GTmetrix API documentation page

An example endpoint is Get a list of tests, which displays a paginated list of all the tests belonging to your account. The URL for this endpoint is:

https://gtmetrix.com/api/2.0/tests

Each endpoint’s documentation contains a descriptive title, a paragraph describing the endpoint’s purpose, the endpoint’s HTTP method (GET) and URL, the URI query parameters as well as an example response:

Get a list of tests endpoint documentation
Get a list of tests endpoint documentation

All API calls to GTmetrix should be made to the https://gtmetrix.com/api/2.0 base domain. All endpoints should be appended to this base URL.

Step 4.) Enter your GTmetrix API request into Apipheny

Now, to get your GTmetrix data in your Google Sheet, go back to your Google Sheet and make sure that you’ve installed the Apipheny add-on and you have it opened on the Import tab. In the Import tab of Apipheny, enter the following details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET, POST, PUT, PATCH or DELETE) required by your GTmetrix API endpoint. For this example, we are using the “GET” method.

API URL: In Step 3, we explained how you can find the GTmetrix API endpoint that you need. Now copy your complete GTmetrix API URL into the Apipheny add-on, in the field that says API URL Path, followed by any POST parameters required for your query (if applicable).

For this example, we are using the Get your account status endpoint, which gets the current account details. The URL for this specific endpoint is:

https://gtmetrix.com/api/2.0/status

If you’re following the same example as us, just copy and paste the above URL into Apipheny.

Headers: In the Headers section of the Apipheny add-on, add one row with the following key and value:

Header

Key:
Authorization

Value:
Basic encoded_string

When entering the Header Value, replace encoded_string with the Base64-encoded version of your concatenated API key with a semicolon. You can use a site you trust like https://www.base64encode.org/ to encode your api_key: string. Just enter your details like this api_key: and then click EncodeMore info about Base64 encoding.

Here’s what your GTmetrix API request should look like when entered into Apipheny, if you’re following the same example as us:

GTmetrix API request entered in the Apipheny add-on
GTmetrix API request entered in the Apipheny add-on

Step 5.) Run the GTmetrix API request in your Google Sheet

The last step is to click the Run button at the bottom of the Apipheny add-on and then your GTmetrix data will be imported into your Google Sheets. Congratulations!

GTmetrix API request entered in the Apipheny add-on
GTmetrix API request entered in the Apipheny add-on

Crypto API Tutorials:


API Tutorials


API Knowledge

What is an API?

What is an API URL?

What are parameters?

What is an endpoint?

What is an API key/token?

What is basic authentication?

What are headers?

What is a GET request?

What is a POST request?