Skip to content
MrKeyword
Developers

How to check backlinks with an API

A backlink API returns the links pointing at a domain, with the page each link sits on, its anchor text, its follow status and when it was seen, so your code can list, count and monitor them. This guide shows the requests in curl, JavaScript and Python, explains every field in the answer, and covers the pitfalls that make two backlink tools disagree: freshness, nofollow and counting rules.

A laptop with a terminal window and three white chain links floating out of the screen, one marked with a green check
The short version
  • With MrKeyword's Data API, GET /domains/backlinks returns up to 500 page-level links per call for 2 credits, and GET /domains/referring-domains returns the linking domains for 2 credits.
  • Each link carries source URL, target URL, anchor text, follow / nofollow / sponsored / UGC flags, link kind, first seen and last seen.
  • Backlinks and referring domains are different counts: 1,000 links can come from 10 domains. Most SEO decisions should start from referring domains.
  • No backlink index sees the whole web, and each one counts differently, so two tools never agree exactly. Compare trends within one tool, not numbers across tools.
  • A link is only "lost" once its page has been read again without it. Use last_seen to judge freshness yourself.

What does a backlink API return?

A backlink API returns, for a domain or URL you name, the links other sites point at it: the linking page, the target page, the anchor text, whether the link is followed, and when the link was found. Most also return totals (backlinks, referring domains, follow and nofollow) and lists of the domains that link.

You use one to build a backlink checker, to monitor a client's new and lost links, to find link-building prospects from competitors' links, or to feed link counts into a report. The examples below use MrKeyword's backlink API because we make it and can explain exactly how it counts; the same ideas apply to any provider, and the comparison of SEO APIs covers the others, including Ahrefs, Majestic and DataForSEO.

Two endpoints cover it:

  • GET /domains/backlinks?domain=&limit=&offset=: page-level links, newest first, up to 500 per call. 2 credits per call.
  • GET /domains/referring-domains?domain=&limit=: the domains that link, strongest first, up to 500, with what changed between releases. 2 credits per call.

How do you check backlinks with an API?

Create an API key, send a GET request with the domain and your key in the Authorization header, and read the links array from the JSON answer. With MrKeyword, the key comes from Data API in the app (it starts with mkd_); the free Developer plan includes 500 credits a month, which is 250 backlinks calls.

List a domain's backlinks

curl "https://app.mrkeyword.io/api/v1/domains/backlinks?domain=example.com&limit=100" \
  -H "Authorization: Bearer $MRKEYWORD_KEY"
2 credits per call, whatever the limit (1 to 500).

The answer (abridged)

{
  "data": {
    "domain": "example.com",
    "total": 1840,
    "totals": { "backlinks": 1240, "follow": 1010, "nofollow": 230, "referringDomains": 312, "new30d": 41, "lost": 17, "combined": 1840 },
    "label": "Measured",
    "asOf": "2026-12-01T06:12:44.000Z",
    "topAnchors": [{ "anchor": "example", "links": 220, "domains": 96 }],
    "links": [{
      "source_url": "https://blog.sample.org/best-tools",
      "source_domain": "blog.sample.org",
      "target_url": "https://example.com/",
      "anchor_text": "Example",
      "nofollow": false, "sponsored": false, "ugc": false,
      "kind": "text",
      "first_seen": "2026-09-14T10:02:11.000Z",
      "last_seen": "2026-11-28T04:40:09.000Z"
    }],
    "limit": 100, "offset": 0, "hasMore": true,
    "note": "1,840 backlinks in MrKeyword data; 1,240 of them are listed individually."
  },
  "meta": { "endpoint": "domains.backlinks", "creditsCharged": 2, "creditsRemaining": 19998, "plan": "starter", "generatedAt": "2026-12-04T09:30:00.000Z" }
}
Field names as the API returns them; the numbers are illustrative.

The response fields, explained

Every link row describes one link from one page to one page, and the totals describe the whole profile; reading them correctly is most of the work.

Link fields in data.links[]

FieldWhat it meansHow to use it
source_urlThe page the link sits onLink to it, so users can check the link themselves
source_domainThe host of that pageGroup links by site; reduce to the registrable domain if you count domains yourself
target_urlThe page on the checked domain the link points at (a subdomain counts)Find your most-linked pages and links to pages that now 404
anchor_textThe clickable text; empty for many image linksSpot over-optimised anchors and brand vs keyword mix
nofollow, sponsored, ugcThe link's rel attributesSeparate editorial links from paid, user-generated and nofollow ones
kindtext, image or emptyImage links often have no anchor text, so do not read an empty anchor as an error
first_seenWhen the link was first foundNew-link alerts and link velocity
last_seenWhen the link was last confirmed on its pageFreshness: an old date means unconfirmed, not necessarily gone

Totals and paging in data

FieldWhat it means
totalThe headline backlink count in MrKeyword data. It can be larger than the links you can list (see note).
totals.backlinks, follow, nofollowCounts over the individually listed links.
totals.referringDomainsDistinct linking hosts among the listed links.
totals.new30dLinks first seen in the last 30 days.
totals.lostLinks whose page was read again after they were last seen, without them.
topAnchorsThe 25 most common anchor texts with link and domain counts.
limit, offset, hasMorePaging. hasMore is true when the page came back full; request the next offset.
label, asOf, noteWhat kind of number this is, when it was last updated, and any caveat in plain words.

Page through every link in JavaScript

Request pages of 500 and advance offset while hasMore is true; each page is one call. Cap the number of pages your tool fetches per domain, because a large site can have far more links than any user will read.

all-links.mjs (Node 18+)

const BASE = "https://app.mrkeyword.io/api/v1";
const headers = { authorization: `Bearer ${process.env.MRKEYWORD_KEY}` };

export async function allBacklinks(domain, { maxPages = 4 } = {}) {
  const links = [];
  for (let page = 0, offset = 0; page < maxPages; page += 1, offset += 500) {
    const res = await fetch(`${BASE}/domains/backlinks?domain=${encodeURIComponent(domain)}&limit=500&offset=${offset}`, { headers });
    if (res.status === 429) { await new Promise((r) => setTimeout(r, Number(res.headers.get("retry-after") || 60) * 1000)); page -= 1; offset -= 500; continue; }
    const body = await res.json();
    if (!res.ok) throw new Error(body.error);
    links.push(...body.data.links);
    if (!body.data.hasMore) break;
  }
  return links;
}

const links = await allBacklinks("example.com");
const editorial = links.filter((l) => !l.nofollow && !l.sponsored && !l.ugc);
console.log(links.length, "links,", editorial.length, "followed editorial");
Four pages of 500 cost 8 credits. Server-side only: keep the key out of the browser.

Find link-building prospects in Python

A link gap is the set of domains that link to your competitors but not to you; with a referring-domains API it is three or four calls and a set difference. Each answer lists linking domains strongest first with their MrKeyword Link Authority, so the gap is already sortable.

link_gap.py

import os, requests

BASE = "https://app.mrkeyword.io/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['MRKEYWORD_KEY']}"

def referring(domain):
    r = session.get(f"{BASE}/domains/referring-domains", params={"domain": domain, "limit": 500}, timeout=60)
    r.raise_for_status()
    return {row["domain"]: row for row in r.json()["data"]["domains"]}

mine = referring("example.com")
gap = {}
for competitor in ["rival-one.com", "rival-two.com", "rival-three.com"]:
    for name, row in referring(competitor).items():
        if name not in mine and not row.get("own"):
            gap.setdefault(name, {"authority": row.get("authority"), "links_to": []})["links_to"].append(competitor)

ranked = sorted(gap.items(), key=lambda kv: (len(kv[1]["links_to"]), kv[1]["authority"] or 0), reverse=True)
for name, info in ranked[:50]:
    print(name, info["authority"], ", ".join(info["links_to"]))
Four referring-domains calls cost 8 credits. Domains that link to two or three competitors come first: they already link to sites like yours.

The own field marks a linking domain that shares the checked domain's name (the same brand under another ending), so links between one owner's sites do not show up as prospects. To score a long prospect list in one request, send it to the domain authority API, which takes up to 100 domains per call.

Check your first backlinks freeThe Developer plan includes 500 credits a month, no card. Mint an mkd_ key under Data API and run the requests above.

See the backlink API

Pitfalls: why backlink counts disagree

Two backlink tools almost never report the same numbers for a domain, because each one has crawled a different share of the web, refreshes it on a different schedule, and counts links by different rules. Knowing the rules lets you explain the difference to users instead of apologising for it.

Link freshness

An index learns that a link exists when it crawls the linking page, and learns that it is gone only when it crawls that page again. Pages that are rarely recrawled keep old links listed. MrKeyword counts a link as lost only after its page was read again without it; a link whose page has not been re-read stays listed with its last_seen date, however old. If freshness matters to your users, filter or flag links whose last_seen is older than, say, 90 days, and say that you did.

Nofollow, sponsored and UGC

Google treats rel="nofollow", rel="sponsored" and rel="ugc" as hints about whether to use a link for ranking, as its documentation on qualifying outbound links explains. They are still links, and they still send visitors. Decide whether your tool counts them, show the split (the API gives you all three flags and follow/nofollow totals), and never mix a "followed only" count from one tool with an "all links" count from another.

Backlinks vs referring domains

A site-wide footer link on a 10,000-page site is 10,000 backlinks from one referring domain. Backlink totals swing wildly with templates like that; referring-domain counts are steadier and closer to what matters for authority. Lead with referring domains in your interface and treat backlink totals as context.

Subdomains and normalisation

MrKeyword counts links to the domain and all its subdomains (a link to blog.example.com counts for example.com), and excludes internal links within the domain. Other tools may count the exact host only, or treat www separately. When comparing, make sure you asked each tool the same question.

Headline totals vs listed links

Some links are known at the domain level without a page-level record. That is why total can exceed the links you can page through; the note field says so in words. If you show both, label them: "1,840 backlinks, 1,240 listed".

Infrastructure noise

CDNs, analytics and other technical hosts appear on millions of pages and would otherwise flood every list. MrKeyword filters a list of technical domains out of its referring-domain answers, so that list shows sites, not script hosts. If you count domains from the raw backlinks list yourself, apply a similar filter.

The honest limit: MrKeyword's link index is its own and smaller than the largest commercial link databases, so for big sites it will report fewer links than Ahrefs or Majestic. It is priced for building tools, not for the deepest counts. Check a few domains you know on the free plan before you build on it.

How to verify a backlink is still live

To confirm a single important link today, fetch the linking page yourself and look for an anchor whose href points at your domain; an API tells you where to look, your own request tells you what is there right now. This matters for paid placements, guest posts and any link a client is about to ask about.

verify_link.py: is the link still on the page?

import requests
from html.parser import HTMLParser
from urllib.parse import urljoin, urlparse

class Links(HTMLParser):
    def __init__(self, base):
        super().__init__(); self.base = base; self.found = []
    def handle_starttag(self, tag, attrs):
        if tag != "a": return
        a = dict(attrs)
        if a.get("href"):
            self.found.append((urljoin(self.base, a["href"]), (a.get("rel") or "").lower()))

def check(source_url, target_domain):
    r = requests.get(source_url, timeout=20, headers={"User-Agent": "link-check/1.0"})
    if r.status_code != 200:
        return {"live": False, "reason": f"HTTP {r.status_code}"}
    parser = Links(r.url); parser.feed(r.text)
    for href, rel in parser.found:
        host = urlparse(href).hostname or ""
        if host == target_domain or host.endswith("." + target_domain):
            return {"live": True, "href": href, "nofollow": "nofollow" in rel, "sponsored": "sponsored" in rel, "ugc": "ugc" in rel}
    return {"live": False, "reason": "no link to the domain in the HTML"}

print(check("https://blog.sample.org/best-tools", "example.com"))
Run it from your server, slowly and politely: one request per page, an honest user agent, and respect for robots.txt if you check many pages.

Three things trip this check up. Pages that build their links with JavaScript show nothing in the raw HTML, so a missing link may only mean you need a rendering browser. Some sites answer automated requests with a block page and a 200 status, so check that the page looks like the page you expect. And a link can move behind a redirect or a tracking URL whose host is not your domain; decide whether those count for you and say so in your report.

What to look for in a backlink API

Judge a backlink API on four things before price: coverage for the sites your users care about, how it shows freshness, how clearly it labels link attributes, and how predictable a lookup's cost is.

  • Coverage you can test. Check five domains you know well, small and large, on a free tier or trial. Compare referring-domain counts and the strongest linking sites with what you know is true.
  • Dates on every link. First-seen and last-seen dates let you show new and lost links honestly. Without them, every list looks equally current.
  • Attributes, not just a count. Follow, nofollow, sponsored and UGC should be separate flags, so you can choose your own counting rule.
  • Cost per lookup. Per-row pricing makes long lists expensive; per-call pricing makes them cheap but caps rows per call. Work out the cost of one typical lookup in your tool, then of a month. The comparison of SEO APIs does this for seven providers.

Monitoring backlinks over time

To monitor links, store what you have seen and compare on a schedule; the API's dates and totals give you most of the comparison for free. A simple weekly job per client domain:

  1. Fetch

    Call /domains/backlinks (newest first) until you reach links you already stored, and /domains/referring-domains once.

  2. Diff

    New links are the source_url + target_url pairs you had not stored. The referring-domains answer also lists domains gained and lost between releases.

  3. Alert

    Send new followed links from domains with real authority, and links whose last_seen stopped moving.

  4. Report

    Chart totals.referringDomains and new30d over time rather than raw backlink totals.

For 50 client domains checked weekly with two calls each, that is about 860 credits a month: API Starter at $29 a month. The build guide covers caching, rate limits and pricing in more detail.

Questions and answers

Backlink API guide questions

What is a backlink API?

A backlink API is a web service that returns the links pointing at a domain or URL, with the linking page, anchor text, follow status and dates, as JSON your code can use to build a checker, monitor links or find prospects.

How do I check backlinks with an API?

Create an API key, call the backlinks endpoint with the domain, and read the links from the answer. With MrKeyword that is GET https://app.mrkeyword.io/api/v1/domains/backlinks?domain=example.com with an mkd_ key, at 2 credits per call.

Is there a free backlink API?

MrKeyword's Developer plan includes 500 credits a month with no card, enough for 250 backlinks calls. Moz's API has a free tier of 50 rows a month, and SE Ranking offers a 14-day trial.

Why do backlink tools show different numbers?

Each tool has crawled a different share of the web, recrawls pages on its own schedule, and counts links by its own rules for nofollow, subdomains and site-wide links. Compare trends inside one tool rather than totals across tools.

Should I count nofollow links?

Show them, labelled. Google treats nofollow, sponsored and ugc as hints, and those links still send visitors. Report the followed and nofollow split so users can decide.

What is the difference between backlinks and referring domains?

Backlinks counts individual links; referring domains counts the distinct sites they come from. One site-wide link can add thousands of backlinks but only one referring domain.

About this article

Written by Raman Makkar, who builds an SEO workspace on first-party Search Console and Bing data. Outside facts link to their original source below. We update this page when the product or the sources change.

Sources

  1. MrKeyword backlink API — endpoints, fields and credit costs
  2. MrKeyword OpenAPI 3.1 spec — parameters and response shapes
  3. Qualify your outbound links to Google — Google Search Central on rel=nofollow, sponsored and ugc
  4. Node.js: fetch — the built-in fetch used in the JavaScript example
  5. Requests: HTTP for Humans — the Python library used in the link-gap example
Keep reading

More on MCP servers and APIs, plus the feature and free tool for the same job. All MCP servers and APIs guides →

Check backlinks from your own code.

Create a free MrKeyword workspace, mint an mkd_ key and use 500 credits a month to build your backlink tool. Free plan for one website, no card; paid plans from $10 a month.