Integrations

Ahrefs API in Claude Code: DR, Backlinks and Keywords

Connect the Ahrefs API to Claude Code: pull DR, UR, backlinks, organic keywords and Content Explorer data, learn what each metric means, and control API costs.

By Somanath Diksangi11 min read
Ahrefs API in Claude Code: pull Domain Rating, backlinks and organic keywords with /claudeseo ahrefs

Connecting the Ahrefs API to Claude Code lets you pull Domain Rating, backlinks, organic keywords, and Content Explorer results into the same session where you plan and edit your site. The ClaudeSEO Ahrefs API Claude Code integration adds a /claudeseo ahrefs command with four subcommands, and every number it returns carries a source label, so you always know what came from Ahrefs.

This guide explains what the main Ahrefs metrics mean, how the command works, how to set it up, and four practical ways to use the data.

Key takeaways

  • You need an Ahrefs account with API access and an API token. Usage is metered in API units, and Ahrefs' own pricing applies.
  • /claudeseo ahrefs has four subcommands: metrics, backlinks, organic, and content.
  • Domain Rating (DR) and URL Rating (UR) are Ahrefs' own link metrics on a 0-100 logarithmic scale. They're useful for comparison, not something Google uses.
  • Before any batch of 50 or more URLs, the skill estimates the API unit cost and surfaces it before running.
  • For a full backlink audit with toxic link checks, competitor gaps, and a health score, use /claudeseo backlinks alongside it.

What does the Ahrefs API add to Claude Code?

Ahrefs runs its own web crawler and keeps a large index of links between sites, plus a keyword database with search volumes and rankings. Many people use it through the web app: search a domain, read the charts, export a CSV. The API exposes the same kinds of data to software.

With the API connected through Claude SEO, Claude Code can fetch that data on request and work with it directly. You can ask for a competitor's referring domains, compare them with your own, and draft an outreach list in one conversation. You can pull a page's organic keywords and then edit that page in your repo without switching tools. The connection uses the official Ahrefs MCP server. MCP (Model Context Protocol) is an open standard Claude Code uses to talk to outside tools.

The command is one of several data integrations in the Claude SEO skill suite. It reads data; it doesn't change anything in your Ahrefs account.

What do DR, UR and the other Ahrefs metrics mean?

Every Ahrefs number is an estimate from Ahrefs' own crawl and models. That's fine, as long as you know what each one measures.

Domain Rating (DR)

Domain Rating measures the strength of a whole site's backlink profile compared with other sites in Ahrefs' index, on a scale from 0 to 100. It's mainly driven by how many unique domains link to the site with followed links, and how strong those linking domains are themselves.

Two things are easy to miss. First, DR is logarithmic: moving from 70 to 80 takes far more new links than moving from 20 to 30. Second, DR is relative. Because it compares every site with every other site, your DR can drop when the rest of the web gains links faster than you do, even if you lost nothing.

Comparison of common ways to misread Domain Rating, such as treating it as a Google score, next to the correct reading of DR as a relative, logarithmic Ahrefs metric.
DR is a useful comparison tool when you read it as a relative Ahrefs metric, not as a Google score.

URL Rating (UR)

URL Rating applies the same idea to one page. It measures the strength of a specific URL's backlink profile on the same 0-100 logarithmic scale. UR is more useful than DR when you want to know why one page outranks yours: the competing page may have much stronger links even if the two sites have similar DR.

Referring domains are the distinct websites linking to a target. Backlinks are the individual links, so one site with a sitewide footer link adds many backlinks but only one referring domain. Referring domains are usually the better number to compare. The backlinks subcommand also reports the anchor text distribution and the follow/nofollow ratio, which show whether a link profile looks natural.

Organic keywords and traffic estimates

Organic keywords are the search queries a site or page ranks for in Ahrefs' keyword database. The organic traffic estimate combines those rankings with each keyword's search volume and the share of clicks each position typically gets. It's a model, not analytics. For your own site, Google Search Console shows real clicks, so use Ahrefs estimates mainly to size up competitors and spot trends.

Content Explorer

Content Explorer is Ahrefs' searchable index of pages by topic. For any topic, it shows top pages along with metrics such as social shares and referring domains. It's a quick way to see which pieces on a subject earned links and attention.

MetricWhat it measuresBest used for
Domain Rating (DR)Strength of a site's backlink profile, relative and logarithmicComparing sites in the same market
URL Rating (UR)Strength of one page's backlink profileComparing pages that compete for a query
Referring domainsDistinct sites linking to a targetTracking link growth over time
Organic keywordsQueries a site or page ranks forFinding keyword gaps and near misses
Organic traffic estimateModeled monthly search clicksSizing competitors, not measuring yourself

How the /claudeseo ahrefs command works

Flow diagram of the Ahrefs command: check the Ahrefs connection, route the subcommand, estimate cost for large batches, call the Ahrefs API, label every metric with its source, and hand off to other skills when needed.
The Ahrefs command checks its connection first and estimates cost before large batches, so you never spend API units by surprise.
  1. Check the connection. Before calling Ahrefs, the skill confirms the Ahrefs MCP tools are available in your session. If they aren't, it tells you the extension isn't installed and how to install it, instead of failing silently.
  2. Route the subcommand. metrics, backlinks, organic, or content decides which Ahrefs data is requested.
  3. Estimate cost. For a batch of 50 or more URLs, it estimates the API unit cost and surfaces the estimate before the batch runs.
  4. Call the Ahrefs API. The data is live from Ahrefs. After each call, the skill logs the actual cost.
  5. Label every metric. Each number is cited as Ahrefs data with a confidence of 1.00. If Ahrefs and Moz disagree on the same metric, the skill trusts Ahrefs and notes the discrepancy.
  6. Hand off when needed. For a multi-source backlink analysis, it defers to the backlink audit skill. For live SERP data where Ahrefs and DataForSEO overlap, it prefers DataForSEO.

The four Ahrefs subcommands

Hub diagram showing a URL or topic sent to the four Ahrefs subcommands, metrics, backlinks, organic and content, whose results merge into one report with a source label on every metric.
Each subcommand requests a different slice of Ahrefs data, and every result comes back with its source label.
SubcommandInputWhat it returns
metricsURL or domainDomain Rating or URL Rating, referring domain count, organic traffic estimate
backlinksURL or domainTop referring domains, anchor distribution, follow/nofollow ratio
organicURL or domainOrganic keywords, ranking distribution, traffic by country
contentTopicContent Explorer top results, social shares, referring domains

The ranking distribution from organic groups a site's keywords by position, so you can see how many rank near the top and how many sit further down. Traffic by country shows where a site's estimated search traffic comes from, which matters if you're deciding which markets to target.

How to set up Ahrefs in Claude Code

You need three things:

  • An Ahrefs account with API access and an API token. API usage is metered in units, and Ahrefs' own pricing applies.
  • The Ahrefs extension for Claude SEO. It installs the official Ahrefs MCP server, with installers for Linux, macOS, and Windows.
  • Node.js 18 or newer on your path, because the MCP server runs on Node.

If you haven't installed the skill suite yet, start with our guide to installing SEO skills in Claude Code. Then check Node and run a first request:

bash
node --version
text
/claudeseo ahrefs metrics https://www.example.com

If the extension isn't connected, the skill says so and shows the install step. Keep your API token out of your repository and any files you commit.

How to run Ahrefs commands in Claude Code

Each subcommand takes a URL, except content, which takes a topic:

text
/claudeseo ahrefs metrics https://www.example.com
/claudeseo ahrefs backlinks https://www.example.com
/claudeseo ahrefs organic https://www.example.com/pricing
/claudeseo ahrefs content "email deliverability"

You can also ask in plain English:

text
Use Ahrefs to compare the Domain Rating, referring domains, and organic traffic estimate of example.com with competitor-a.com and competitor-b.com.

Results label every metric with its source, for example:

markdown
| Metric                   | Value | Source                         |
|--------------------------|-------|--------------------------------|
| Domain Rating            | XX    | Ahrefs (live, confidence 1.00) |
| Referring domains        | XX    | Ahrefs (live, confidence 1.00) |
| Organic traffic estimate | XX    | Ahrefs (live, confidence 1.00) |

The exact layout depends on the question you asked. The source label on each metric doesn't change.

How to use Ahrefs data: four workflows

1. Benchmark against real competitors

Run metrics on your domain and on the three to five sites that actually compete with you in search, not the biggest names in your industry. Compare referring domains first, then DR. A large gap in referring domains suggests links are a real constraint. A small gap suggests looking at content and technical issues too, which the technical SEO audit covers.

Run backlinks to see your top referring domains, anchor distribution, and follow ratio. Branded and naked URL anchors should dominate a natural profile. For the full picture, including toxic link patterns, competitor gap lists, and a health score built from several link data sources, run the backlink audit with Claude Code.

3. Find keyword gaps and near misses

Run organic on a competitor's page that outranks yours. Look for keywords it ranks for that your page doesn't cover, then ask Claude Code to compare the two:

text
Here are the organic keywords for the competitor page from Ahrefs. Compare them with the headings and body of src/content/pricing.md. List the topics the competitor covers that we don't, and suggest where each one fits in our page.

Run it on your own pages too. Keywords sitting just below the top positions are often the cheapest wins, because the page already ranks and needs improvement rather than a rewrite. Our keyword research guide covers how to prioritize them.

Run content on a topic you want to cover. The pages with the most referring domains show which formats and angles other sites chose to link to, such as original research, tools, or definitive guides. Use that to decide what kind of piece to make, then write something better rather than a copy.

Cost guardrails for the Ahrefs API

Every Ahrefs API request uses units from your plan, so the skill builds in three habits for batch work of 50 or more URLs:

  1. Estimate first. It calculates the expected unit cost before running.
  2. Surface the estimate. It's reported before the batch runs.
  3. Log actual cost. It records what each call really used.

It shares its cost tracker with the DataForSEO skill. To keep spending predictable, start with single URLs, ask for the subcommand you need instead of all four, and save results to a file so you can re-read them without calling the API again.

Doing it without the skill

If you use the Ahrefs web app but haven't set up the API, you can still get much of the value. Export reports from Site Explorer as CSV, such as referring domains, anchors, or organic keywords, then hand them to plain Claude Code:

text
Read the Ahrefs CSV exports in ./ahrefs (referring domains and organic keywords for example.com and competitor.com). Tell me which referring domains link to the competitor but not to us, and which keywords the competitor ranks for in the top 10 where we rank outside the top 20 or not at all. Output two tables sorted by the competitor's metric.
text
Read anchors.csv from Ahrefs. Group the anchors into branded, naked URL, generic, exact-match keyword, and other, and show the share of each group. Flag any single domain that uses keyword anchors in most of its links.

The skill adds live data on demand, source labels on every metric, a connection check, cost estimates before big batches, and hand-offs to the backlink and DataForSEO skills when they fit better.

Mistakes to avoid with Ahrefs data

  • Treating DR as a Google metric. It's Ahrefs' own score, useful for comparison only.
  • Comparing DR across unrelated markets. A local bakery and a national newspaper aren't competing for the same links.
  • Reading traffic estimates as analytics. Use Search Console for your own clicks.
  • Running big batches blind. Let the skill estimate the unit cost first.
  • Chasing links by DR alone. A relevant site with a lower DR can be worth more than an unrelated one with a higher DR.

FAQ

Can Claude Code connect to the Ahrefs API?

Yes. Claude SEO includes an Ahrefs extension that installs the official Ahrefs MCP server, which Claude Code uses to request Ahrefs data. You need an Ahrefs account with API access, an API token, and Node.js 18 or newer.

What is a good Domain Rating?

There's no universal good DR, because it's relative and logarithmic. Compare your DR with the sites you actually compete against in search. If they all sit well above you, links are probably a constraint. If you're close, focus on content and technical quality instead.

What is the difference between DR and UR?

DR measures the backlink strength of a whole domain. UR measures the backlink strength of a single page. Both use Ahrefs' 0-100 logarithmic scale, and UR is the better metric when comparing two pages that compete for the same query.

Does Google use Domain Rating?

No. Domain Rating is a metric Ahrefs calculates from its own link index. Google has its own systems for evaluating links and doesn't use third-party scores. DR is useful because it summarizes a link profile in one comparable number.

How much does the Ahrefs API cost?

That depends on your Ahrefs plan, and Ahrefs' own pricing applies. Usage is metered in API units, so the skill estimates the cost before any batch of 50 or more URLs and logs actual usage after each call.

Is Ahrefs data accurate?

It's an estimate based on Ahrefs' own crawl and models. Link counts reflect what Ahrefs has found, and traffic figures are modeled from rankings and search volumes. Use it to compare sites and spot trends, and use Search Console for your own site's real clicks.