> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modulex.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Ahrefs Integration for AI Agents & Workflows

> SEO toolset providing backlink analysis, referring domain data, and site explorer metrics via the Ahrefs REST API

{/* Self-hosted logo — build-time vendored from modulex.json / Iconify (see scripts/lib/logo.js). */}

<img src="https://mintcdn.com/modulexaillc/zKB2qsP6Q61VNLfB/logos/ahrefs.svg?fit=max&auto=format&n=zKB2qsP6Q61VNLfB&q=85&s=a3017940118be25310320177c38756cd" alt="Ahrefs logo" width="72" height="72" data-path="logos/ahrefs.svg" />

## Overview

Add **Ahrefs** to any ModuleX agent or workflow. SEO backlink analysis and referring domain data via the Ahrefs REST API (`api.ahrefs.com/v3`).

<Info>
  **Categories**: Marketing & Advertising · SEO · Marketing · Web Search & Scraping · **Auth**: API Key · **Actions**: 3
</Info>

## Authentication

### API Key

Authenticate with an Ahrefs API v3 key (Account settings -> API keys; requires an eligible paid plan, key valid 1 year)

<Steps>
  <Step title="Step 1">
    Sign in to Ahrefs as a workspace owner or admin
  </Step>

  <Step title="Step 2">
    Go to Account settings -> API keys
  </Step>

  <Step title="Step 3">
    Create a new API key and copy it (each key is valid for 1 year)
  </Step>

  <Step title="Step 4">
    Paste the key into ModuleX
  </Step>
</Steps>

#### Required Credentials

| Field          | Description                                             | Required | Format |
| -------------- | ------------------------------------------------------- | -------- | ------ |
| Ahrefs API Key | Ahrefs API v3 key, sent as Authorization: Bearer \<key> | Yes      | `-`    |

## Available Actions

<AccordionGroup>
  <Accordion title="get_backlinks — Get the backlinks for a domain or URL with details for the referring pages (e.g., anchor and page title)">
    ### Parameters

    <ResponseField name="target" type="string" required>
      Domain or URL to get backlinks for
    </ResponseField>

    <ResponseField name="select" type="array" required>
      List of columns to return (e.g. url\_from, url\_to, ahrefs\_rank, anchor, page\_title)
    </ResponseField>

    <ResponseField name="mode" type="string">
      Mode of operation: exact, domain, subdomains, or prefix (Default: `domain`)
    </ResponseField>

    <ResponseField name="limit" type="integer">
      Number of results to return (Default: `1000`)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "$defs": {
        "BacklinkItem": {
          "additionalProperties": false,
          "description": "A single backlink record returned by the Ahrefs API.",
          "properties": {
            "url_from": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Url From"
            },
            "url_to": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Url To"
            },
            "ahrefs_rank": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Ahrefs Rank"
            },
            "anchor": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Anchor"
            },
            "page_title": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Page Title"
            },
            "first_seen": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "First Seen"
            },
            "last_seen": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Last Seen"
            },
            "domain_rating": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Domain Rating"
            },
            "extra": {
              "anyOf": [
                {
                  "additionalProperties": true,
                  "type": "object"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "description": "Additional fields returned by the API based on the select parameter",
              "title": "Extra"
            }
          },
          "title": "BacklinkItem",
          "type": "object"
        }
      },
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "backlinks": {
          "items": {
            "$ref": "#/$defs/BacklinkItem"
          },
          "title": "Backlinks",
          "type": "array"
        },
        "total": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Total"
        }
      },
      "required": [
        "success"
      ],
      "title": "GetBacklinksOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="get_backlinks_one_per_domain — Get one backlink with the highest ahrefs_rank per referring domain for a target URL or domain">
    ### Parameters

    <ResponseField name="target" type="string" required>
      Domain or URL to get backlinks for
    </ResponseField>

    <ResponseField name="select" type="array" required>
      List of columns to return (e.g. url\_from, url\_to, ahrefs\_rank, anchor, page\_title)
    </ResponseField>

    <ResponseField name="mode" type="string">
      Mode of operation: exact, domain, subdomains, or prefix (Default: `domain`)
    </ResponseField>

    <ResponseField name="limit" type="integer">
      Number of results to return (Default: `1000`)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "$defs": {
        "BacklinkItem": {
          "additionalProperties": false,
          "description": "A single backlink record returned by the Ahrefs API.",
          "properties": {
            "url_from": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Url From"
            },
            "url_to": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Url To"
            },
            "ahrefs_rank": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Ahrefs Rank"
            },
            "anchor": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Anchor"
            },
            "page_title": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Page Title"
            },
            "first_seen": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "First Seen"
            },
            "last_seen": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Last Seen"
            },
            "domain_rating": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Domain Rating"
            },
            "extra": {
              "anyOf": [
                {
                  "additionalProperties": true,
                  "type": "object"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "description": "Additional fields returned by the API based on the select parameter",
              "title": "Extra"
            }
          },
          "title": "BacklinkItem",
          "type": "object"
        }
      },
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "backlinks": {
          "items": {
            "$ref": "#/$defs/BacklinkItem"
          },
          "title": "Backlinks",
          "type": "array"
        },
        "total": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Total"
        }
      },
      "required": [
        "success"
      ],
      "title": "GetBacklinksOnePerDomainOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="get_referring_domains — Get the referring domains that contain backlinks to the target URL or domain">
    ### Parameters

    <ResponseField name="target" type="string" required>
      Domain or URL to get referring domains for
    </ResponseField>

    <ResponseField name="select" type="array" required>
      List of columns to return for referring domains (e.g. domain, domain\_rating, backlinks)
    </ResponseField>

    <ResponseField name="mode" type="string">
      Mode of operation: exact, domain, subdomains, or prefix (Default: `domain`)
    </ResponseField>

    <ResponseField name="limit" type="integer">
      Number of results to return (Default: `1000`)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "$defs": {
        "ReferringDomainItem": {
          "additionalProperties": false,
          "description": "A single referring domain record returned by the Ahrefs API.",
          "properties": {
            "domain": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Domain"
            },
            "domain_rating": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Domain Rating"
            },
            "backlinks": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Backlinks"
            },
            "first_seen": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "First Seen"
            },
            "last_seen": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Last Seen"
            },
            "extra": {
              "anyOf": [
                {
                  "additionalProperties": true,
                  "type": "object"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "description": "Additional fields returned by the API based on the select parameter",
              "title": "Extra"
            }
          },
          "title": "ReferringDomainItem",
          "type": "object"
        }
      },
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "refdomains": {
          "items": {
            "$ref": "#/$defs/ReferringDomainItem"
          },
          "title": "Refdomains",
          "type": "array"
        },
        "total": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Total"
        }
      },
      "required": [
        "success"
      ],
      "title": "GetReferringDomainsOutput",
      "type": "object"
    }
    ```
  </Accordion>
</AccordionGroup>

## Limits & Quotas

* Rate limits depend on your Ahrefs subscription plan (Lite, Standard, Advanced, Enterprise).
* API usage is metered against monthly "API rows" quota included in your plan.
* Error model: non-2xx responses and timeouts are caught and returned as `success=False` + `error` rather than raising.

## Related integrations

<CardGroup cols={3}>
  <Card title="Google Search Console" href="/integrations/tools/google-search-console" />

  <Card title="Google Ad Manager" href="/integrations/tools/google-ad-manager" />

  <Card title="Google My Business" href="/integrations/tools/google-my-business" />
</CardGroup>

## Links

* [Ahrefs](https://ahrefs.com)
