Ahrefs Connection
by @jonathan-sokol
Connect to Ahrefs API to retrieve real-time SEO data including backlinks, keyword metrics, domain analysis, rank tracking, and site audits for SEO insights.
clawhub install ahrefs-connectionπ About This Skill
name: ahrefs-mcp description: > Access Ahrefs SEO data via the Ahrefs API for comprehensive SEO analysis, keyword research, backlink analysis, site audits, and competitive intelligence. Use when users mention: (1) SEO-related queries about websites, domains, or URLs, (2) Keyword research, rankings, or search volume data, (3) Backlink analysis or link profiles, (4) Domain metrics (DR, UR, traffic), (5) Competitor analysis or site comparison, (6) Rank tracking or SERP analysis, (7) Content gap analysis, (8) Site Explorer data requests. When uncertain if a query is SEO-related, ask if Ahrefs should be used.
Ahrefs API
Access real-time Ahrefs SEO data directly through the Ahrefs API to analyze websites, research keywords, track rankings, and make data-driven SEO decisions.
First-Time Setup
If this is your first time using the Ahrefs API, read references/setup.md for complete setup instructions. You'll need:
After setup, return here for usage guidance.
Core Capabilities
Ahrefs API provides access to:
1. Site Explorer - Domain metrics, backlinks, organic traffic, referring domains 2. Keywords Explorer - Search volume, keyword difficulty, SERP analysis, related keywords 3. Rank Tracker - Position tracking, visibility metrics, competitor rankings (requires pre-configured projects) 4. Site Audit - Technical SEO issues, crawl data, site health (requires pre-configured projects) 5. SERP Overview - Top 100 SERP results for any keyword 6. Batch Analysis - Process up to 100 targets per request 7. Brand Radar - Brand performance stats
For detailed capability reference, see references/capabilities.md.
Authentication
All API requests require an API key passed via the Authorization header:
Authorization: Bearer YOUR_API_KEY
Store your API key securely. Consider using environment variables:
export AHREFS_API_KEY="your-api-key-here"
Usage Workflow
1. Understand the Request
Identify what SEO data is needed:
2. Make API Requests
Use curl or similar tools to call the Ahrefs API. Base URL: https://api.ahrefs.com/v3
Example - Get domain overview:
curl -X GET "https://api.ahrefs.com/v3/site-explorer/domain-overview?target=example.com" \
-H "Authorization: Bearer $AHREFS_API_KEY"
Example - Keyword metrics:
curl -X GET "https://api.ahrefs.com/v3/keywords-explorer/overview?keyword=seo+tools&country=us" \
-H "Authorization: Bearer $AHREFS_API_KEY"
3. Process and Present Results
Common Workflows
Keyword Research + Cross-Reference
1. User provides keyword list 2. Make batch API calls to Keywords Explorer 3. Parse and consolidate metrics (volume, difficulty, CPC) 4. Present analysis with prioritization recommendations
See references/workflows.md for detailed workflow patterns with example API calls.
Competitive Analysis
1. Identify target domain and competitors 2. Call Site Explorer for each domain 3. Compare metrics (DR, organic traffic, referring domains) 4. Analyze top organic keywords 5. Identify content gaps 6. Provide actionable recommendations
Site Audit Review
Note: Requires pre-configured Site Audit project in Ahrefs web interface.
1. Call Site Audit API for project data 2. Identify critical issues by severity 3. Prioritize fixes by impact 4. Provide technical recommendations
API Limits & Best Practices
Rate Limiting
API Unit Consumption
Optimization Tips
limit parameterselect parameter to reduce costsPlan-Specific Access
Error Handling
Common HTTP status codes:
200 OK - Success400 Bad Request - Invalid parameters401 Unauthorized - Invalid or missing API key403 Forbidden - Insufficient permissions or plan limits429 Too Many Requests - Rate limit exceeded500 Internal Server Error - Ahrefs server issueAlways check response status and handle errors gracefully.
When API Key is Missing
If the API key is not configured: 1. Provide setup instructions from references/setup.md 2. Guide through API key generation in Ahrefs Account settings 3. Explain how to securely store the key (environment variables recommended) 4. Test the connection with a simple API call