I pulled the referring domains for a small business site from the Ahrefs API in August and it came back with 2. The real number at the time was 41. Nothing errored, the request returned normally, and the only thing wrong was one setting called mode. If I'd reported the first number, I'd have told someone the site had almost no links when it had twenty times as many.
What the setting does
Every Site Explorer call in the Ahrefs API takes a mode, which the documentation describes as “The scope of the search based on the target you entered.” The allowed values are exact, prefix, domain and subdomains.

The site I was checking is served from the www address, and I'd entered the bare domain as the target. With mode set to domain, and again with it set to exact, the API counted links to the bare domain only and gave me 2. With mode set to subdomains, it counted links to the www address as well and gave me 41, because that's where nearly every link pointed.
A second domain I checked the same day returned 411 on all three modes. Its links all pointed at the bare domain, so the setting made no difference there, which is why you can use this API for a long time and never notice.
The second way it returned a wrong number
I was on the Lite plan, which caps every call at 100 rows. What I didn't expect is that it also ignores the offset, so when I asked for the second page of results, I got the first page again with no error. If you loop through pages and add the rows up, you get the same hundred domains several times over, and if you remove the duplicates, you're left with 100 and think that's all there is.
The way round it is to slice the request with a filter. I walked through the range of Domain Rating in bands, and whenever a band came back with exactly 100 rows, I split it in two and asked again, until every band returned fewer than 100. That's how I pulled a list of 539 referring domains for one site on a plan that only gives 100 at a time.
What the 41 turned out to be
Getting the count right was only half of it, because 41 sounded healthy for a small site until I looked at what they were.
- 27 of the 41 had appeared in eight days, between 18 and 26 August.
- 23 of the 41 had an estimated traffic figure under 100.
- 21 linked with nofollow only.
- The new arrivals were all directory sites.
- There was one followed link from a site with real readership.
So, the honest summary was one link that counted and a burst of directory listings I hadn't asked for. I never found out who or what placed them. I didn't disavow them either, because Google's disavow page says “In most cases, Google can assess which links to trust without additional guidance”, and a few dozen nofollow directory links aren't going to bring a manual action.

Two columns worth adding
The referring domains endpoint has two fields that most of the examples leave out. One is the domain's estimated traffic, and I now judge a referring domain on that before I look at its Domain Rating, because 23 of those 41 had a rating and next to no visitors. The other is a spam flag. On the 539 domain list, which was nearly all spam, it had flagged 98% of them, so it's a quick way to sort a profile before you read it.
What I got wrong
I believed the 2. It was a small site and a small number, and it looked about right. It was only caught by running the same call in the other modes and seeing the answer change, which is now the first thing I do. Both of these faults return a normal response with a believable number in it, and I'd been treating a successful request as a correct one.
I should also say where I stand. I make my living on the links side of SEO, so I use these tools every day and I'm not knocking this one. The setting does what the documentation says. My mistake was not knowing which address the site's links pointed at before I chose it.
What I'd do
In this order, because the first check takes a minute and tells you whether the rest of your numbers can be trusted:
- Run the referring domains count in domain, exact and subdomains mode. If the three agree, carry on. If they don't, subdomains is the one that includes www, and that was the true figure for me.
- Check which address the site is served from, and enter the target to match it.
- Before you page through results, request page two and compare it with page one. If they're the same, your plan is ignoring the offset.
- If it is, slice by Domain Rating bands and split any band that comes back full.
- Add the traffic and spam columns to every pull, and sort by traffic.
- Sort by first seen date as well. A cluster of new domains in one week is the first thing I'd want to know about any link profile.
There's more on judging links on the link building page.
This post sits under link building in the knowledge base, which is where I set out what Google says on it and what the published studies found. The rest of what happened on my own sites is on the blog.