It's easy to burn a big chunk of an Ahrefs API allowance before a script does anything useful. Nothing has to be broken for that to happen. The unit rules just punish small, chatty requests.

If you're about to build on it, here's the short version worth reading before the first loop.

The formula

Ahrefs documents the cost of a request as:

max(base_cost, per_row_cost * num_rows) 

base_cost is 50 units. per_row_cost is the sum of every unique field that shows up in the result, in where, or in order_by. Most fields cost 1 unit, some cost 5 or 10.

Their own example is the Domain Rating endpoint. It returns one row with two fields, so the row cost is 2. You still pay 50, because 2 is less than the base.

So small lookups are the expensive ones per piece of data. A loop that asks for DR of 500 domains one by one costs 25,000 units, no matter how tiny each answer is.

How big is the allowance?

From Ahrefs' help center (checked 11 November 2026):

Plan Price API units / month Max rows per request
Lite $129/mo 200,000 100
Standard $249/mo 800,000 250
Advanced $449/mo 2,000,000 500
Enterprise sales custom unlimited

200,000 units on Lite is 4,000 minimum-cost calls. That's plenty for a weekly report and not much for a tool that fans out per URL.

Read the headers, not your guesses

Every response tells you what it cost:

  • x-api-units-cost-total: what the request should cost
  • x-api-units-cost-total-actual: what it actually consumed
  • x-api-rows and x-api-units-cost-row
  • x-api-cache: hit, miss or no_cache (cached responses are free)

Log them on every call:

import requests API = "https://api.ahrefs.com/v3" def ahrefs_get(path, params, token, log): r = requests.get( f"{API}/{path}", params=params, headers={"Authorization": f"Bearer {token}"}, timeout=60, ) r.raise_for_status() log.append({ "path": path, "rows": r.headers.get("x-api-rows"), "per_row": r.headers.get("x-api-units-cost-row"), "units": r.headers.get("x-api-units-cost-total-actual"), "cache": r.headers.get("x-api-cache"), }) return r.json() 

After a test run, sum units by path. One endpoint almost always eats most of the budget, and that's the one to fix.

Four habits that cut usage

  1. Ask for fewer fields. Use select. Every field you drop lowers the per-row cost, and filtering on an expensive field counts too.
  2. Batch. Ahrefs points to batch-analysis for pulling metrics on many targets in one request instead of paying the 50-unit floor each time.
  3. Cache on your side. DR doesn't change hourly. A 7-day local cache keyed by target and endpoint is usually enough.
  4. Develop on free test queries. The docs say consumed units are non-refundable and suggest testing with free test queries and putting limits on API keys. Do both before you run anything in a loop.

When the math says "switch"

If your team already lives in Ahrefs, the units come with the plan and the API is a nice extra. The awkward case is paying $129+ a month mostly to get API access for backlink or keyword data.

That's where pay-as-you-go APIs make sense. SE Ranking, for example, sells a $50 wallet of 250,000 credits that its pricing page says never expire, doesn't charge failed requests, and gives 100,000 trial credits for 14 days without a card (checked 11 November 2026). Their credit costs differ by endpoint, so the honest test is the same one as above: run your 20 most common calls, log the credits, compare.

If you want a wider side-by-side of SEO data APIs, including when Ahrefs is still the right call, there's a breakdown on ToolVerdict. Either way, log the headers first. Your bill is hiding in them.

Prices and unit rules from Ahrefs docs, Ahrefs help center and SE Ranking's API pricing page, checked 11 November 2026. More notes like this at toolverdict.top