SEMrush Data API: Extract Structured JSON in 2026
Tutorials

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.

4 min read
2 views

AlterLab handles this automaticallyscrape any URL with one API call. No infrastructure required.

Try it free

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 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:

Python
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:

Bash
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:

Python
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., value as string won't return numbers)
  • Required fields are present
  • Descriptions guide the extraction model For SEMrush data, a typical schema might specify:
JSON
{
  "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:

  1. Batching: Group URLs into chunks of 50-100 to optimize throughput
  2. Rate limiting: AlterLab automatically respects Retry-After headers; implement client-side backoff for 429 responses
  3. Async jobs: Use the /v1/extract/async endpoint for non-blocking processing (see batch example above)
  4. 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.
Share

Was this article helpful?

Frequently Asked Questions

SEMrush offers official APIs for certain products like Domain Analytics, but these require specific subscriptions and have rate limits. AlterLab provides an alternative for extracting publicly available data from SEMrush pages as structured JSON without needing official API access.
You can extract publicly listed data fields such as metric_name, value, date, source, and category from SEMrush pages. AlterLab validates and returns this data as typed JSON based on your defined schema, eliminating the need for HTML parsing.
AlterLab uses pay-as-you-go pricing with no minimums or expired credits. Extraction costs are clamped between $0.001 and $0.50 per request, with detailed estimates available via the Extract API's cost preview feature.