Skip to main content

Scenario

Pull the top-performing pages from your domain by organic traffic, analyze what makes them successful (structure, keyword targeting, topic coverage), then generate content briefs that replicate those patterns for underperforming or uncovered topics. The Ahrefs top-pages endpoint returns pages sorted by estimated organic traffic alongside the keywords driving that traffic and their positions.

Architecture

Code

Example Output

Error Handling

Your Ahrefs API token is invalid, expired, or revoked. Regenerate at Ahrefs → API Keys. Bearer tokens are long-lived but can be rotated.
You’ve exceeded the 60 requests/minute rate limit. Back off for 60 seconds. In production, implement a token-bucket rate limiter shared across all Ahrefs calls.