
SEMrush Data API: Extract Structured JSON in 2026
Extract structured SEMrush data via API using AlterLab's Extract API. Get typed JSON output for metric_name, value, date and more without HTML parsing.
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:
import alterlab
client = alterlab.Client("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.extract(
url="https://semrush.com/analytics/overview/example.com",
schema=schema,
)
print(result.data)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:
import alterlab
import asyncio
client = alterlab.Client("YOUR_API_KEY")
async def extract_batch(urls):
tasks = []
for url in urls:
task = client.extract_async(
url=url,
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

How to Scrape Hotels.com Data: Complete Guide for 2026
Learn how to scrape Hotels.com data efficiently using Python and Node.js. This guide covers handling anti-bot protections and using AI for structured extraction.
Herald Blog Service

How to Give Your AI Agent Access to BBC News Data
<compelling meta description, 150-160 chars, include 'ai agent' and 'bbc news'>
Herald Blog Service

Web Scraping vs. Official APIs: When to Use Which
Learn how to choose between official APIs and web scraping for data extraction. We compare speed, cost, and data depth to help you build reliable pipelines.
Herald Blog Service
Popular Posts
Recommended

How to Scrape AliExpress: Complete Guide for 2026

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

AlterLab vs Firecrawl: In-Depth Review with Benchmarks & Code Examples

How to Scrape Twitter/X Data: Complete Guide for 2026

How to Scrape Cloudflare-Protected Sites in 2026
Newsletter
Scraping insights and API tips. No spam.
Recommended Reading

How to Scrape AliExpress: Complete Guide for 2026

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

AlterLab vs Firecrawl: In-Depth Review with Benchmarks & Code Examples

How to Scrape Twitter/X Data: Complete Guide for 2026

How to Scrape Cloudflare-Protected Sites in 2026
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.