Have you ever wanted to automatically check if your website is healthy — broken links, SEO issues, and performance problems — all in one script?
In this tutorial, I'll show you how to build a website health monitor using three free APIs. The entire script is under 50 lines of Python.
What We're Building
A script that takes a URL and returns:
- SEO score (0-100) with critical issues flagged
- Broken links found across the site
- Response time and performance metrics
All from three API calls. No browser automation, no Selenium, no headless Chrome setup.
Prerequisites
You'll need:
- Python 3.6+
- A free RapidAPI account (sign up here)
- Subscribe to these free APIs:
The Script
import requests
import sys
import json
API_KEY = 'your-rapidapi-key-here'
HEADERS = {
'x-rapidapi-key': API_KEY,
'x-rapidapi-host': ''
}
def check_seo(url):
HEADERS['x-rapidapi-host'] = 'seo-audit8.p.rapidapi.com'
r = requests.get(
'https://seo-audit8.p.rapidapi.com/api/seo',
headers=HEADERS, params={'url': url}, timeout=30
)
data = r.json()
score = data.get('score', '?')
grade = data.get('grade', '?')
issues = data.get('issues', [])
print(f'SEO Score: {score}/100 (Grade {grade})')
if issues:
print(f' Issues: {len(issues)} found')
for issue in issues[:3]:
print(f' - {issue}')
return data
def check_links(url):
HEADERS['x-rapidapi-host'] = 'dead-link-checker.p.rapidapi.com'
r = requests.get(
'https://dead-link-checker.p.rapidapi.com/api/deadlinks',
headers=HEADERS, params={'url': url, 'max_pages': '5'},
timeout=120
)
data = r.json()
broken = data.get('broken_count', 0)
total = data.get('total_links_checked', 0)
score = data.get('summary', {}).get('health_score', '?')
print(f'Links: {total} checked, {broken} broken (Health: {score}%)')
for bl in data.get('broken_links', [])[:5]:
print(f' [{bl["status"]}] {bl["url"]}')
return data
if __name__ == '__main__':
url = sys.argv[1] if len(sys.argv) > 1 else 'https://example.com'
print(f'\n=== Website Health Check: {url} ===\n')
check_seo(url)
print()
check_links(url)
print('\nDone.')
Running It
pip install requests
python health_check.py https://yoursite.com
Output:
=== Website Health Check: https://yoursite.com ===
SEO Score: 78/100 (Grade C)
Issues: 4 found
- Missing meta description
- Images without alt text (3)
- No Open Graph tags
Links: 47 checked, 2 broken (Health: 96%)
[404] https://yoursite.com/old-page
[500] https://external-site.com/api
Done.
Making It Useful
Here are three ways to extend this:
1. Run on a Schedule (cron)
# Check every Monday at 9am
0 9 * * 1 python3 /path/to/health_check.py https://yoursite.com >> /var/log/health.log
2. Send Alerts
Add a simple email or Slack notification when broken links are found:
def alert_if_broken(data):
if data.get('broken_count', 0) > 0:
# Send to Slack webhook, email, etc.
broken = data['broken_links']
msg = f'Found {len(broken)} broken links!\n'
msg += '\n'.join(f' [{b["status"]}] {b["url"]}' for b in broken)
print(f'ALERT: {msg}')
3. Track Score Over Time
Log the SEO score and broken link count to a CSV for trend analysis:
import csv
from datetime import datetime
def log_score(url, seo_score, broken_count):
with open('health_log.csv', 'a') as f:
writer = csv.writer(f)
writer.writerow([datetime.now().isoformat(), url, seo_score, broken_count])
Why Use APIs Instead of Building From Scratch?
You could write a link crawler with requests and BeautifulSoup. But consider:
- Link checking needs to handle redirects, timeouts, JavaScript-rendered pages, and rate limiting across many domains
- SEO auditing requires knowledge of 50+ checks across meta tags, headings, images, mobile-friendliness, and crawlability
- Maintenance — the rules for what constitutes 'good SEO' change regularly
Using an API lets you focus on your application logic while the API handles the complexity.
Resources
- Dead Link Checker API — free tier: 10 scans/day
- SEO Audit API — free tier: 10 audits/day
- Screenshot API — capture pages as PNG
All three APIs have free tiers, so you can start building immediately. PRO and ULTRA tiers are available if you need higher rate limits for production use.
What would you add to your health monitor? Drop a comment below.
Top comments (0)