Search API Connector Documentation

Print

Import Ahrefs Data to Google Sheets

premium

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

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.

  1. Select Ahrefs from the drop-down list of applications
    ahrefs-library-application
  2. Under Authorization, click Connect to Ahrefs
    ahrefs-library-authorization
  3. You will see a modal asking you to approve the connection. Click Allow.
    ahrefs-img2
  4. You'll then be returned to your Google Sheet, and can verify that your Ahrefs connection is now active.
    ahrefs-library-authorization-connected

Part 2: Pull Data from Ahrefs to Sheets

Now that we're connected, let's pull some data into Sheets.

  1. 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.
    ahrefs-library-parameters
  2. Fill out the other required parameters (mode and target). For this example we'll set mode as domain and target as ahrefs.com, but you can use your own values.
    ahrefs-library-parameters-2
  3. Set a destination sheet, name your request, and click Run to see response data in your sheet.
    ahrefs-library-response
  4. 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, using any of the URLs shown in the API documentation. To create a custom request, add the complete URL into the request URL field and select Ahrefs from the OAuth menu.
ahrefs-custom

To convert from a preset request to a custom API URL, tick the Add request URL box before running your preset request (under Output options). This will print out your complete API URL, which you can then copy/paste into the request URL field.

Part 4: API Documentation

Official API documentation: https://ahrefs.com/api/documentation

API request builder tool: https://ahrefs.com/api/api-request-builder

20 thoughts on “Import Ahrefs Data to Google Sheets”

  1. 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?

    Reply
  2. 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."

    Reply
  3. 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?

    Reply
  4. Hello,

    Is this possible to target several urls in the same query ?

    For exemple to concatenat a bunch of url and test all of them with only 1 request ?

    Larry

    Reply
    • Hey Sarah, the Ahrefs connection is only available for users on the Business plan, sorry for the confusion. You get a free 2 week trial when you first install API Connector, or feel free to message support with your email address if you'd like me to extend that for you.

      Reply
    • Hey Kerry, currently you'll need to use a custom request for that, as only custom requests let you reference cells. (We'll enable cell references in the preset application menu in the future, but it's not available yet).

      Reply
  5. Hey Ana,

    Would this support pulling data from multiple competitors into one sheet? Ideally want to build a giant competitor database of Referring Domains. Would this be achievable?

    Reply
    • Sure, you could pull referring domains for multiple competitors into a single sheet. It would probably be easiest to list all the domains in one sheet and then cycle through them with a custom request like https://apiv2.ahrefs.com/?output=json&mode=subdomains&from=refdomains&order_by=domain_rating:desc&target=+++Domains!A1:A10+++
      I think my main concern would be that if you want to build a giant database, Sheets may not be the best place, since it's not really suited for very large amounts of data. But that really depends on what you have in mind.

      Reply

Leave a Reply to Raza Cancel reply

Jump To...