Documentation
Ahrefs CLI
ahrefs-pp-cli
Install
npx -y @mvanhorn/printing-press-library install ahrefsInstalls the CLI binary and the agent skill for Claude Code, Codex, Cursor, Gemini CLI, Copilot, and more. Add --cli-only or --skill-only for one half. Requires Node.
Documentation
SEO and competitive intelligence API for backlinks, keywords, rank tracking, site audit, and SERP data.
Learn more at Ahrefs.
Created by @cathrynlavery (Cathryn Lavery).
Quick Start
1. Install
See Install above.
2. Set Up Credentials
Get your API key from your API provider's developer portal. The key typically looks like a long alphanumeric string.
export AHREFS_API_KEY="<paste-your-key>"
You can also persist this in your config file at ~/.config/ahrefs-pp-cli/config.toml.
3. Verify Setup
ahrefs-pp-cli doctor
This checks your configuration and credentials.
4. Try Your First Command
ahrefs-pp-cli keywords-explorer matching-terms
Usage
Run ahrefs-pp-cli --help for the full command reference and flag list.
Commands
keywords-explorer
Keywords Explorer endpoints.
ahrefs-pp-cli keywords-explorer matching-terms- Matching termsahrefs-pp-cli keywords-explorer overview- Overviewahrefs-pp-cli keywords-explorer related-terms- Related termsahrefs-pp-cli keywords-explorer search-suggestions- Search suggestionsahrefs-pp-cli keywords-explorer volume-by-country- Volume by countryahrefs-pp-cli keywords-explorer volume-history- Time-series. Volume history
public
Public endpoints.
ahrefs-pp-cli public crawler-ip-ranges- Crawler IP rangesahrefs-pp-cli public crawler-ips- Crawler IP addresses
rank-tracker
Rank Tracker endpoints.
ahrefs-pp-cli rank-tracker competitors-overview- Competitors overviewahrefs-pp-cli rank-tracker overview- Overviewahrefs-pp-cli rank-tracker serp-overview- SERP Overview
serp-overview
Serp Overview endpoints.
ahrefs-pp-cli serp-overview- SERP Overview
site-audit
Site Audit endpoints.
ahrefs-pp-cli site-audit issues- Project Issuesahrefs-pp-cli site-audit page-content- Page contentahrefs-pp-cli site-audit page-explorer- Page explorerahrefs-pp-cli site-audit projects- Project Health Scores
site-explorer
Site Explorer endpoints.
ahrefs-pp-cli site-explorer all-backlinks- Backlinksahrefs-pp-cli site-explorer backlinks-stats- Backlinks statsahrefs-pp-cli site-explorer broken-backlinks- Broken Backlinksahrefs-pp-cli site-explorer domain-rating- Point-in-time snapshot. Domain ratingahrefs-pp-cli site-explorer domain-rating-history- Time-series. Domain Rating historyahrefs-pp-cli site-explorer metrics- Point-in-time snapshot. Metricsahrefs-pp-cli site-explorer metrics-by-country- Metrics by countryahrefs-pp-cli site-explorer organic-competitors- Organic competitorsahrefs-pp-cli site-explorer organic-keywords- Organic keywordsahrefs-pp-cli site-explorer pages-by-traffic- Pages by trafficahrefs-pp-cli site-explorer refdomains-history- Time-series. Refdomains historyahrefs-pp-cli site-explorer top-pages- Top pages
subscription-info
Subscription Info endpoints.
ahrefs-pp-cli subscription-info- Limits and usage
Output Formats
# Human-readable table (default in terminal, JSON when piped)
ahrefs-pp-cli keywords-explorer matching-terms
# JSON for scripting and agents
ahrefs-pp-cli keywords-explorer matching-terms --json
# Filter to specific fields
ahrefs-pp-cli keywords-explorer matching-terms --json --select id,name,status
# Dry run — show the request without sending
ahrefs-pp-cli keywords-explorer matching-terms --dry-run
# Agent mode — JSON + compact + no prompts in one flag
ahrefs-pp-cli keywords-explorer matching-terms --agent
Agent Usage
This CLI is designed for AI agent consumption:
- Non-interactive - never prompts, every input is a flag
- Pipeable -
--jsonoutput to stdout, errors to stderr - Filterable -
--select id,namereturns only fields you need - Previewable -
--dry-runshows the request without sending - Read-only by default - this CLI does not create, update, delete, publish, send, or mutate remote resources
- Offline-friendly - sync/search commands can use the local SQLite store when available
- Agent-safe by default - no colors or formatting unless
--human-friendlyis set
Exit codes: 0 success, 2 usage error, 3 not found, 4 auth error, 5 API error, 7 rate limited, 10 config error.
Health Check
ahrefs-pp-cli doctor
Verifies configuration, credentials, and connectivity to the API.
Configuration
Config file: ~/.config/ahrefs-pp-cli/config.toml
Environment variables:
AHREFS_API_KEY
Troubleshooting
Authentication errors (exit code 4)
- Run
ahrefs-pp-cli doctorto check credentials - Verify the environment variable is set:
echo $AHREFS_API_KEYNot found errors (exit code 3) - Check the resource ID is correct
- Run the
listcommand to see available items
Generated by CLI Printing Press
For agents: pass /documentation/ahrefs/agents.md to install this CLI from a prompt.