titledescriptionupdated_date
Ahrefs API2025-10-24T16:45:21Z

Ahrefs API Integration

Overview

Ahrefs is a comprehensive SEO tool that provides data for keyword research, backlink analysis, competitor analysis, and keyword rank tracking. This guide explains how to set up API access and permissions for Ahrefs integration.

What We Need?

To access Ahrefs API data, you will need:

  • Enterprise Account: Full API access requires an Ahrefs Enterprise plan
  • API Key: Generated by a workspace owner or administrator
  • Authentication: Bearer token for API requests
  • API Units: Check your plan’s API unit allocation (Enterprise plans include a set number of units)
  • Rate Limit Understanding: Default is 60 requests per minute

Eligibility

  • Enterprise Plan Required: Full Ahrefs API access is only available for Enterprise plans
  • Limited Access: Other plans have access to a limited set of free test queries
  • Contact Enterprise Team: To upgrade to API v3, contact the Ahrefs Enterprise team

API Keys & Permissions Setup

Creating API Keys

  1. Admin Access Required: Only workspace owners and administrators can create and manage API keys
  2. Generate API Key:

API Key Management

  • Set Limits: You can set limits on your API keys (recommended during testing/development)
  • Multiple Keys: Create multiple keys for different applications or purposes
  • Revocation: Keys can be revoked at any time from the same interface or automatically when the user who created the API key is removed from the workspace

Authentication

API requests require Bearer token authentication:

  • Header Format:
    Authorization: Bearer your_API_key
    Content-Type: application/json
    
  • Token Security: Store your API key securely and never expose it in client-side code

Integration Details

  • Base URL: https://api.ahrefs.com/v3/
  • Rate Limiting: 60 requests per minute by default
  • API Units:
    • Requests consume API units based on data volume and fields requested
    • Minimum cost for any request is 50 units
    • Enterprise plans include a certain number of API units
    • Additional units are charged on a pay-as-you-go basis

Available Endpoints

Ahrefs API v3 provides access to the following data:

  • Site Explorer:

    • Overview stats and historical charts
    • Backlinks and referring domains
    • Organic and paid traffic reports
  • Keywords Explorer:

    • Metrics for keywords
    • Search volume history and volume by country
    • Keyword ideas reports
  • SERP Overview:

    • Top 100 SERP results
  • Site Audit:

    • Projects’ Health Scores
    • Content of crawled pages
  • Rank Tracker:

    • Project overview
    • Competitor reports
    • Rank Tracker SERPs
  • Management Endpoints:

    • Manage Rank Tracker projects
    • Manage Keywords Explorer lists
  • Subscription Information:

    • API limits and usage
  • Public Endpoints:

    • Crawler IP addresses and ranges

Example Request

Method: GET
URL: https://api.ahrefs.com/v3/site-explorer/domain-rating?target=example.com&output=json
Headers:
  Authorization: Bearer your_API_key
  Content-Type: application/json

Best Practices

  1. Use Test Queries: Utilize free test queries for development and testing
  2. Set Key Limits: Put limits on your API keys, especially during testing
  3. Optimize Requests: Only request the fields you need to reduce API unit consumption
  4. Monitor Usage: Track API unit consumption in Account settings / Limits & usage
  5. Handle Rate Limits: Implement proper handling for 429 (Too Many Requests) responses

Additional Resources