data
Ahrefs CLI for AI Agents
Use the Ahrefs CLI from KosmoKrator to call Ahrefs tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Ahrefs CLI Setup
Ahrefs can be configured headlessly with `kosmokrator integrations:configure ahrefs`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure ahrefs --set api_key="$AHREFS_API_KEY" --enable --read allow --write ask --json
kosmokrator integrations:doctor ahrefs --json
kosmokrator integrations:status --json Credentials
Authentication type: API key api_key. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
api_key | AHREFS_API_KEY | Secret secret | yes | API Key |
url | AHREFS_URL | URL url | no | Ahrefs API URL |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call ahrefs.ahrefs_list_backlinks '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json kosmo integrations:ahrefs ahrefs_list_backlinks '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs ahrefs --json
kosmo integrations:docs ahrefs.ahrefs_list_backlinks --json
kosmo integrations:schema ahrefs.ahrefs_list_backlinks --json
kosmo integrations:search "Ahrefs" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
ahrefs.ahrefs_list_backlinks
List backlinks pointing to a target website or URL. Use this to analyze a site's link profile, find linking pages, anchor texts, and backlink quality metrics.
read - Parameters
- target, limit, offset, mode
kosmo integrations:call ahrefs.ahrefs_list_backlinks '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json kosmo integrations:ahrefs ahrefs_list_backlinks '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json ahrefs.ahrefs_list_referring_domains
List referring domains that link to a target website. Shows domain-level metrics like domain rating (DR), the number of backlinks from each domain, and first/last seen dates.
read - Parameters
- target, limit, offset, mode
kosmo integrations:call ahrefs.ahrefs_list_referring_domains '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json kosmo integrations:ahrefs ahrefs_list_referring_domains '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json ahrefs.ahrefs_list_organic_keywords
List organic keywords that a target website or URL ranks for in search results. Returns keyword, position, search volume, traffic, keyword difficulty, and the ranking URL.
read - Parameters
- target, limit, offset, mode
kosmo integrations:call ahrefs.ahrefs_list_organic_keywords '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json kosmo integrations:ahrefs ahrefs_list_organic_keywords '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json ahrefs.ahrefs_list_pages
List top pages for a target website ranked by traffic or other metrics. Returns page URLs along with traffic data, keyword counts, and backlink information.
read - Parameters
- target, limit, offset, mode
kosmo integrations:call ahrefs.ahrefs_list_pages '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json kosmo integrations:ahrefs ahrefs_list_pages '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json ahrefs.ahrefs_get_metrics
Get Site Explorer overview metrics for a target using Ahrefs API v3.
read - Parameters
- params
kosmo integrations:call ahrefs.ahrefs_get_metrics '{"params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_get_metrics '{"params":"example_params"}' --json ahrefs.ahrefs_get_domain_rating
Get Domain Rating and Ahrefs Rank for a target and date.
read - Parameters
- params
kosmo integrations:call ahrefs.ahrefs_get_domain_rating '{"params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_get_domain_rating '{"params":"example_params"}' --json ahrefs.ahrefs_get_backlinks_stats
Get backlink statistics for a target using Ahrefs Site Explorer.
read - Parameters
- params
kosmo integrations:call ahrefs.ahrefs_get_backlinks_stats '{"params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_get_backlinks_stats '{"params":"example_params"}' --json ahrefs.ahrefs_list_broken_backlinks
List broken backlinks pointing to a target.
read - Parameters
- params
kosmo integrations:call ahrefs.ahrefs_list_broken_backlinks '{"params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_list_broken_backlinks '{"params":"example_params"}' --json ahrefs.ahrefs_list_organic_competitors
List organic search competitors for a target.
read - Parameters
- params
kosmo integrations:call ahrefs.ahrefs_list_organic_competitors '{"params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_list_organic_competitors '{"params":"example_params"}' --json ahrefs.ahrefs_list_paid_pages
List pages from a target ranking in paid search results.
read - Parameters
- params
kosmo integrations:call ahrefs.ahrefs_list_paid_pages '{"params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_list_paid_pages '{"params":"example_params"}' --json ahrefs.ahrefs_list_linked_domains
List domains linked from the target.
read - Parameters
- params
kosmo integrations:call ahrefs.ahrefs_list_linked_domains '{"params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_list_linked_domains '{"params":"example_params"}' --json ahrefs.ahrefs_list_anchors
List anchor texts used in backlinks pointing to a target website. Shows anchor text distribution, the number of referring pages using each anchor, and backlink counts.
read - Parameters
- target, limit, offset
kosmo integrations:call ahrefs.ahrefs_list_anchors '{"target":"example_target","limit":1,"offset":1}' --json kosmo integrations:ahrefs ahrefs_list_anchors '{"target":"example_target","limit":1,"offset":1}' --json ahrefs.ahrefs_get_limits_and_usage
Get Ahrefs API subscription limits and usage for the authenticated API key.
read - Parameters
- none
kosmo integrations:call ahrefs.ahrefs_get_limits_and_usage '{}' --json kosmo integrations:ahrefs ahrefs_get_limits_and_usage '{}' --json ahrefs.ahrefs_api_get
Call any Ahrefs API v3 GET endpoint.
read - Parameters
- path, params
kosmo integrations:call ahrefs.ahrefs_api_get '{"path":"example_path","params":"example_params"}' --json kosmo integrations:ahrefs ahrefs_api_get '{"path":"example_path","params":"example_params"}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
ahrefs.ahrefs_list_backlinks 4 parameters
kosmo integrations:schema ahrefs.ahrefs_list_backlinks --json | Parameter | Type | Required | Description |
|---|---|---|---|
target | string | yes | The target URL or domain to analyze (e.g., "example.com" or "https://example.com/page"). |
limit | integer | no | Maximum number of backlinks to return (default: 100). |
offset | integer | no | Number of results to skip for pagination (default: 0). |
mode | string | no | Target matching mode: "domain", "subdomains", "exact", or "prefix". Default: "subdomains". |
ahrefs.ahrefs_list_referring_domains 4 parameters
kosmo integrations:schema ahrefs.ahrefs_list_referring_domains --json | Parameter | Type | Required | Description |
|---|---|---|---|
target | string | yes | The target URL or domain to analyze (e.g., "example.com"). |
limit | integer | no | Maximum number of referring domains to return (default: 100). |
offset | integer | no | Number of results to skip for pagination (default: 0). |
mode | string | no | Target matching mode: "domain", "subdomains", "exact", or "prefix". Default: "subdomains". |
ahrefs.ahrefs_list_organic_keywords 4 parameters
kosmo integrations:schema ahrefs.ahrefs_list_organic_keywords --json | Parameter | Type | Required | Description |
|---|---|---|---|
target | string | yes | The target URL or domain to analyze (e.g., "example.com"). |
limit | integer | no | Maximum number of keywords to return (default: 100). |
offset | integer | no | Number of results to skip for pagination (default: 0). |
mode | string | no | Target matching mode: "domain", "subdomains", "exact", or "prefix". Default: "subdomains". |
ahrefs.ahrefs_list_pages 4 parameters
kosmo integrations:schema ahrefs.ahrefs_list_pages --json | Parameter | Type | Required | Description |
|---|---|---|---|
target | string | yes | The target URL or domain to analyze (e.g., "example.com"). |
limit | integer | no | Maximum number of pages to return (default: 100). |
offset | integer | no | Number of results to skip for pagination (default: 0). |
mode | string | no | Target matching mode: "domain", "subdomains", "exact", or "prefix". Default: "subdomains". |
ahrefs.ahrefs_get_metrics 1 parameters
kosmo integrations:schema ahrefs.ahrefs_get_metrics --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | Query parameters such as target, date, mode, country, protocol, volume_mode, and select. |
ahrefs.ahrefs_get_domain_rating 1 parameters
kosmo integrations:schema ahrefs.ahrefs_get_domain_rating --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | Query parameters such as target, date, protocol, and output. |
ahrefs.ahrefs_get_backlinks_stats 1 parameters
kosmo integrations:schema ahrefs.ahrefs_get_backlinks_stats --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | Query parameters such as target, date, mode, protocol, and output. |
ahrefs.ahrefs_list_broken_backlinks 1 parameters
kosmo integrations:schema ahrefs.ahrefs_list_broken_backlinks --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | Query parameters such as target, mode, limit, offset, select, and where. |
ahrefs.ahrefs_list_organic_competitors 1 parameters
kosmo integrations:schema ahrefs.ahrefs_list_organic_competitors --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | Query parameters such as target, mode, date, country, limit, offset, and select. |
ahrefs.ahrefs_list_paid_pages 1 parameters
kosmo integrations:schema ahrefs.ahrefs_list_paid_pages --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | Query parameters such as target, mode, date, country, limit, offset, and select. |
ahrefs.ahrefs_list_linked_domains 1 parameters
kosmo integrations:schema ahrefs.ahrefs_list_linked_domains --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | Query parameters such as target, mode, limit, offset, select, and where. |
ahrefs.ahrefs_list_anchors 3 parameters
kosmo integrations:schema ahrefs.ahrefs_list_anchors --json | Parameter | Type | Required | Description |
|---|---|---|---|
target | string | yes | The target URL or domain to analyze (e.g., "example.com"). |
limit | integer | no | Maximum number of anchors to return (default: 100). |
offset | integer | no | Number of results to skip for pagination (default: 0). |
ahrefs.ahrefs_get_limits_and_usage 0 parameters
kosmo integrations:schema ahrefs.ahrefs_get_limits_and_usage --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
ahrefs.ahrefs_api_get 2 parameters
kosmo integrations:schema ahrefs.ahrefs_api_get --json | Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | API path such as /v3/site-explorer/metrics. |
params | object | no | Query parameters. |
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.