Search API Connector Documentation
Import Ahrefs Data to Google Sheets
In this guide, I’ll get you started on pulling data from the awesome Ahrefs SEO tool suite into Google Sheets, using the API Connector add-on for Sheets. Targeted around backlinks, you can use the Site Explorer, Content Explorer, Keywords Explorer, Rank Tracker, and Site Audit to compare your website to competitors. All in all, it’s a pretty sweet tool and we can integrate its native API with Google Sheets!
Note: You need an account with Ahrefs to use this integration, and Ahrefs is not a free tool. However, through this integration, you can access their API without paying their additional API fee ($500+ a month, as shown here).
Contents
- Before You Begin
- Part 1: Connect to the Ahrefs API
- Part 2: Fetch Data from Ahrefs
- Part 3: Create a Custom API Request
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Connect to the Ahrefs API
The easiest way to get started with the Ahrefs API is through API Connector’s built-in integration.
- Select Ahrefs from the drop-down list of applications
- Under Authorization, click Connect to Ahrefs
- You will see a modal asking you to approve the connection. Click Allow.
- You’ll then be returned to your Google Sheet, and can verify that your Ahrefs connection is now active.
Part 2: Fetch Data from Ahrefs
Now that we’re connected, let’s pull some data into Sheets.
- There’s only one endpoint for Ahrefs so skip straight to Request parameters. Choose the table from which you’d like to retrieve data. For this example, we’ll choose
backlinks
. - Fill out the other required parameters (mode and target). For this example we’ll set mode as
domain
and target asahrefs.com
, but you can use your own values. - Set a destination sheet, name your request, and click Run to see response data in your sheet.
- Now select any other “from” table of interest and adjust parameters to get different data sets. You can pull in any of the data you see while logged into Ahrefs.
Part 3: Create a Custom API Request
Alternatively, you can run your own custom API requests instead of using API Connector’s pre-built integration. When you create a custom request, you add your complete URL into the request URL field and select Ahrefs from the OAuth menu.
Part 4: API Documentation
Official API documentation: https://ahrefs.com/api/documentation
API request builder tool: https://ahrefs.com/api/api-request-builder
Can we retrieve backlink for each cell instead of a one-off API request
Hey Amine, sorry, I’m not sure I understand your question. The ImportAPI function lets you run API requests from cells, is that what you’re looking for? If not please clarify and I’ll be happy to answer further.
This is quite handy. Thanks for sharing
You’re welcome, glad it’s useful!
Hi there
Does this works as integration app? Ahrefs offers API and integration as 2 separate things for some reason. Even the premium plan doesnt offer direct API access however you can connect your Ahrefs account with some existing App to get the required data. Will this work with an account or do you need API?
Yep, it lets you access API data for free, as long as you have an Ahrefs account. You don’t need to have their API plan.
Hi Ana,
when im using the sidebar this works perfect! But im trying to use importAPI with this and im getting this error:
“Request failed: Access not granted or expired. Please click Manage Connections and check OAuth2 connection status.”
You probably need to switch to a sheet where you’re the sheet owner. Please check the error messages section of this article, it explains the issue in more detail.
You mention that I can grab Keywords in your intro. What ‘From’ do I need to set in order to grab my saved keywords data for a specific domain?
It doesn’t look like they provide saved keyword lists via the API, you can see an old discussion about it on their roadmap. You can get some keywords data using the positions_metrics parameter.