Token导航 LogoToken导航

Agent Skill · 研究检索

ahrefs-python(ahrefs Python 搜索)

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

ahrefs-python 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 36,504。

总安装 1,909周安装 82GitHub Stars 6下载 669核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:ahrefs-python(ahrefs Python 搜索)
来源仓库:https://github.com/ahrefs/ahrefs-api-skills
仓库路径:skills/ahrefs-python
安装命令:
npx skills add https://github.com/ahrefs/ahrefs-api-skills --skill ahrefs-python
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ahrefs/ahrefs-api-skills --skill ahrefs-python

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

ahrefs-python 集成 Ahrefs SEO API 的 Python SDK,提供类型化接口。支持站点分析、关键词研究、排名跟踪与品牌雷达等功能。适用于自动化 SEO 数据整理与竞品监控场景。需配置 API 密钥并按配额使用,注意数据访问限制。通过 ahrefs 客户端对象调用各模块方法获取结构化数据。

来源仓库内路径:skills/ahrefs-python

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/ahrefs/ahrefs-api-skills --skill ahrefs-python;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

ahrefs-python 怎么安装?

在终端执行 npx skills add https://github.com/ahrefs/ahrefs-api-skills --skill ahrefs-python。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

ahrefs-python 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

ahrefs-python 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

ahrefs-python 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

ahrefs-python 用的人多吗?

公开数据是累计安装 1,909 次,近一周安装 82 次,下载 669 次,GitHub 6 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

ahrefs-python 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
ahrefs-python

ahrefs Python 搜索 · 本页

1,9096接触敏感数据未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

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
  • Management — Rank Tracker project, keyword list, competitor, and Brand Radar prompt management (create, update, delete)
  • 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
  • Web Analytics - Website visitor analytics (traffic, browsers, devices, sources, pages)
  • Public — Ahrefs crawler IP addresses and CIDR ranges (no API key required)
  • Subscription Info — API usage limits, billing period, key expiration

Installation

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

Requires Python 3.11+. Dependencies: httpx, pydantic.

API Method Discovery

The SDK has 105 methods across 11 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):

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):

# 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.
  • PREFER AsyncAhrefsClient with asyncio.gather() when making multiple independent API calls — parallelism saves wall-clock time and API round-trips.
  • 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

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

Public endpoints work without an API key — just omit the api_key parameter:

from ahrefs import AhrefsClient

with AhrefsClient() as client:
    ips = client.public_crawler_ips()
    ranges = client.public_crawler_ip_ranges()

Only public_* methods work without a key. All other methods require authentication. An authenticated client can also call public methods — there is no need for a separate client or raw HTTP calls.

SDK Patterns

Client Setup

import os
import ahrefs

with ahrefs.AhrefsClient(
    api_key=os.environ["AHREFS_API_KEY"],  # omit for public-only access
    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:

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:

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:

# 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.

Responses

Methods return typed Data objects directly.

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

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:

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

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.

When errors occur and the API key is valid, call subscription_info_limits_and_usage() to diagnose — it returns the subscription plan, key expiration date, and usage vs limits. For 403 errors specifically, also read e.response_body for the exact reason (units limit, export rows limit, domains-per-week limit, etc.).

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:

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.

Recommended Defaults

Unless the user requests otherwise:

  • Backlink endpoints (all_backlinks, anchors, pages_by_backlinks, refdomains): Use history="live" for current live data. The API defaults to all_time which includes lost backlinks.
  • Traffic/keyword endpoints (organic_keywords, top_pages, metrics, etc.): Use today's date for the date parameter.

API Methods

Use search_api_methods("query") or python3 -m ahrefs.api_search "query" to find methods by keyword. Search covers all 105 methods across 11 API sections and returns complete signatures, parameters, and response fields. Results with very large field lists (e.g. site_audit_page_explorer with 608 fields) are truncated at 9K chars — if you see ... [truncated], use select to request only the columns you need rather than relying on the full field list.

Web Analytics

Web Analytics has 34 endpoints across many dimensions — not all method names match the dimension name directly (e.g. pages data uses web_analytics_top_pages, not web_analytics_pages). Always use search_api_methods("web analytics <topic>") to find the correct method.

These endpoints require a project_id (not a target domain). Use from_ and to for datetime ranges — from is a Python reserved word, so the SDK uses from_ with automatic serialization to the correct API name.

# Overall traffic stats (scalar endpoint)
stats = client.web_analytics_stats(project_id=123)
print(stats.pageviews, stats.visitors, stats.visits)

# Dimension breakdown (list endpoint — use select)
browsers = client.web_analytics_browsers(
    project_id=123,
    from_="2025-01-01T00:00:00Z",
    to="2025-01-31T23:59:59Z",
    select="browser,visitors",
    limit=10,
)

# Time-series chart (list endpoint — requires granularity)
chart = client.web_analytics_chart(
    project_id=123,
    granularity="daily",
    from_="2025-01-01T00:00:00Z",
    to="2025-01-31T23:59:59Z",
)

Management

Management endpoints handle Rank Tracker project configuration and Brand Radar prompt management — creating projects, managing keyword lists, adding competitors, and managing custom Brand Radar prompts. Unlike other API sections, this section includes endpoints that modify state via PUT/POST/PATCH/DELETE. None of these endpoints use select, where, order_by, or limit.

  • Use management_projects() to list all projects and find project_id values.
  • Use management_locations() to get valid country codes, language codes, and location IDs before adding keywords.
  • keyword_list_id is NOT discoverable via the API — the user must provide it from the Ahrefs web UI. Keyword list methods: management_keyword_list_keywords (list), management_set_keyword_list_keywords (add via PUT), management_keyword_list_keywords_delete (remove).
  • Brand Radar prompt endpoints require a report_id (from the Brand Radar report URL). Methods: management_brand_radar_prompts (list), management_create_brand_radar_prompts (create), management_brand_radar_prompts_delete (remove).
  • Delete endpoints are destructive and irreversible. ALWAYS confirm with the user before calling management_project_keywords_delete, management_project_competitors_delete, management_keyword_list_keywords_delete, or management_brand_radar_prompts_delete.
# List all Rank Tracker projects
projects = client.management_projects()
for p in projects:
    print(p.project_id, p.project_name, p.url)

# Add keywords to a project (requires nested request types)
from ahrefs.types import ManagementSetProjectKeywordsLocation, ManagementSetProjectKeywordsKeyword

client.management_set_project_keywords(
    project_id=12345,
    locations=[ManagementSetProjectKeywordsLocation(
        country="us",
        language="en",
    )],
    keywords=[ManagementSetProjectKeywordsKeyword(keyword="ahrefs seo")],
)

# Add competitors to a project
from ahrefs.types import ManagementCreateProjectCompetitorsCompetitor

client.management_create_project_competitors(
    project_id=12345,
    competitors=[ManagementCreateProjectCompetitorsCompetitor(
        url="moz.com",
        mode="domain",
    )],
)

# List Brand Radar custom prompts
prompts = client.management_brand_radar_prompts(report_id="abc123")
for p in prompts:
    print(p.prompt, p.country, p.created_at)

# Create custom prompts for specific countries
client.management_create_brand_radar_prompts(
    report_id="abc123",
    countries=["us", "gb"],
    prompts=["What is the best SEO tool?"],
)

平台分布

Codex

34.05%
按下载量换算228

Claude

32.16%
按下载量换算215

Cursor

18.23%
按下载量换算122

Gemini CLI

9.27%
按下载量换算62

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills