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:
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.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
After logging into your GTmetrix account go to your account name and click the Account item from the drop-down menu:
Click the Generate API Key button:
Your API key is now generated. Copy it to a safe location because you’ll need it later:
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):
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:
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.
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 Encode. More 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:
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!
Crypto API Tutorials: