seo
Ahrefs CLI for Headless Automation
Use the Ahrefs CLI for headless automation with headless JSON commands, schema discovery, credentials, and permission controls.
7 functions 7 read 0 write API key auth
Ahrefs CLI for Headless Automation
Use KosmoKrator as a non-interactive integration runtime for local automations and wrappers.
Use headless automation when another tool needs a stable local command surface. The Ahrefs CLI uses the same integration registry as the TUI, Lua runtime, and MCP gateway, but returns predictable command output for automation.
Command Shape
# Ahrefs CLI for Headless Automation
kosmokrator integrations:configure ahrefs --set api_key="$AHREFS_API_KEY" --enable --read allow --write ask --json
kosmo integrations:call ahrefs.ahrefs_list_backlinks '{"target":"example_target","limit":1,"offset":1,"mode":"example_mode"}' --json Discovery Before Execution
Agents and scripts can inspect Ahrefs docs and schemas 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 Useful Ahrefs CLI Functions
| Function | Type | Parameters | Description |
|---|---|---|---|
ahrefs.ahrefs_list_backlinks | Read | target, limit, offset, mode | 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. |
ahrefs.ahrefs_list_referring_domains | Read | target, limit, offset, mode | 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. |
ahrefs.ahrefs_list_organic_keywords | Read | target, limit, offset, mode | 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. |
ahrefs.ahrefs_list_pages | Read | target, limit, offset, mode | 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. |
ahrefs.ahrefs_list_paid_keywords | Read | target, limit, offset | 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. |
ahrefs.ahrefs_list_anchors | Read | target, limit, offset | 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. |
ahrefs.ahrefs_get_current_user | Read | none | Get the authenticated Ahrefs user's profile information. Returns account details like name, email, and subscription plan. Use this to verify API connectivity. |
Automation Notes
- Use
--jsonfor machine-readable output. - Keep credentials out of argv by using environment variables or stored KosmoKrator configuration.
- Configure read/write policy before unattended runs; use
--forceonly for trusted automation. - Use the MCP gateway instead when the agent needs dynamic tool discovery inside a conversation.