KosmoKrator

seo

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.

7 functions 7 read 0 write API key auth

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 use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_key AHREFS_API_KEY Secret secret yes API Key
url AHREFS_URL URL url no Ahrefs API URL

Call Ahrefs Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call ahrefs.ahrefs_list_backlinks '{
  "target": "example_target",
  "limit": 1,
  "offset": 1,
  "mode": "example_mode"
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:ahrefs ahrefs_list_backlinks '{
  "target": "example_target",
  "limit": 1,
  "offset": 1,
  "mode": "example_mode"
}' --json

Agent Discovery Commands

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

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Ahrefs.

ahrefs.ahrefs_list_referring_domains

Read read

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.

Parameters
target, limit, offset, mode

Generic CLI call

kosmo integrations:call ahrefs.ahrefs_list_referring_domains '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json

Provider shortcut

kosmo integrations:ahrefs ahrefs_list_referring_domains '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json

ahrefs.ahrefs_list_organic_keywords

Read read

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.

Parameters
target, limit, offset, mode

Generic CLI call

kosmo integrations:call ahrefs.ahrefs_list_organic_keywords '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json

Provider shortcut

kosmo integrations:ahrefs ahrefs_list_organic_keywords '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json

ahrefs.ahrefs_list_pages

Read read

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.

Parameters
target, limit, offset, mode

Generic CLI call

kosmo integrations:call ahrefs.ahrefs_list_pages '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json

Provider shortcut

kosmo integrations:ahrefs ahrefs_list_pages '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json

ahrefs.ahrefs_list_paid_keywords

Read read

List paid (PPC) keywords that a target website bids on in search advertising. Returns keyword, position, search volume, CPC, traffic, and the landing page URL.

Parameters
target, limit, offset

Generic CLI call

kosmo integrations:call ahrefs.ahrefs_list_paid_keywords '{"target":"example_target","limit":1,"offset":1}' --json

Provider shortcut

kosmo integrations:ahrefs ahrefs_list_paid_keywords '{"target":"example_target","limit":1,"offset":1}' --json

ahrefs.ahrefs_list_anchors

Read read

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.

Parameters
target, limit, offset

Generic CLI call

kosmo integrations:call ahrefs.ahrefs_list_anchors '{"target":"example_target","limit":1,"offset":1}' --json

Provider shortcut

kosmo integrations:ahrefs ahrefs_list_anchors '{"target":"example_target","limit":1,"offset":1}' --json

ahrefs.ahrefs_get_current_user

Read read

Get the authenticated Ahrefs user's profile information. Returns account details like name, email, and subscription plan. Use this to verify API connectivity.

Parameters
none

Generic CLI call

kosmo integrations:call ahrefs.ahrefs_get_current_user '{}' --json

Provider shortcut

kosmo integrations:ahrefs ahrefs_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

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.

Operation
Read read
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", "subdomain", "exact", "prefix". Default: "domain".

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.

Operation
Read read
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", "subdomain", "exact", "prefix". Default: "domain".

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.

Operation
Read read
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", "subdomain", "exact", "prefix". Default: "domain".

ahrefs.ahrefs_list_paid_keywords

List paid (PPC) keywords that a target website bids on in search advertising. Returns keyword, position, search volume, CPC, traffic, and the landing page URL.

Operation
Read read
Schema command
kosmo integrations:schema ahrefs.ahrefs_list_paid_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).

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.

Operation
Read read
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_current_user

Get the authenticated Ahrefs user's profile information. Returns account details like name, email, and subscription plan. Use this to verify API connectivity.

Operation
Read read
Schema command
kosmo integrations:schema ahrefs.ahrefs_get_current_user --json
ParameterTypeRequiredDescription
No 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.