Agent skill

Ahrefs Python

by OpenClaudia in OpenClaudia/openclaudia-skills

Manages Ahrefs API usage in Python using ahrefs-python library.

MITAuto-check passedMarketing & SEO

Install Ahrefs Python

skills CLI
$ npx skills add OpenClaudia/openclaudia-skills --skill ahrefs-python -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install OpenClaudia/openclaudia-skills ahrefs-python --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/OpenClaudia/openclaudia-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/ahrefs-research .claude/skills/ahrefs-python && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ahrefs-python
GitHub stars
708
Token cost
~1.9k tokens
SKILL.md length
477 words
Files
3 (incl. references)
Skills in repo
74
Repo updated
First seen
Licence
MIT

At a glance

Manages Ahrefs API usage in Python using ahrefs-python library.

  • Working with SEO / marketing related tasks
  • SKILL.md covers Overview, Installation, API Method Discovery and IMPORTANT RULES, plus 3 more sections
  • Calls python3 and pip3; reaches github.com and api.ahrefs.com; needs AHREFS_API_KEY
  • With data including backlinks

What it does

Ahrefs Python is an agent skill from OpenClaudia/openclaudia-skills. Manages Ahrefs API usage in Python using ahrefs-python library. Use when working with SEO / marketing related tasks or with data including backlinks, keywords, domain ratings, organic traffic, site audits, rank tracking, and brand monitoring. Covers ahrefs-python usage including AhrefsClient / AsyncAhrefsClient, typed request/response models, error handling, and all API sections.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/api-methods.md` and `references/filter-syntax.md`).

It sits in Marketing & SEO, covering SEO audit, Link building and Error handling. It works with Ahrefs and Python. The repository describes itself as: 77 open-source marketing skills for Claude Code, Codex, and other AI coding agents. SEO, content, email, ads, analytics, and growth. The licence is MIT.

When your agent uses it

  • Working with SEO / marketing related tasks
  • With data including backlinks
  • Organic traffic
  • Brand monitoring

Example prompts

  • “Use the ahrefs-python skill to manage Ahrefs API usage in Python using ahrefs-python library”
  • “/ahrefs-python”

Requirements

  • Python 3
  • A credential in AHREFS_API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit 28bf209. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python3
    • pip3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • github.com
    • api.ahrefs.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • AHREFS_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Ahrefs Python loads about 1.9k tokens when it runs, and up to ~76k if it reads all its reference files. Until then it costs about 100 tokens; SKILL.md has 477 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~100
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~76k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from OpenClaudia/openclaudia-skills at commit 28bf209, republished under its MIT licence (© OpenClaudia). 477 words, ~1,895 tokens.

Download SKILL.mdSave it as .claude/skills/ahrefs-python/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
ahrefs-python
description
Manages Ahrefs API usage in Python using `ahrefs-python` library. Use when working with SEO / marketing related tasks or with data including backlinks, keywords, domain ratings, organic traffic, site audits, rank tracking, and brand monitoring. Covers `ahrefs-python` usage including AhrefsClient / AsyncAhrefsClient, typed request/response models, error handling, and all API sections.

Ahrefs Python SDK Skill

Overview

The Ahrefs API provides programmatic access to Ahrefs SEO data. The official Python SDK (ahrefs-python) provides typed request and response models for all endpoints, auto-generated from the OpenAPI spec.

Key capabilities:

  • Site Explorer - Backlinks, organic keywords, domain rating, traffic, referring domains
  • Keywords Explorer - Keyword research, volumes, difficulty, related terms
  • Rank Tracker - SERP monitoring, competitor tracking
  • Site Audit - Technical SEO issues, page content, page explorer
  • Brand Radar - AI brand mentions, share of voice, impressions
  • SERP Overview - Search result analysis
  • Batch Analysis - Bulk domain/URL metrics via POST

Installation

sh
pip3 install git+https://github.com/ahrefs/ahrefs-python.git

Requires Python 3.11+. Dependencies: httpx, pydantic.

API Method Discovery

The SDK has 52 methods across 7 API sections. The built-in search tool is the fastest way to find the right method — it returns matching method signatures, parameters, and return types directly, so there's no need to scan through a large reference.

Python (preferred when already in a Python context):

python
from ahrefs.search import search_api_methods

# Returns formatted text with method signatures, parameters, and return types
print(search_api_methods("domain rating"))

# Filter by API section and limit results
print(search_api_methods("backlinks", section="site-explorer", limit=3))

CLI (preferred when exploring from the terminal):

sh
# Ensure python3 points to the interpreter where ahrefs-python is installed:
#   which python3
#   python3 -c "import ahrefs"
python3 -m ahrefs.api_search "domain rating"
python3 -m ahrefs.api_search "backlinks" --section site-explorer --limit 3
python3 -m ahrefs.api_search "batch" --json
python3 -m ahrefs.api_search --sections  # list all API sections

IMPORTANT RULES

  • ALWAYS use the ahrefs-python SDK. DO NOT make raw httpx/requests calls to the Ahrefs API.
  • ALWAYS pass dates as strings in YYYY-MM-DD format (e.g. "2025-01-15").
  • ALWAYS use select on list endpoints to request only the columns you need. List endpoints return all columns by default, which wastes API units and increases response size.
  • USE context managers (with / async with) for client lifecycle management.
  • NEVER hardcode API keys in source code. Use the AHREFS_API_KEY environment variable or your preferred secrets mechanism.
  • The client handles retries (429, 5xx, connection errors) automatically. DO NOT implement your own retry logic on top of the SDK.

Quick Start

python
import os
from ahrefs import AhrefsClient

with AhrefsClient(api_key=os.environ["AHREFS_API_KEY"]) as client:
    data = client.site_explorer_domain_rating(target="ahrefs.com", date="2025-01-15")
    print(data.domain_rating)  # 91.0
    print(data.ahrefs_rank)    # 3

SDK Patterns

Client Setup
python
import os
import ahrefs

with ahrefs.AhrefsClient(
    api_key=os.environ["AHREFS_API_KEY"],  # or any secrets source
    base_url="...",          # override API base URL (default: https://api.ahrefs.com/v3)
    timeout=30.0,            # request timeout in seconds (default: 60)
    max_retries=3,           # retries on transient errors (default: 2)
) as client:
    ...

Async client:

python
import os
from ahrefs import AsyncAhrefsClient

async with AsyncAhrefsClient(api_key=os.environ["AHREFS_API_KEY"]) as client:
    data = await client.site_explorer_domain_rating(target="ahrefs.com", date="2025-01-15")

For parallel calls, use asyncio.gather:

python
import asyncio

async with AsyncAhrefsClient(api_key=os.environ["AHREFS_API_KEY"]) as client:
    dr_ahrefs, dr_moz = await asyncio.gather(
        client.site_explorer_domain_rating(target="ahrefs.com", date="2025-01-15"),
        client.site_explorer_domain_rating(target="moz.com", date="2025-01-15"),
    )
Calling Methods

Two calling styles -- both are equivalent:

python
# Keyword arguments (recommended)
data = client.site_explorer_domain_rating(target="ahrefs.com", date="2025-01-15")

# Request objects (full type safety)
from ahrefs.types import SiteExplorerDomainRatingRequest
request = SiteExplorerDomainRatingRequest(target="ahrefs.com", date="2025-01-15")
data = client.site_explorer_domain_rating(request)

Method names follow {api_section}_{endpoint}, e.g. site_explorer_organic_keywords, keywords_explorer_overview.

Show full SKILL.md (189 more words)Show less
Responses

Methods return typed Data objects directly.

Scalar endpoints return a single data object (or None):

python
data = client.site_explorer_domain_rating(target="ahrefs.com", date="2025-01-15")
print(data.domain_rating)

List endpoints return a list of data objects. There is no pagination — set limit to the number of results you need. Use select to request only the columns you need:

python
items = client.site_explorer_organic_keywords(
    target="ahrefs.com",
    date="2025-01-15",
    select="keyword,volume,best_position",
    order_by="volume:desc",
    limit=10,
)
for item in items:
    print(item.keyword, item.volume, item.best_position)
Error Handling
python
import ahrefs

try:
    data = client.site_explorer_domain_rating(target="example.com", date="2025-01-15")
except ahrefs.AuthenticationError:    # 401
    ...
except ahrefs.RateLimitError as e:    # 429 -- e.retry_after has the delay
    ...
except ahrefs.NotFoundError:          # 404
    ...
except ahrefs.APIError as e:          # other 4xx/5xx -- e.status_code, e.response_body
    ...
except ahrefs.APIConnectionError:     # network / timeout
    ...

All exceptions inherit from ahrefs.AhrefsError.

Common Parameters

Most list endpoints share these parameters:

ParameterTypeDescription
targetstrDomain, URL, or path to analyze
datestrDate in YYYY-MM-DD format
date_from / date_tostrDate range for history endpoints
countrystrTwo-letter country code (ISO 3166-1 alpha-2)
selectstrComma-separated columns to return
wherestrFilter expression
order_bystrColumn and direction, e.g. "volume:desc"
limitintMax results to return

Parameters typed as enums in the API reference (CountryEnum, VolumeModeEnum, etc.) accept plain strings — pass country="us" not CountryEnum("us").

The where parameter takes a JSON string. Use json.dumps() to build it:

python
import json
where = json.dumps({"field": "volume", "is": ["gte", 1000]})
items = client.site_explorer_organic_keywords(
    target="ahrefs.com", date="2025-01-15",
    select="keyword,volume", where=where,
)

For full filter syntax (boolean combinators, operators, nested fields), see references/filter-syntax.md.

API Methods

Use search_api_methods("query") or python3 -m ahrefs.api_search "query" to find methods by keyword. Search covers all 52 methods across 7 API sections and returns complete signatures, parameters, and response fields.

© OpenClaudia, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in skills/ahrefs-research of OpenClaudia/openclaudia-skills.

  • SKILL.md
  • references/api-methods.md
  • references/filter-syntax.md

Open the folder on GitHubat commit 28bf209

Compare with similar skills

Ahrefs Python next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Ahrefs Python compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ahrefs Python this skillOpenClaudia/openclaudia-skills708—~1.9kAutomated safety check: PassMIT
Global SEO Growthminhnv0807/ai-business-skills608—~5kAutomated safety check: PassMIT
Pp Ahrefsmvanhorn/printing-press-library2.1k—~2.4kAutomated safety check: NotesApache-2.0
FLOW SEO FrameworkAgriciDaniel/claude-seo18k2 repos~1.4kAutomated safety check: PassMIT
Beyondseobeyondtahir/beyondseo155—~4.3kAutomated safety check: PassMIT
Roblox Homepage Ranking Auditorkennyzir/7deer_skills322—~3.8kAutomated safety check: PassMIT

Similar skills

  • Global SEO Growth

    minhnv0807/ai-business-skills

    Covers six SEO layers for a website: crawl and index audit, local SEO, search-intent content, AI search visibility, schema markup and backlink or directory distribution.

    608 GitHub stars~5k tokensUpdated 25 days ago
    Marketing & SEOAuto-check passed
  • Pp Ahrefs

    mvanhorn/printing-press-library

    Printing Press CLI for Ahrefs. An agent skill from mvanhorn/printing-press-library.

    2.1k GitHub stars~2.4k tokensUpdated yesterday
    Marketing & SEOAuto-check: notes
  • FLOW SEO Framework

    AgriciDaniel/claude-seo

    Brings the FLOW framework's stage-specific SEO prompts into the agent, from keyword discovery through backlinks, on-page work and conversion to local SEO, loaded on demand.

    18k GitHub starsUsed in 2 repos~1.4k tokens
    Marketing & SEOAuto-check passed
  • Beyondseo

    beyondtahir/beyondseo

    Audit websites, apply authorised SEO improvements and plan content, competitors and backlinks with evidence, design checks and optional project monitoring.

    155 GitHub stars~4.3k tokensUpdated 12 days ago
    Marketing & SEOAuto-check passed
  • Roblox Homepage Ranking Auditor

    kennyzir/7deer_skills

    Audit a Roblox or game-site homepage against the RB Auto Golden Homepage model.

    322 GitHub stars~3.8k tokensUpdated 8 days ago
    Marketing & SEOAuto-check passed
  • Universal SEO Analysis

    AgriciDaniel/claude-seo

    Hub for site-wide SEO work: audits, technical checks, schema, content quality, local, hreflang and AI-search readiness, run through slash commands.

    18k GitHub stars~4.9k tokensUpdated 2 days ago
    Marketing & SEOAuto-check passed

More from OpenClaudia/openclaudia-skills

All 74 skills in this repo
  • Competitor Traffic Report

    OpenClaudia/openclaudia-skills

    Build an interactive competitive-traffic report for any company and its rivals — monthly visits (SimilarWeb), organic search traffic and Domain Rating (Ahrefs) — as one self-contained HTML page with…

    708 GitHub stars~1.2k tokensUpdated 19 days ago
    Auto-check passed
  • Geo Difficulty

    OpenClaudia/openclaudia-skills

    Score how hard a keyword is to rank for in the AI-search era — page-level URL Rating of real competitors (not just domain DR), Ahrefs keyword difficulty, and whether a given site already ranks or is…

    708 GitHub stars~694 tokensUpdated 19 days ago
    Auto-check passed
  • Gsc Portfolio Audit

    OpenClaudia/openclaudia-skills

    Audit EVERY Google Search Console property at once — rank all sites by clicks and impressions with period-over-period deltas, then diff keywords per site to surface what is newly ranking, rising…

    708 GitHub stars~1k tokensUpdated 19 days ago
    Auto-check passed
  • Similarweb Traffic

    OpenClaudia/openclaudia-skills

    Fetch website traffic estimates (monthly visits, traffic sources, top countries, keywords, engagement, ranks) for any domain from SimilarWeb.

    708 GitHub stars~882 tokensUpdated 19 days ago
    Auto-check passed
  • Ab Test Setup

    OpenClaudia/openclaudia-skills

    Design, plan, and analyze A/B tests with statistical rigor. An agent skill from OpenClaudia/openclaudia-skills.

    708 GitHub stars~1.7k tokensUpdated 19 days ago
    Auto-check passed
  • Affiliate Marketing

    OpenClaudia/openclaudia-skills

    Build and manage an affiliate marketing program. An agent skill from OpenClaudia/openclaudia-skills.

    708 GitHub stars~2.2k tokensUpdated 19 days ago
    Auto-check passed

Works with

Categories

Questions about Ahrefs Python

What does Ahrefs Python do?

Manages Ahrefs API usage in Python using ahrefs-python library. Ahrefs Python is an agent skill from OpenClaudia/openclaudia-skills. Manages Ahrefs API usage in Python using ahrefs-python library.

When should I use Ahrefs Python?

Ahrefs Python fits situations like: working with SEO / marketing related tasks; with data including backlinks; organic traffic; brand monitoring.

How do I install Ahrefs Python in Claude Code?

Run `npx skills add OpenClaudia/openclaudia-skills --skill ahrefs-python -a claude-code`. Or copy the skill folder (skills/ahrefs-research in OpenClaudia/openclaudia-skills) into .claude/skills/ahrefs-python in your project. Claude Code loads it when a task matches its description.

How do I install Ahrefs Python in Codex?

Run `npx skills add OpenClaudia/openclaudia-skills --skill ahrefs-python -a codex`. Or copy the skill folder (skills/ahrefs-research in OpenClaudia/openclaudia-skills) into .agents/skills/ahrefs-python in your project. Codex loads it when a task matches its description.

Can I use Ahrefs Python in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add OpenClaudia/openclaudia-skills --skill ahrefs-python -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ahrefs-python, .gemini/skills/ahrefs-python, .github/skills/ahrefs-python and .opencode/skills/ahrefs-python in your project.

What does Ahrefs Python need to run?

Going by SKILL.md and its folder, Ahrefs Python needs the command-line tools its instructions call (python3 and pip3) and credentials named AHREFS_API_KEY. Our summary lists: Python 3; A credential in AHREFS_API_KEY.

Does Ahrefs Python access the network?

SKILL.md names 2 domains. In commands or code: github.com and api.ahrefs.com; the agent is likely to contact these when it follows the instructions. This is read from the text; nothing was executed.

Is Ahrefs Python safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Ahrefs Python use?

Ahrefs Python is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Ahrefs Python use?

About 1.9k tokens (SKILL.md is roughly 7.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 75k tokens, read only when the agent opens those files.

What are the alternatives to Ahrefs Python?

Skills that share tags, products or a category with Ahrefs Python: Global SEO Growth (minhnv0807/ai-business-skills, 608 stars), Pp Ahrefs (mvanhorn/printing-press-library, 2.1k stars), FLOW SEO Framework (AgriciDaniel/claude-seo, 18k stars) and Beyondseo (beyondtahir/beyondseo, 155 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ahrefs Python?

OpenClaudia (a GitHub organization) maintains it in OpenClaudia/openclaudia-skills, which has 708 GitHub stars. The repository holds 74 skills in this directory. The repository was last updated on September 18, 2026.

Source: OpenClaudia/openclaudia-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.