Ahrefs API

Give your agents access to Ahrefs API. Bring your own Ahrefs key, or skip the signup and pay per call from your Composio balance with Composio Instant.

Ahrefs logoAhrefs
Instant

Ahrefs is an SEO and marketing platform for site audits, keyword research, and competitor insights. It helps you improve search rankings and drive organic traffic.

46 Tools
COMPOSIO INSTANT

What is Composio Instant?

Composio Instant lets your agent use paid APIs like Ahrefs without a separate account or API key for each one. New accounts start with $2 of free credit.

No Ahrefs account or key

Your agent calls Ahrefs through Composio, so there is nothing to sign up for, store, or rotate.

Pay per call, at cost

$0 per request, paid from your Composio balance with zero markup.

Works in any agent

Claude, ChatGPT, Cursor, and other MCP clients, or your own code with the Composio SDK.

Works with your apps

Use Ahrefs with Gmail, Slack, Google Sheets, and 1,700+ other apps you connect.

AI ASSISTANTS

Connect the Ahrefs API to your AI assistant

Use Ahrefs from the AI assistant you already work in. Connect Composio once, then paste the prompt.

  1. 1

    Open the Connectors menu

    Use the button to open Claude's Add connector dialog with Composio filled in. Or click + in the message box, then Connectors, Add connector and Add custom connector.
    Add Composio to Claude
  2. 2

    Add the Composio MCP server

    Name it Composio, paste the MCP server URL and click Add.
    https://connect.composio.dev/mcp
  3. 3

    Authorize in your browser

    A browser window opens. Sign in to Composio to approve the connection.
  4. 4

    Paste the prompt

    Start a new chat and paste the prompt. Claude runs the call on Composio Instant.
  1. 1

    Install the Composio plugin

    Open Composio's plugin page in ChatGPT and click Install. Sign in to ChatGPT first if it asks.
    Install in ChatGPT
  2. 2

    Authorize in your browser

    Connect the plugin, then sign in to Composio to approve the connection.
  3. 3

    Turn on Composio in your chat

    In a new chat, click +, then More, and select Composio.
  4. 4

    Paste the prompt

    Paste the prompt into that chat. ChatGPT runs the call on Composio Instant.
  1. 1

    Install the Composio plugin

    Open Composio in the Cursor marketplace, click Install Composio Plugin for Cursor and approve the connection in your browser.
    Install in Cursor
  2. 2

    Paste the prompt

    Open the Agent chat and paste the prompt. Cursor runs the call on Composio Instant.
  1. 1

    Add the Composio plugin

    Open Composio's listing on x.ai and click Add to Grok Bot. When Grok Bot opens the plugin, click Add.
    Add to Grok Bot
  2. 2

    Authenticate

    Go to Installed, open Composio and click Authenticate. Sign in to Composio and click Authorize.
  3. 3

    Paste the prompt

    Paste the prompt into your bot's chat. Grok Bot runs the call on Composio Instant.
  1. 1

    Paste the setup prompt

    Copy this into your Hermes chat. Hermes adds the Composio MCP server for you.
    Set up Composio from composio.dev/hermes
  2. 2

    Authorize in your browser

    A browser window opens. Sign in to Composio to approve the connection.
  3. 3

    Paste the prompt

    Start a new chat and paste the prompt. Hermes runs the call on Composio Instant.
ClaudeNew chat

Paste this prompt

Use Ahrefs through Composio Instant to retrieve the free Domain Rating for wikipedia.org. Return the domain rating.

What success looks like

AHREFS_GET_DOMAIN_RATING_FREE

Your assistant runs Ahrefs and replies with the Domain Rating for wikipedia.org.

Runs on Composio Instant
SDK

Use the Ahrefs API in your code

Call Ahrefs from your own agent with the Composio SDK. Four steps and one tool call.

  1. 1

    Set up Composio

    Turn on Instant Toolkits in your project settings and check your prepaid balance in Billing. Then set your API key.
    export COMPOSIO_API_KEY="your_composio_api_key"
  2. 2

    Install the SDK

    The Python SDK needs Python 3.11 through 3.15.
    pip install composio
  3. 3

    Run the call

    Create a session that keeps Instant to this toolkit and reports the charge, then run the tool on the Instant account.
    AHREFS_GET_DOMAIN_RATING_FREE
  4. 4

    Read the response

    When the call runs on Instant, the response includes its charge: the amount as an exact USD decimal string, the currency and charged_by.
agent.py
from composio import Composio

composio = Composio()

session = composio.sessions.create(
    user_id="user_123",
    toolkits=["ahrefs"],
    instant={
        "toolkits": {"enable": ["ahrefs"]},
        "return_instant_charge": True,
    },
)

result = session.execute(
    "AHREFS_GET_DOMAIN_RATING_FREE",
    arguments={
        "target": "wikipedia.org",
    },
    account="instant_account",
)
print(result)
print("Instant charge:", result.instant_charge)
TOOLS

Available Ahrefs API tools

42 Ahrefs tools run on Instant, priced per call with no Ahrefs key. Tools marked Your key need your own Ahrefs account.

ActionTool slugWhat it doesAvailability
Backlink StatsAHREFS_BACKLINKS_STATS_RETRIEVALGet backlink statistics for a website or URL.
Instant$0.006 per 10 API units used65% off
Keyword OverviewAHREFS_EXPLORE_KEYWORDS_OVERVIEWRetrieve keyword metrics for terms or a keyword list in a country.
Instant$0.006 per 10 API units used65% off
Domain RatingAHREFS_GET_DOMAIN_RATING_FREERetrieve the free Domain Rating for a domain or URL.
Instant$0 per request
Organic CompetitorsAHREFS_RETRIEVE_ORGANIC_COMPETITORSFind organic search competitors, with keyword overlap and performance metrics.
Instant$0.006 per 10 API units used65% off
Top PagesAHREFS_RETRIEVE_TOP_PAGES_FROM_SITE_EXPLORERRetrieve data about a website's top-performing pages.
Instant$0.006 per 10 API units used65% off
Batch Url AnalysisAHREFS_BATCH_URL_ANALYSISPerforms a batch analysis on multiple URLs or domains using Ahrefs' powerful SEO metrics.
Instant$0.006 per 10 API units used65% off
Domain rating for site explorerAHREFS_DOMAIN_RATING_FOR_SITE_EXPLORERRetrieves Ahrefs Domain Rating and Ahrefs Rank for a specified domain or URL on a requested date.
Instant$0.006 per 10 API units used65% off
Domain rating historyAHREFS_DOMAIN_RATING_HISTORYRetrieves the historical Domain Rating (DR) data for a specified domain over time.
Instant$0.006 per 10 API units used65% off
Explore keyword volume by countryAHREFS_EXPLORE_KEYWORD_VOLUME_BY_COUNTRYRetrieves monthly search volume data across countries for a specified keyword using Ahrefs' Keywords Explorer.
Instant$0.006 per 10 API units used65% off
Explore linked domains of a siteAHREFS_EXPLORE_LINKED_DOMAINS_OF_A_SITERetrieves a list of external domains that the specified target website or URL links to, using Ahrefs' Site Explorer functionality.
Instant$0.006 per 10 API units used65% off
Explore matching terms for keywordsAHREFS_EXPLORE_MATCHING_TERMS_FOR_KEYWORDSThe keywords_explorer_matching_terms endpoint retrieves a list of keyword phrases that match or contain the specified keyword from Ahrefs' vast database.
Instant$0.006 per 10 API units used65% off
Fetch all backlinksAHREFS_FETCH_ALL_BACKLINKSRetrieves a comprehensive list of backlinks for a specified website or URL using Ahrefs' Site Explorer tool.
Instant$0.006 per 10 API units used65% off
Fetch broken backlinks dataAHREFS_FETCH_BROKEN_BACKLINKS_DATARetrieves a list of broken backlinks for a specified website using Ahrefs' Site Explorer tool.
Instant$0.006 per 10 API units used65% off
Fetch site explorer referring domainsAHREFS_FETCH_SITE_EXPLORER_REFERRING_DOMAINSRetrieves a list of domains that have backlinks pointing to a specified target website.
Instant$0.006 per 10 API units used65% off
Fetch total search volume historyAHREFS_FETCH_TOTAL_SEARCH_VOLUME_HISTORYRetrieves historical total search volume for keywords associated with a target domain or URL using Ahrefs Site Explorer.
Instant$0.006 per 10 API units used65% off
Get content helper topicsAHREFS_GET_CONTENT_HELPER_TOPICSRetrieve topics covered by top-ranking pages for a keyword.
Instant$0.006 per 10 API units used65% off
Get domain rating top domainsAHREFS_GET_DOMAIN_RATING_TOP_DOMAINSRetrieves domains ordered by Ahrefs Domain Rating.
Instant$0 per request
Get serp overviewAHREFS_GET_SERP_OVERVIEWRetrieves a SERP overview for one keyword in a specified country, optionally at a historical date.
Instant$0.006 per 10 API units used65% off
Get site explorer AI responses countAHREFS_GET_SITE_EXPLORER_AI_RESPONSES_COUNTRetrieve AI response citation and page counts for a site.
Instant$0.006 per 10 API units used65% off
Get site explorer country metricsAHREFS_GET_SITE_EXPLORER_COUNTRY_METRICSRetrieves country-specific Site Explorer metrics for a target website or URL, including organic traffic and keyword metrics.
Instant$0.006 per 10 API units used65% off
Get site explorer crawled pagesAHREFS_GET_SITE_EXPLORER_CRAWLED_PAGESRetrieve crawled pages and crawl metadata for a target URL.
Instant$0.006 per 10 API units used65% off
Get site explorer linked anchors externalAHREFS_GET_SITE_EXPLORER_LINKED_ANCHORS_EXTERNALRetrieves anchor text data for external links going out from a target website using Ahrefs Site Explorer.
Instant$0.006 per 10 API units used65% off
Get url rating historyAHREFS_GET_URL_RATING_HISTORYRetrieves the historical URL Rating data for a specified URL over time.
Instant$0.006 per 10 API units used65% off
Linked anchors explorerAHREFS_LINKED_ANCHORS_EXPLORERRetrieves information about internal linked anchors for a specified website using the Ahrefs API.
Instant$0.006 per 10 API units used65% off
List best by external linksAHREFS_LIST_BEST_BY_EXTERNAL_LINKSRetrieves pages from a specified website using Ahrefs' Site Explorer best-by-external-links report.
Instant$0.006 per 10 API units used65% off
Pages by traffic overviewAHREFS_PAGES_BY_TRAFFIC_OVERVIEWRetrieves a list of pages from a specified website, ordered by their estimated organic search traffic.
Instant$0.006 per 10 API units used65% off
Post Domain Rating FreeAHREFS_POST_DOMAIN_RATING_FREERetrieve Domain Rating scores for up to 1,000 target URLs.
Instant$0 per request
Retrieve anchor dataAHREFS_RETRIEVE_ANCHOR_DATARetrieves anchor text data for a specified website or URL using Ahrefs' Site Explorer tool.
Instant$0.006 per 10 API units used65% off
Retrieve best by internal linksAHREFS_RETRIEVE_BEST_BY_INTERNAL_LINKSRetrieves pages ranked by internal links for a specified website using Ahrefs' Site Explorer.
Instant$0.006 per 10 API units used65% off
Retrieve crawler ip rangesAHREFS_RETRIEVE_CRAWLER_IP_RANGESRetrieves the list of IP address ranges used by Ahrefs' web crawler (AhrefsBot).
Instant$0 per request
Retrieve organic keywordsAHREFS_RETRIEVE_ORGANIC_KEYWORDSRetrieves organic keywords data for a specified website using Ahrefs' Site Explorer tool.
Instant$0.006 per 10 API units used65% off
Retrieve outlinks statsAHREFS_RETRIEVE_OUTLINKS_STATSRetrieves outgoing-link statistics for a specified website or URL using Ahrefs Site Explorer.
Instant$0.006 per 10 API units used65% off
Retrieve paid pages dataAHREFS_RETRIEVE_PAID_PAGES_DATARetrieves information about paid pages (PPC advertising) for a specified website using Ahrefs' Site Explorer tool.
Instant$0.006 per 10 API units used65% off
Retrieve public crawler ipsAHREFS_RETRIEVE_PUBLIC_CRAWLER_IPSRetrieves a list of IP addresses currently used by AhrefsBot, Ahrefs' web crawler.
Instant$0 per request
Retrieve related termsAHREFS_RETRIEVE_RELATED_TERMSRetrieves related keyword ideas for a given keyword or keyword list in a specified country.
Instant$0.006 per 10 API units used65% off
Retrieve site explorer keywords historyAHREFS_RETRIEVE_SITE_EXPLORER_KEYWORDS_HISTORYRetrieves historical keyword performance data for a specified website or domain using Ahrefs' Site Explorer.
Instant$0.006 per 10 API units used65% off
Retrieve site explorer metricsAHREFS_RETRIEVE_SITE_EXPLORER_METRICSRetrieves Site Explorer SEO metrics for a target domain or URL on a specified date, including backlink, referring-page and crawled-page counts.
Instant$0.006 per 10 API units used65% off
Retrieve site explorer metrics historyAHREFS_RETRIEVE_SITE_EXPLORER_METRICS_HISTORYRetrieves historical Site Explorer traffic metrics for a target website or URL over a specified period, including estimated organic and paid traffic and cost.
Instant$0.006 per 10 API units used65% off
Retrieve site explorer pages historyAHREFS_RETRIEVE_SITE_EXPLORER_PAGES_HISTORYRetrieves historical page counts for a target domain or URL from Ahrefs Site Explorer over a specified period.
Instant$0.006 per 10 API units used65% off
Retrieve site explorer referring domains historyAHREFS_RETRIEVE_SITE_EXPLORER_REFERRING_DOMAINS_HISTORYRetrieves the historical data of referring domains for a specified website or URL over time.
Instant$0.006 per 10 API units used65% off
Retrieve volume historyAHREFS_RETRIEVE_VOLUME_HISTORYRetrieves the historical search volume data for a specified keyword using Ahrefs' Keywords Explorer tool.
Instant$0.006 per 10 API units used65% off
Search suggestions explorerAHREFS_SEARCH_SUGGESTIONS_EXPLORERRetrieves search suggestions for keywords or an existing keyword list using Ahrefs Keywords Explorer.
Instant$0.006 per 10 API units used65% off
Site Audit ProjectsAHREFS_GET_SITE_AUDIT_PROJECTSList Site Audit projects with project and crawl status details.Your key
Rank Tracker OverviewAHREFS_FETCH_RANK_TRACKER_OVERVIEWReview project rankings and search performance for a date and device.Your key

Instant prices are Ahrefs's list prices with 0% markup, paid from your Composio balance and updated every hour. Instant calls also count toward your plan's tool calls. See all plans on the pricing page.

USE CASES

Ahrefs API use cases and example prompts

Copy a prompt into your agent. Each one uses Ahrefs with apps you connect through Composio.

  • Build a keyword plan

    Use Ahrefs to retrieve keyword metrics for my target terms in the United States. Add the terms and results to my SEO Keyword Plan in Google Sheets, then post the sheet link and a brief summary in Slack's #marketing channel.

    Apps used: Ahrefs, Google Sheets, Slack

  • Map organic competitors

    Use Ahrefs to find the organic search competitors for Acme and review their keyword overlap and performance metrics. Save the findings in a page in my SEO Research space in Notion, then share the page link in Slack's #marketing channel.

    Apps used: Ahrefs, Notion, Slack

  • Report on backlink strength

    Use Ahrefs to retrieve backlink statistics and Domain Rating for Acme's website. Add the results to my SEO Metrics sheet in Google Sheets, then write a summary in my SEO Review document in Google Docs.

    Apps used: Ahrefs, Google Sheets, Google Docs

  • Review top-performing pages

    Use Ahrefs to retrieve data about Acme's top-performing pages. Add the page URLs and returned performance data to my Content Inventory in Google Sheets, and group the results by page.

    Apps used: Ahrefs, Google Sheets

TROUBLESHOOTING

Ahrefs API troubleshooting

Still stuck? The Instant tools docs cover limits, charges and session settings.

Start with Ahrefs.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Ahrefs tool your agent needs.Free to start.

Start building