
SEMrush Data API: Extract Structured JSON in 2026
This guide covers extracting publicly accessible data. Always review a site's robots.txt and Terms of Service before scraping. TL;DR Use AlterLab's Extract...
AlterLab handles this automatically — scrape any URL with one API call. No infrastructure required.
Try it freeThis guide covers extracting publicly accessible data. Always review a site's robots.txt and Terms of Service before scraping.
TL;DR
Use AlterLab's Extract API to get structured SEMrush data as typed JSON. Define a schema for fields like metric_name and value, POST the URL and schema, and receive validated output—no HTML parsing needed. Ideal for building reliable data pipelines.
Why use SEMrush data?
SEMrush contains valuable public data for competitive analysis. Engineers use it to:
- Train AI models on market trend datasets
- Build analytics dashboards tracking keyword visibility
- Feed competitive intelligence systems with real-time SERP metrics Accessing this data via API enables automation in data-driven workflows without manual exports.
What data can you extract?
From publicly available SEMrush pages, you can extract these core fields:
- metric_name: The specific metric being measured (e.g., "Organic Traffic", "Keyword Difficulty")
- value: The numeric or string value of the metric
- date: When the metric was recorded or last updated
- source: The specific SEMrush tool or report section origin
- category: Broad classification like "Domain Overview" or "Keyword Analytics" These fields form the foundation for time-series analysis and cross-domain comparisons. AlterLab ensures each field matches your schema's type definition, returning clean JSON ready for downstream processing.
The extraction approach
Raw HTTP requests combined with HTML parsing fail frequently on modern sites like SEMrush due to:
- Dynamic content loaded via JavaScript
- Frequent frontend framework updates breaking CSS selectors
- Anti-bot measures requiring header rotation and proxy management A data API like AlterLab handles these challenges through headless browsers, automatic retries, and structured extraction—delivering consistent JSON output where parsers would break. This shifts focus from maintenance to data utilization.
Quick start with AlterLab Extract API
Begin by installing the AlterLab SDK (Getting started guide). Here's how to extract SEMrush data with schema validation:
from alterlab import AlterLabSync
client = AlterLabSync("YOUR_API_KEY")
schema = {
"type": "object",
"properties": {
"metric_name": {
"type": "string",
"description": "The metric name field"
},
"value": {
"type": "string",
"description": "The value field"
},
"date": {
"type": "string",
"description": "The date field"
},
"source": {
"type": "string",
"description": "The source field"
},
"category": {
"type": "string",
"description": "The category field"
}
}
}
result = client.scrape(
url="https://semrush.com/analytics/overview/example.com",
extraction_schema=schema,
)
print(result["filtered_content"])The equivalent cURL request:
curl -X POST https://api.alterlab.io/v1/extract \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://semrush.com/analytics/overview/example.com",
"schema": {"properties": {"metric_name": {"type": "string"}, "value": {"type": "string"}, "date": {"type": "string"}}}
}'For batch processing, use asynchronous jobs:
from alterlab import AlterLab
import asyncio
client = AlterLab("YOUR_API_KEY")
async def extract_batch(urls):
tasks = []
for url in urls:
task = client.scrape(
url=url,
extraction_schema={"type": "object", "properties": {"metric_name": {"type": "string"}}}
)
tasks.append(task)
results = await asyncio.gather(*tasks)
return [r.data for r in results]
# Example usage
urls = [
"https://semrush.com/analytics/overview/site1.com",
"https://semrush.com/analytics/overview/site2.com"
]
data = asyncio.run(extract_batch(urls))Define your schema
The schema parameter is JSON Schema draft-07. AlterLab validates output against it, ensuring:
- Type safety (e.g.,
valueas string won't return numbers) - Required fields are present
- Descriptions guide the extraction model For SEMrush data, a typical schema might specify:
{
"type": "object",
"properties": {
"metric_name": {"type": "string", "minLength": 1},
"value": {"type": ["string", "number"]},
"date": {"type": "string", "format": "date"},
"source": {"type": "string"},
"category": {"type": "string", "enum": ["Domain Analytics", "Keyword Research"]}
},
"required": ["metric_name", "value", "date"]
}This guarantees your pipeline receives predictable data structures, reducing error handling complexity.
Handle pagination and scale
For large-scale extraction:
- Batching: Group URLs into chunks of 50-100 to optimize throughput
- Rate limiting: AlterLab automatically respects
Retry-Afterheaders; implement client-side backoff for 429 responses - Async jobs: Use the
/v1/extract/asyncendpoint for non-blocking processing (see batch example above) - Cost monitoring: Check extraction costs beforehand with the Extract API docs cost preview feature See AlterLab pricing for volume discounts—costs scale linearly with successful extractions, minimums apply only to enterprise commitments.
Key takeaways
- AlterLab's Extract API converts SEMrush page data into typed JSON via schema validation
- Avoid fragile parsers by letting the API handle JavaScript rendering and anti-bot measures
- Define precise schemas for fields like metric_name and value to ensure pipeline reliability
- Scale efficiently with async jobs and built-in rate limit handling
- Focus on data analysis, not extraction maintenance—your JSON output is ready for immediate use AlterLab // Web Data, Simplified.
Was this article helpful?
Frequently Asked Questions
Related Articles

Oxylabs Alternative: Practical Developer Guide for Web Scraping Pipelines
Build reliable scraping pipelines with anti-bot handling, auto-escalation, and monitoring using a practical AltLab-compatible solution. Follow the 3-step setup, integrate with your existing workflow, and control costs at $0.0002 per request.
Herald Blog Service

Python aiohttp vs. httpx for High-Throughput Web Scraping
A benchmark‑driven comparison of aiohttp and httpx for asynchronous scraping, with concrete numbers, code snippets, and guidance on when to choose each library.
Herald Blog Service

MCP Servers Explained: How AI Tools Access the Real-Time Web in 2026
Learn how Model Context Protocol servers enable AI agents to fetch live data via scraping APIs, with architecture, code examples, and best practices for 2026.
Herald Blog Service
Popular Posts
Recommended

Selenium Bot Detection: Why You Get Flagged and How to Fix It

Why Your Headless Browser Gets Detected (and How to Fix It)

Scraping E-Commerce Sites at Scale Without Getting Blocked

Playwright Stealth and Anti-Bot Techniques for RAG Pipelines

Mastering Playwright Stealth for Agentic Web Workflows
Newsletter
Scraping insights and API tips. No spam.
Recommended Reading

Selenium Bot Detection: Why You Get Flagged and How to Fix It

Why Your Headless Browser Gets Detected (and How to Fix It)

Scraping E-Commerce Sites at Scale Without Getting Blocked

Playwright Stealth and Anti-Bot Techniques for RAG Pipelines

Mastering Playwright Stealth for Agentic Web Workflows
Stay in the Loop
Get scraping insights, API tips, and platform updates. No spam — we only send when we have something worth reading.
Explore AlterLab
Web Scraping API Resources
Part of the Web Scraping API Documentation cluster
Complete API reference with 5-tier auto-escalation — Curl to challenge resolution.
Pillar pageConfigure Tier 4 browser rendering for SPAs and dynamic content.
Scrape pages behind login using session management.
Real success rates and cost data across all 5 tiers.
MCP Server, Python SDK, and Firecrawl-compatible API for AI agent workflows.