Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 7 min read

Build a Website Authority Checker in Python Using Moz, Ahrefs, Semrush & Majestic Metrics

Understanding how authoritative a website is has become an important part of modern SEO workflows. Whether you're building an SEO platform, a competitor analysis tool, a website auditing system, or simply trying to unde

Build a Website Authority Checker in Python Using Moz, Ahrefs, Semrush & Majestic Metrics

Understanding how authoritative a website is has become an important part of modern SEO workflows.

Whether you're building an SEO platform, a competitor analysis tool, a website auditing system, or simply trying to understand why some domains perform better than others, website authority metrics provide valuable insights into the overall strength and credibility of a domain.

The challenge is that there is no single universal "website authority" metric.

Different SEO providers use different names, different algorithms, and different data sources:

  • Moz uses Domain Authority (DA).
  • Ahrefs uses Domain Rating (DR).
  • Semrush uses Authority Score.
  • Majestic uses Trust Flow and Citation Flow.

Although these metrics are calculated differently, they all attempt to answer a similar question:

How strong and trustworthy is this website compared to others?

In this tutorial, we will build a Python-based website authority checker that retrieves authority metrics from multiple SEO providers through a unified API.

By the end, you will have a command-line application capable of analyzing a domain and returning:

  • Moz Domain Authority
  • Moz Page Authority
  • Ahrefs Domain Rating
  • Semrush Authority Score
  • Majestic Trust Flow
  • Majestic Citation Flow

The complete source code, endpoint documentation, schemas, and additional examples in other programming languages are available in the GitHub repository.

Understanding Website Authority Metrics

Before writing code, it is important to understand what we are measuring.

What is Website Authority?

Website authority (sometimes referred to as thought leadership or topical authority) describes how relevant, trustworthy, and influential a website appears within a particular subject area or industry.

Search engines do not publish a single "authority score" for websites. Instead, SEO providers create their own scoring systems based on factors such as:

  • Backlink profiles
  • Referring domains
  • Link quality
  • Organic search performance
  • Historical data
  • Website trust signals

Because each provider uses different methodologies, the scores are not directly interchangeable.

A Domain Authority score of 90 from Moz does not mean the same thing as a Domain Rating score of 90 from Ahrefs.

However, they are useful because they help estimate the relative strength of a website.

Comparing Popular Authority Metrics

Provider Metric Description
Moz Domain Authority (DA) Predicts how likely a domain is to rank in search engines
Moz Page Authority (PA) Predicts ranking potential of an individual page
Ahrefs Domain Rating (DR) Measures the strength of a website's backlink profile
Semrush Authority Score Evaluates overall domain quality and SEO strength
Majestic Trust Flow Measures the quality and trustworthiness of inbound links
Majestic Citation Flow Measures link influence based on link quantity

The important takeaway:

These metrics measure different aspects of authority. Combining multiple providers gives a more complete picture than relying on a single score.

Problem: Multiple Providers, Multiple APIs

Imagine you are building an SEO SaaS platform.

A user enters:

google.com

You want to display:

Moz
Domain Authority: 94

Ahrefs
Domain Rating: 99

Semrush
Authority Score: 100

Majestic
Trust Flow: 100
Citation Flow: 99

Without a unified solution, you would need separate integrations:

Each provider has:

  • Different authentication methods
  • Different request formats
  • Different response structures
  • Different documentation

Maintaining multiple integrations quickly becomes complicated.

Instead, we will use a unified SEO metrics API:

The Project

We will build a simple Python command-line application.

The final result:

python authority_checker.py google.com

Example output:

========================================
Website Authority Report
========================================

Domain:
google.com


Moz
----------------------------------------
Domain Authority: 94
Page Authority: 91


Ahrefs
----------------------------------------
Domain Rating: 99


Semrush
----------------------------------------
Authority Score: 100


Majestic
----------------------------------------
Trust Flow: 100
Citation Flow: 99

========================================

Prerequisites

Before starting, you need:

  • Python 3.8+
  • A RapidAPI account
  • An API key

You will also need the following Python packages:

pip install requests python-dotenv

Project Setup

Create a new project:

mkdir authority-checker

cd authority-checker

Create the following files:

authority-checker/

β”œβ”€β”€ authority_checker.py
β”œβ”€β”€ seo_metrics.py
β”œβ”€β”€ requirements.txt
└── .env

Your requirements.txt:

requests
python-dotenv

Configure API Authentication

Create a .env file:

RAPIDAPI_KEY=your_api_key_here

We will load this key from Python instead of hardcoding it.

Creating the API Client

Create seo_metrics.py.

First, configure the API connection:

import os
import requests

from dotenv import load_dotenv


load_dotenv()


BASE_URL = "https://enterprise-seo-metrics.p.rapidapi.com"

HEADERS = {
    "x-rapidapi-key": os.getenv("RAPIDAPI_KEY"),
    "x-rapidapi-host": "enterprise-seo-metrics.p.rapidapi.com",
    "Content-Type": "application/x-www-form-urlencoded"
}

Now create a reusable request function:

def get_metrics(endpoint, domain):

    response = requests.post(
        f"{BASE_URL}/{endpoint}",
        data={
            "domain": domain
        },
        headers=HEADERS
    )

    response.raise_for_status()

    return response.json()

This function allows us to call any SEO metrics endpoint using the same code.

Retrieving Moz Metrics

Moz provides several useful authority signals.

For this tutorial, we will use:

  • Domain Authority
  • Page Authority

The endpoint response contains:

{
  "metrics": {
    "domain_authority": 94,
    "page_authority": 91
  }
}

Retrieve the data:

moz = get_metrics(
    "moz-metrics",
    domain
)

moz_metrics = moz["results"]["metrics"]

domain_authority = moz_metrics["domain_authority"]

page_authority = moz_metrics["page_authority"]

Retrieving Ahrefs Metrics

Ahrefs uses Domain Rating (DR) as its primary domain authority metric.

The response separates domain-level and URL-level metrics.

For overall website authority, we use the domain object:

ahrefs = get_metrics(
    "ahrefs-metrics",
    domain
)

Extract Domain Rating:

domain_rating = (
    ahrefs["results"]
    ["metrics"]
    ["domain"]
    ["domain_rating"]
)

Ahrefs also provides additional data such as:

  • Backlinks
  • Referring domains
  • Organic traffic
  • Organic keywords

Retrieving Semrush Authority Score

Semrush provides Authority Score together with additional SEO metrics.

Retrieve the endpoint:

semrush = get_metrics(
    "semrush-metrics",
    domain
)

Extract the score:

authority_score = (
    semrush["results"]
    ["data"]
    ["metrics"]
    ["authority_score"]
)

Retrieving Majestic Metrics

Majestic focuses heavily on link intelligence.

For authority analysis, we will use:

  • Trust Flow
  • Citation Flow

Retrieve the metrics:

majestic = get_metrics(
    "majestic-metrics",
    domain
)

Extract values:

trust_flow = (
    majestic["results"]
    ["metrics"]
    ["trust_flow"]
)


citation_flow = (
    majestic["results"]
    ["metrics"]
    ["citation_flow"]
)

Building the Command-Line Application

Create authority_checker.py.

Import the API client:

import sys

from seo_metrics import get_metrics

Get the domain:

domain = sys.argv[1]

Retrieve all providers:

moz = get_metrics(
    "moz-metrics",
    domain
)

ahrefs = get_metrics(
    "ahrefs-metrics",
    domain
)

semrush = get_metrics(
    "semrush-metrics",
    domain
)

majestic = get_metrics(
    "majestic-metrics",
    domain
)

Formatting the Results

Now extract the values:

moz_metrics = moz["results"]["metrics"]

domain_authority = moz_metrics["domain_authority"]

page_authority = moz_metrics["page_authority"]


domain_rating = (
    ahrefs["results"]
    ["metrics"]
    ["domain"]
    ["domain_rating"]
)


authority_score = (
    semrush["results"]
    ["data"]
    ["metrics"]
    ["authority_score"]
)


trust_flow = (
    majestic["results"]
    ["metrics"]
    ["trust_flow"]
)


citation_flow = (
    majestic["results"]
    ["metrics"]
    ["citation_flow"]
)

Finally, print the report:

print(f"""
========================================
Website Authority Report
========================================

Domain:
{domain}


Moz
----------------------------------------
Domain Authority: {domain_authority}
Page Authority: {page_authority}


Ahrefs
----------------------------------------
Domain Rating: {domain_rating}


Semrush
----------------------------------------
Authority Score: {authority_score}


Majestic
----------------------------------------
Trust Flow: {trust_flow}
Citation Flow: {citation_flow}

========================================
""")

Run:

python authority_checker.py google.com

Possible Extensions

Now that you have a working website authority checker, there are many ways to expand it.

Export Results to CSV

Instead of printing results, save reports:

domain,domain_authority,domain_rating,authority_score
google.com,94,99,100

This allows bulk analysis and reporting.

Analyze Hundreds of Domains

You can extend the application to process:

domains.txt

google.com
github.com
stackoverflow.com
example.com

Then generate reports for every domain.

Build a Web Dashboard

The same Python logic can power:

  • Flask applications
  • FastAPI services
  • Internal SEO dashboards
  • SaaS products

Integrate Into an SEO SaaS

Many SEO platforms need exactly this functionality:

  • Competitor analysis
  • Website auditing
  • Link analysis
  • Marketing dashboards
  • Automated reporting

A unified metrics API removes the need to maintain multiple provider integrations.

Explore Additional SEO Metrics

Authority is only one part of SEO analysis.

You can extend the project with:

  • Backlink metrics
  • Core Web Vitals
  • Chrome UX Report data
  • Social share metrics
  • Technical SEO signals

Further Reading

The complete API documentation includes:

  • Endpoint documentation
  • Request parameters
  • Response schemas
  • Field descriptions
  • Error handling
  • Code snippets

You can explore the full GitHub repository here:

Enterprise SEO Metrics API Documentation

Additional resources:

  • Python examples
  • Complete response schemas
  • Moz Metrics documentation
  • Ahrefs Metrics documentation
  • Semrush Metrics documentation
  • Majestic Metrics documentation

Key Takeaways

  • Website authority is not represented by a single universal metric.
  • Moz, Ahrefs, Semrush, and Majestic all approach the problem differently, and each metric provides a unique perspective.
  • By combining these signals in Python, you can build powerful SEO applications without maintaining multiple independent integrations.
  • The same foundation can be extended into bulk analyzers, dashboards, SEO SaaS platforms, and automated reporting systems.

Final Thoughts

I wrote this tutorial mainly because integrating SEO authority metrics often becomes more complicated than it first appears. Each provider offers valuable insights, but working with multiple APIs, response formats, and authentication methods can quickly add unnecessary complexity.

By combining these metrics into a single Python workflow, developers can focus more on building useful applications instead of maintaining multiple integrations.

If you have questions, ideas, or different approaches for building SEO tools with Python, feel free to leave a comment below. I'd be interested to hear how you would use these metrics in your own projectsβ€”whether you're building an SEO platform, a reporting dashboard, a website auditing tool, or something completely different.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.