KosmoKrator

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, configure, and verify
# 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.

KeyEnv varTypeRequiredLabel
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.

Generic CLI call
kosmo integrations:call ahrefs.ahrefs_list_backlinks '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json
Provider shortcut
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.

Discovery commands
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 read
Parameters
target, limit, offset, mode
Generic call
kosmo integrations:call ahrefs.ahrefs_list_backlinks '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json
Shortcut
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 read
Parameters
target, limit, offset, mode
Generic call
kosmo integrations:call ahrefs.ahrefs_list_referring_domains '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json
Shortcut
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 read
Parameters
target, limit, offset, mode
Generic call
kosmo integrations:call ahrefs.ahrefs_list_organic_keywords '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json
Shortcut
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 read
Parameters
target, limit, offset, mode
Generic call
kosmo integrations:call ahrefs.ahrefs_list_pages '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json
Shortcut
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 read
Parameters
params
Generic call
kosmo integrations:call ahrefs.ahrefs_get_metrics '{"params":"example_params"}' --json
Shortcut
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 read
Parameters
params
Generic call
kosmo integrations:call ahrefs.ahrefs_get_domain_rating '{"params":"example_params"}' --json
Shortcut
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 read
Parameters
params
Generic call
kosmo integrations:call ahrefs.ahrefs_get_backlinks_stats '{"params":"example_params"}' --json
Shortcut
kosmo integrations:ahrefs ahrefs_get_backlinks_stats '{"params":"example_params"}' --json

ahrefs.ahrefs_list_broken_backlinks

List broken backlinks pointing to a target.

Read read
Parameters
params
Generic call
kosmo integrations:call ahrefs.ahrefs_list_broken_backlinks '{"params":"example_params"}' --json
Shortcut
kosmo integrations:ahrefs ahrefs_list_broken_backlinks '{"params":"example_params"}' --json

ahrefs.ahrefs_list_organic_competitors

List organic search competitors for a target.

Read read
Parameters
params
Generic call
kosmo integrations:call ahrefs.ahrefs_list_organic_competitors '{"params":"example_params"}' --json
Shortcut
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 read
Parameters
params
Generic call
kosmo integrations:call ahrefs.ahrefs_list_paid_pages '{"params":"example_params"}' --json
Shortcut
kosmo integrations:ahrefs ahrefs_list_paid_pages '{"params":"example_params"}' --json

ahrefs.ahrefs_list_linked_domains

List domains linked from the target.

Read read
Parameters
params
Generic call
kosmo integrations:call ahrefs.ahrefs_list_linked_domains '{"params":"example_params"}' --json
Shortcut
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 read
Parameters
target, limit, offset
Generic call
kosmo integrations:call ahrefs.ahrefs_list_anchors '{"target":"example_target","limit":1,"offset":1}' --json
Shortcut
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 read
Parameters
none
Generic call
kosmo integrations:call ahrefs.ahrefs_get_limits_and_usage '{}' --json
Shortcut
kosmo integrations:ahrefs ahrefs_get_limits_and_usage '{}' --json

ahrefs.ahrefs_api_get

Call any Ahrefs API v3 GET endpoint.

Read read
Parameters
path, params
Generic call
kosmo integrations:call ahrefs.ahrefs_api_get '{"path":"example_path","params":"example_params"}' --json
Shortcut
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_referring_domains 4 parameters
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_referring_domains --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_organic_keywords --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_pages --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema ahrefs.ahrefs_get_metrics --json
ParameterTypeRequiredDescription
params object yes Query parameters such as target, date, mode, country, protocol, volume_mode, and select.
ahrefs.ahrefs_get_domain_rating 1 parameters
Schema command
kosmo integrations:schema ahrefs.ahrefs_get_domain_rating --json
ParameterTypeRequiredDescription
params object yes Query parameters such as target, date, protocol, and output.
ahrefs.ahrefs_list_organic_competitors 1 parameters
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_organic_competitors --json
ParameterTypeRequiredDescription
params object yes Query parameters such as target, mode, date, country, limit, offset, and select.
ahrefs.ahrefs_list_paid_pages 1 parameters
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_paid_pages --json
ParameterTypeRequiredDescription
params object yes Query parameters such as target, mode, date, country, limit, offset, and select.
ahrefs.ahrefs_list_linked_domains 1 parameters
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_linked_domains --json
ParameterTypeRequiredDescription
params object yes Query parameters such as target, mode, limit, offset, select, and where.
ahrefs.ahrefs_list_anchors 3 parameters
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_anchors --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema ahrefs.ahrefs_get_limits_and_usage --json
ParameterTypeRequiredDescription
No parameters.
ahrefs.ahrefs_api_get 2 parameters
Schema command
kosmo integrations:schema ahrefs.ahrefs_api_get --json
ParameterTypeRequiredDescription
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.