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 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 --jsonkosmokrator integrations:doctor ahrefs --jsonkosmokrator integrations:status --json
Credentials
Authentication type: API keyapi_key. Configure credentials once, then use the same stored profile from
scripts, coding CLIs, Lua code mode, and the MCP gateway.
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
Call Ahrefs Headlessly
Use the generic call form when another coding CLI or script needs a stable universal interface.
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_backlinks
Read read
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.
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.
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.
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.
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.
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.
Get the authenticated Ahrefs user's profile information. Returns account details like name, email, and subscription plan. Use this to verify API connectivity.
Use these parameter tables when building CLI payloads without calling integrations:schema first.
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.
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.
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.
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.
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.
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.
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.
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.