Documentation
Every night, RAIA™ (Real estate Artificial Intelligence Agent) checks the popularity and authority of potential landlord and agency websites using a free Ahrefs tool. By checking this score in the background, our sales agents can instantly see
Every night, RAIA™ (Real estate Artificial Intelligence Agent) checks the popularity and authority of potential landlord and agency websites using a free Ahrefs tool. By checking this score in the background, our sales agents can instantly see
Ahrefs Free Domain Rating Integration
This integration pulls Ahrefs free domain rating data to assess the authority and trustworthiness of property listing websites, helping agents prioritize high-quality lead sources.
Every night, RAIA™ (Real estate Artificial Intelligence Agent) checks the popularity and authority of potential landlord and agency websites using a free Ahrefs tool. By checking this score in the background, our sales agents can instantly see which leads have the most valuable real estate portfolios—all without manual research or paying for expensive API keys.
2. How it works — operational workflow
RAIA's GTM lead generation pipeline automatically scans Companies House and regional directories to find newly registered property firms and independent agencies. However, raw lists contain thousands of entries, many of which are dormant or low-value. To target our outreach effectively, the system uses the Ahrefs free Domain Rating (DR) API to score the digital authority of each lead's website. High-DR sites correlate with established portfolios, indicating high-value commissions.
Step-by-Step Data Enrichment
-
1Nightly Lead Ingestion
The nightly cron task pulls newly discovered property agencies from Companies House and writes them as cold leads to the database.
-
2Domain Extraction & Normalization
The GTM scraper extracts corporate URLs from lead metadata and strips subdirectories, protocols, and query strings to get a canonical domain name (e.g.,
example.co.uk). -
3Public Ahrefs Rating Query
RAIA™ (Real estate Artificial Intelligence Agent) dispatches a direct, unauthenticated GET request to Ahrefs' public API to fetch the domain's authority rating (DR) on a scale from 0 to 100.
-
4Database Storage & Sync
The returned rating is upserted into the lead's data profile (
tbl_organisations_data), instantly updating our systems. -
5Dashboard Triage for Sales Staff
When our sales team logs in at 09:00, the admin dashboard displays newly enriched prospects sorted by Domain Rating, allowing them to prioritize high-value companies immediately.
A Day in the Life of the Scraper
The entire enrichment pipeline operates fully autonomously in the background. The table below outlines how the system schedules, executes, and surfaces the scored leads:
| Time | Event / Trigger | Which Agent | What Agent Does | What You See |
|---|---|---|---|---|
| 02:00 | Nightly Cron Wakeup | GTM Ingest Agent | Imports fresh listings from Companies House | New records added to tbl_companies_house_leads |
| 02:30 | Lead Pre-processing | Enrichment Agent | Parses, cleans, and canonicalizes corporate URLs | Domain fields populated in lead rows |
| 02:35 | Ahrefs REST Query | Domain Scraper Agent | GET requests sent to the free Ahrefs endpoint | Responses processed in milliseconds |
| 02:40 | Database Ledger Sync | Database Sync Agent | Upserts fresh DR values into organization tables | Database metrics fully populated |
| 09:00 | Daily Login | Agency Sales Staff | Opens the Sales Portal to manage outreach | Dashboard lists leads prioritized by DR badge |
Operational Flowchart
3. Technical — how it works in code
The domain rating scraper is integrated into RAIA's nightly pipeline scripts. By calling Ahrefs' unauthenticated endpoint with the appropriate query string, we bypass the need for paid API tokens, while wrapping calls in retry logic to prevent transient network failures or rate limits.
Repository Code
The live codebase implementation for the Ahrefs lead rating scraper and cron synchronization sits within:
Active Code Implementation (Python)
Below is the core Python logic used to query Ahrefs' public API and securely update the Supabase database:
import requests
import time
def fetch_ahrefs_domain_rating(domain: str, max_retries: int = 3) -> float:
"""
Queries Ahrefs' free public Domain Rating endpoint.
Bypasses the need for API keys while utilizing basic backoff retries.
"""
url = "https://api.ahrefs.com/v3/public/domain-rating-free"
params = {"target": domain}
for attempt in range(max_retries):
try:
response = requests.get(url, params=params, timeout=10)
if response.status_code == 429:
time.sleep(2 ** attempt) # Exponential backoff on rate limits
continue
response.raise_for_status()
data = response.json()
return data.get("domain_rating", {}).get("domain_rating", 0.0)
except Exception as e:
if attempt == max_retries - 1:
print(f"Error querying Ahrefs for {domain}: {e}")
return 0.0
time.sleep(1)
return 0.0
Database Schema & Storage Queries
The extracted score is stored directly inside tbl_organisations_data under the JSONB field or dedicated columns. Sales portals query this data directly to build dynamic badges:
-- Upserting lead with updated Domain Rating
UPDATE public.tbl_organisations_data
SET snapshot_static = jsonb_set(
COALESCE(snapshot_static, '{}'::jsonb),
'{ahrefs_domain_rating}',
'45.5'::jsonb
)
WHERE organisation_id = 'org_01jh823528b';
-- Querying and sorting prospects by authority score
SELECT
organisation_id,
name,
(snapshot_static->>'ahrefs_domain_rating')::float AS domain_rating
FROM public.tbl_organisations_data
WHERE (snapshot_static->>'ahrefs_domain_rating') IS NOT NULL
ORDER BY domain_rating DESC
LIMIT 50;
Sequence Diagram & Error States
This sequence diagram documents the end-to-end API exchange, illustrating the exponential backoff loop for rate limits (HTTP 429) and silent failure fallbacks to keep the cron runner robust:
Cross-References & Connected Systems
This pipeline is part of the larger GTM & Lead Enrichment system. Check out these related specs to see how it fits together:
- See 3.14 News Feed scanning & Google NotebookLM Research Integration for details on nightly RSS ingestion.
- See 4.3 Agent-to-Agent (A2A) Strategic Activation & Trojan Horse Plan for B2B portal overrides.
Architecture Details
Integration architecture uses a hub-and-spoke model with a central integration engine that manages API connections, data transformation, and error handling. Each external integration is a self-contained adapter with its own configuration, rate limiting, and health monitoring.
- Core Component: Integration engine and adapter registry
- Data Flow: External API → Adapter → Normalisation → Core Processing → Response → Adapter → External API
- Integration Points: REST APIs, webhooks, OAuth2, rate limiters, circuit breakers
Configuration Reference
Key configuration parameters for this system:
| Parameter | Type | Default | Description |
|---|---|---|---|
| integration_timeout | integer | 15000 | API call timeout in milliseconds |
| rate_limit_rpm | integer | 60 | Maximum requests per minute |
| circuit_breaker_threshold | integer | 5 | Failure count before circuit opens |
Figure 2: Integration architecture — component interaction and data flow.
Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| API rate limit exceeded | High request volume exceeding provider limits | Implement request queuing or increase rate_limit_rpm |
| Adapter connection failure | Provider API outage or credential expiry | Check provider status page and rotate credentials |
This component is part of the RAIA (Real estate Artificial Intelligence Agent) platform mono-repo. Implementation details, API contracts, and integration tests are available in the repository.