Ahrefs SEO Analysis
Query and analyze SEO data using the Ahrefs API for backlinks, keywords, rankings, and competitive intelligence.
Prerequisites
API Access
You need an Ahrefs subscription with API access:
- - Lite: Basic metrics, limited filtering
- Standard: More endpoints, some filtering
- Advanced: Advanced filtering, more data
- Enterprise: Full API access, advanced filtering, high rate limits
Setup
- 1. Get your API token from Ahrefs Account Settings
- 2. Configure in OpenClaw:
Add to
~/.openclaw/workspace/.env:
CODEBLOCK0
- 3. Verify setup:
CODEBLOCK1
Plan-Specific Features
All Plans
- - Domain Rating & Ahrefs Rank
- Basic backlinks stats (total counts)
- Organic keywords count
- Organic traffic estimates
- Top pages by traffic
Standard & Above
- - Organic keywords with positions (all positions)
- Keywords in positions 1-3 (via
org_keywords_1_3 metric) - Referring domains list (basic)
Advanced & Enterprise
- - Advanced filtering: Filter keywords by position (1-10 for first page)
- Geographic filtering: Filter backlinks by country/TLD (e.g.,
.au domains) - Detailed keyword data: Access to
best_position, sum_traffic, INLINECODE5 - Detailed backlink data: Full backlinks list with filtering
- Higher rate limits: Fetch larger datasets (5000+ records)
Core Capabilities
Site Explorer (Domain Analysis)
Get comprehensive SEO metrics for any domain:
- - Domain Rating (DR) & URL Rating (UR)
- Organic traffic estimates
- Referring domains & backlinks
- Organic keywords & rankings
- Top pages by traffic
- Historical data & trends
- [Advanced/Enterprise] Filter by country/TLD
- [Advanced/Enterprise] Position-based filtering (first page only)
Keywords Explorer (Keyword Research)
Discover and analyze keywords:
- - Search volume (global & country-specific)
- Keyword difficulty (KD) score
- Cost per click (CPC) estimates
- SERP analysis & features
- Related keywords & questions
- Keyword ideas & suggestions
- Parent topic analysis
- Traffic potential estimates
Rank Tracker (Position Monitoring)
Track keyword rankings over time:
- - Position tracking & visibility
- Competitor rankings comparison
- SERP feature tracking
- Historical position data
- Share of voice metrics
- Note: Requires pre-configured projects in Ahrefs
Site Audit (Technical SEO)
Identify technical SEO issues:
- - Crawl data & site health scores
- On-page issues by severity
- Internal link analysis
- Page performance metrics
- Mobile usability issues
- Note: Requires pre-configured projects in Ahrefs
SERP Overview (Search Results)
Analyze search engine results:
- - Top 100 organic results for any keyword
- SERP features present
- Domain metrics for ranking pages
- Keyword difficulty breakdown
- Click-through rate estimates
Batch Analysis (Bulk Processing)
Process multiple targets efficiently:
- - Analyze up to 100 domains/URLs per request
- Bulk keyword metrics
- Batch backlink data
- Cost-effective for large datasets
Brand Radar (Brand Monitoring)
Track brand performance:
- - Brand mention metrics
- Share of voice
- Competitor brand comparison
- Sentiment analysis preparation
Competitor Analysis
Compare domains and identify opportunities:
- - Side-by-side domain comparison
- Content gap analysis
- Keyword overlaps & differences
- Backlink gap analysis
- Traffic comparison
- [Advanced/Enterprise] Filtered comparisons (first page keywords, local backlinks)
API Structure
Ahrefs API base URL: INLINECODE6
Authentication
All requests require the API token in the header:
CODEBLOCK2
Important: Use AHREFS_API_TOKEN, NOT AHREFS_MCP_TOKEN.
Required Parameters
All API calls require:
- -
date: Current date in format INLINECODE10 - INLINECODE11 : Domain (e.g.,
example.com)
Common Endpoints
For detailed endpoint documentation and parameters, see references/api-endpoints.md.
API Unit Management
Understanding API Units
- - Each API request consumes units from your monthly allowance
- Cost depends on rows returned (minimum 50 units per request)
- Enterprise plans include units; additional units can be purchased
- Track usage at: https://app.ahrefs.com/account/limits-and-usage/web
Cost Optimization Tips
- 1. Limit rows returned: Use
limit parameter to reduce cost - Select specific columns: Use
select parameter for only needed fields - Batch requests: Process multiple targets in one call (up to 100)
- Cache results: Store frequently accessed data locally
- Use date ranges: Limit historical data when not needed
Rate Limits
- - 60 requests per minute (default)
- HTTP 429 returned if limit exceeded
- Implement exponential backoff for retries
Usage Examples
Site Explorer - Get Backlinks & Referring Domains
CODEBLOCK3
Returns:
CODEBLOCK4
Get Organic Keywords & Traffic
CODEBLOCK5
Returns:
CODEBLOCK6
Get Domain Rating
CODEBLOCK7
Returns:
CODEBLOCK8
Get Top Pages
CODEBLOCK9
Keywords Explorer - Keyword Research
CODEBLOCK10
Returns:
CODEBLOCK11
Keywords Explorer - Related Keywords
CODEBLOCK12
SERP Overview - Analyze Search Results
CODEBLOCK13
Returns top 100 organic results with domain metrics.
Rank Tracker - Get Project Rankings
Note: Requires pre-configured project in Ahrefs web interface.
CODEBLOCK14
Site Audit - Get Project Issues
Note: Requires pre-configured project in Ahrefs web interface.
CODEBLOCK15
Batch Analysis - Multiple Domains
CODEBLOCK16
Returns metrics for all domains in one request.
Common Workflows
Keyword Research Workflow
- 1. Get keyword overview (volume, difficulty, CPC)
- Fetch related keywords and questions
- Analyze SERP for top-ranking content
- Identify keyword difficulty and traffic potential
- Export prioritized keyword list
Competitive Analysis Workflow
- 1. Compare domain metrics (DR, traffic, keywords)
- Analyze competitor backlink profiles
- Identify content gaps
- Find keywords competitors rank for but you don't
- Discover backlink opportunities
Technical SEO Audit Workflow
Requires Site Audit project
- 1. Fetch site health overview
- Identify critical issues by severity
- Analyze internal linking structure
- Review page performance metrics
- Generate prioritized fix list
Content Strategy Workflow
- 1. Research target keywords (Keywords Explorer)
- Analyze top-ranking content (SERP Overview)
- Identify content gaps vs competitors
- Plan content based on traffic potential
- Track rankings over time (Rank Tracker)
Batch Domain Analysis Workflow
- 1. Compile list of target domains
- Make batch API request (up to 100 domains)
- Compare metrics across all domains
- Identify patterns and opportunities
- Export comparative analysis
Best Practices
- 1. Rate Limits: Respect API rate limits (60 req/min default)
- API Units: Monitor usage and optimize queries (limit rows, select columns)
- Caching: Cache responses for frequently accessed data
- Pagination: Use
limit and offset parameters for large datasets - Batch Requests: Use batch endpoints when analyzing multiple targets
- Error Handling: Check for 401 (auth), 429 (rate limit), 404 (not found)
- Project Requirements: Rank Tracker and Site Audit require pre-configured projects
Environment Variables
Load the token from the workspace .env file:
CODEBLOCK17
CODEBLOCK18
Response Format
API responses vary by endpoint but typically return JSON:
Stats endpoints (backlinks-stats, metrics, domain-rating):
CODEBLOCK19
List endpoints (top-pages, backlinks, etc.):
CODEBLOCK20
Troubleshooting
Authentication Errors
- - Verify token is correctly set in INLINECODE18
- Check token hasn't expired
- Ensure Bearer token format in header
Rate Limiting
- - Implement exponential backoff
- Cache responses where appropriate
- Use batch endpoints when available
Data Not Found
- - Verify domain/URL format
- Check if domain exists in Ahrefs index
- Try alternative target formats (with/without www)
Ahrefs SEO 分析
使用 Ahrefs API 查询和分析 SEO 数据,包括反向链接、关键词、排名和竞争情报。
前提条件
API 访问权限
您需要拥有具备 API 访问权限的 Ahrefs 订阅:
- - Lite(精简版):基础指标,有限过滤
- Standard(标准版):更多端点,部分过滤
- Advanced(高级版):高级过滤,更多数据
- Enterprise(企业版):完整 API 访问,高级过滤,高频率限制
设置步骤
- 1. 获取 API 令牌:前往 Ahrefs 账户设置
- 2. 在 OpenClaw 中配置:
添加到 ~/.openclaw/workspace/.env:
bash
AHREFS
APITOKEN=your
apitoken_here
AHREFS
APIPLAN=enterprise # 选项:lite, standard, advanced, enterprise
- 3. 验证设置:
bash
grep AHREFS ~/.openclaw/workspace/.env
套餐专属功能
所有套餐
- - 域名评级与 Ahrefs 排名
- 基础反向链接统计(总数量)
- 自然关键词数量
- 自然流量估算
- 按流量排序的顶级页面
标准版及以上
- - 自然关键词及其排名(所有排名)
- 排名 1-3 的关键词(通过 orgkeywords1_3 指标)
- 引用域名列表(基础)
高级版与企业版
- - 高级过滤:按排名位置过滤关键词(1-10 为首页)
- 地理过滤:按国家/顶级域名过滤反向链接(例如 .au 域名)
- 详细关键词数据:访问 bestposition、sumtraffic、volume
- 详细反向链接数据:完整反向链接列表及过滤功能
- 更高频率限制:获取更大数据集(5000+ 条记录)
核心功能
网站分析(域名分析)
获取任意域名的全面 SEO 指标:
- - 域名评级与 URL 评级
- 自然流量估算
- 引用域名与反向链接
- 自然关键词与排名
- 按流量排序的顶级页面
- 历史数据与趋势
- [高级版/企业版] 按国家/顶级域名过滤
- [高级版/企业版] 基于排名位置的过滤(仅首页)
关键词分析(关键词研究)
发现和分析关键词:
- - 搜索量(全球及特定国家)
- 关键词难度评分
- 每次点击费用估算
- 搜索结果页面分析与功能
- 相关关键词与问题
- 关键词创意与建议
- 父主题分析
- 流量潜力估算
排名追踪(排名监控)
追踪关键词排名随时间的变化:
- - 排名位置与可见度
- 竞争对手排名对比
- 搜索结果页面功能追踪
- 历史排名数据
- 声量份额指标
- 注意: 需要在 Ahrefs 中预先配置项目
网站审计(技术 SEO)
识别技术 SEO 问题:
- - 爬取数据与网站健康评分
- 按严重程度分类的页面问题
- 内部链接分析
- 页面性能指标
- 移动端可用性问题
- 注意: 需要在 Ahrefs 中预先配置项目
搜索结果页面概览(搜索结果)
分析搜索引擎结果:
- - 任意关键词的前 100 个自然搜索结果
- 存在的搜索结果页面功能
- 排名页面的域名指标
- 关键词难度分解
- 点击率估算
批量分析(批量处理)
高效处理多个目标:
- - 每次请求最多分析 100 个域名/URL
- 批量关键词指标
- 批量反向链接数据
- 处理大数据集时成本效益高
品牌雷达(品牌监控)
追踪品牌表现:
- - 品牌提及指标
- 声量份额
- 竞争对手品牌对比
- 情感分析准备
竞争对手分析
对比域名并识别机会:
- - 并排域名对比
- 内容差距分析
- 关键词重叠与差异
- 反向链接差距分析
- 流量对比
- [高级版/企业版] 过滤对比(首页关键词、本地反向链接)
API 结构
Ahrefs API 基础 URL:https://api.ahrefs.com/v3/site-explorer/
身份验证
所有请求需要在请求头中包含 API 令牌:
Authorization: Bearer {AHREFSAPITOKEN}
重要提示: 使用 AHREFSAPITOKEN,而非 AHREFSMCPTOKEN。
必需参数
所有 API 调用需要:
- - date:当前日期,格式为 YYYY-MM-DD
- target:域名(例如 example.com)
常用端点
有关详细的端点文档和参数,请参阅 references/api-endpoints.md。
API 单位管理
理解 API 单位
- - 每个 API 请求会消耗您月度配额中的单位
- 成本取决于返回的行数(每次请求至少 50 个单位)
- 企业版套餐包含单位;可额外购买单位
- 使用情况追踪:https://app.ahrefs.com/account/limits-and-usage/web
成本优化技巧
- 1. 限制返回行数:使用 limit 参数减少成本
- 选择特定列:使用 select 参数仅获取所需字段
- 批量请求:一次调用处理多个目标(最多 100 个)
- 缓存结果:本地存储频繁访问的数据
- 使用日期范围:不需要时限制历史数据
频率限制
- - 默认每分钟 60 次请求
- 超出限制时返回 HTTP 429 状态码
- 重试时实施指数退避策略
使用示例
网站分析 - 获取反向链接与引用域名
bash
DATE=$(date +%Y-%m-%d)
curl -X GET https://api.ahrefs.com/v3/site-explorer/backlinks-stats?date=$DATE&target=example.com \
-H Authorization: Bearer $AHREFS
APITOKEN
返回结果:
json
{
metrics: {
live: 4545,
all_time: 25318,
live_refdomains: 718,
alltimerefdomains: 3272
}
}
获取自然关键词与流量
bash
DATE=$(date +%Y-%m-%d)
curl -X GET https://api.ahrefs.com/v3/site-explorer/metrics?date=$DATE&target=example.com \
-H Authorization: Bearer $AHREFS
APITOKEN
返回结果:
json
{
metrics: {
org_keywords: 6925,
org_traffic: 38702,
orgkeywords1_3: 1560,
org_cost: 2372016
}
}
获取域名评级
bash
DATE=$(date +%Y-%m-%d)
curl -X GET https://api.ahrefs.com/v3/site-explorer/domain-rating?date=$DATE&target=example.com \
-H Authorization: Bearer $AHREFS
APITOKEN
返回结果:
json
{
domain_rating: {
domain_rating: 43.0,
ahrefs_rank: 1189155
}
}
获取顶级页面
bash
DATE=$(date +%Y-%m-%d)
curl -X GET https://api.ahrefs.com/v3/site-explorer/top-pages?date=$DATE&target=example.com&limit=10&select=url,sum_traffic \
-H Authorization: Bearer $AHREFS
APITOKEN
关键词分析 - 关键词研究
bash
curl -X GET https://api.ahrefs.com/v3/keywords-explorer/overview?keyword=seo+tools&country=us \
-H Authorization: Bearer $AHREFS
APITOKEN
返回结果:
json
{
keyword: seo tools,
volume: 14000,
keyword_difficulty: 75,
cpc: 25.50,
serpfeatures: [featuredsnippet, peoplealsoask],
traffic_potential: 18500
}
关键词分析 - 相关关键词
bash
curl -X GET https://api.ahrefs.com/v3/keywords-explorer/related-keywords?keyword=seo+tools&country=us&limit=50 \
-H Authorization: Bearer $AHREFS
APITOKEN
搜索结果页面概览 - 分析搜索结果