DEV Community

2x lazymac
2x lazymac

Posted on

SEO Analyzer API: Automate On-Page Audits for Your SaaS

Manually auditing page titles, meta descriptions, heading structure, and canonical tags is tedious at scale. Here's how to automate on-page SEO audits for your entire SaaS.

What a Full SEO Audit Checks

import requests

resp = requests.post("https://api.lazy-mac.com/seo-analyzer/audit", json={
    "url": "https://your-site.com/pricing",
    "checks": [
        "title",           # Length, keyword presence
        "meta_description", # Length, CTA presence
        "headings",        # H1 count, hierarchy
        "images",          # Alt text missing
        "canonical",       # Canonical URL correct
        "structured_data", # JSON-LD present
        "page_speed",      # Basic load indicators
        "mobile_friendly"  # Viewport meta present
    ]
})

audit = resp.json()
Enter fullscreen mode Exit fullscreen mode

Sample response:

{
  "url": "https://your-site.com/pricing",
  "score": 72,
  "issues": [
    {
      "check": "title",
      "severity": "warning",
      "message": "Title is 73 characters (recommended: 50-60)",
      "current": "Pricing — Full Feature Comparison | YourSaaS Platform",
      "suggestion": "Pricing | YourSaaS — Plans from $9/month"
    },
    {
      "check": "images",
      "severity": "error",
      "message": "3 images missing alt text",
      "elements": ["hero-image.jpg", "feature-1.png", "testimonial.webp"]
    }
  ],
  "passed": ["meta_description", "headings", "canonical", "mobile_friendly"]
}
Enter fullscreen mode Exit fullscreen mode

Bulk Audit for Your Entire Site

import requests

pages = [
    "/", "/pricing", "/features", "/blog", "/docs",
    "/about", "/contact", "/login", "/signup"
]
base_url = "https://your-site.com"

results = []
for page in pages:
    r = requests.post("https://api.lazy-mac.com/seo-analyzer/audit", json={
        "url": base_url + page,
        "checks": ["title", "meta_description", "headings", "canonical"]
    })
    data = r.json()
    results.append({"page": page, "score": data['score'], "issue_count": len(data['issues'])})

# Sort by worst score first
results.sort(key=lambda x: x['score'])
for r in results:
    print(f"Score {r['score']:3d} | {len(r['issue_count']):2d} issues | {r['page']}")
Enter fullscreen mode Exit fullscreen mode

CI Integration

# .github/workflows/seo-check.yml
- name: SEO Audit
  run: |
    SCORE=$(curl -s -X POST "https://api.lazy-mac.com/seo-analyzer/audit" \
      -H "Content-Type: application/json" \
      -d '{"url": "https://your-site.com", "checks": ["title","meta_description","headings"]}' \
      | jq '.score')
    if [ "$SCORE" -lt 60 ]; then echo "SEO score $SCORE below threshold"; exit 1; fi
Enter fullscreen mode Exit fullscreen mode

SEO Analyzer API | Full API store

Top comments (0)