```yaml
product: AlterLab
title: PubMed Data API: Extract Structured JSON in 2026
category: Tutorials
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
last_updated: 2026-07-28
canonical_facts:
  - "Learn how to extract structured JSON from PubMed using AlterLab's data API — schema-driven, accurate, and ready for AI pipelines in 2026."
source_url: https://alterlab.io/blog/pubmed-data-api-extract-structured-json-in-2026
```

# PubMed Data API: Extract Structured JSON in 2026

## TL;DR
Use AlterLab's Extract API to get structured JSON from PubMed pages by posting a URL and a JSON schema. The service handles anti‑bot measures, returns typed data matching your schema, and requires no HTML parsing. Ideal for building reliable data pipelines for AI training, analytics, or competitive intelligence.

> This guide covers extracting publicly accessible data. Always review a site's robots.txt and Terms of Service before scraping.

## Why use PubMed data?
PubMed is the largest free repository of biomedical literature, offering millions of records that power diverse workflows:
- **AI training**: Collect abstracts and titles to fine‑tune language models on domain‑specific text.
- **Analytics**: Track research trends over time by aggregating publication counts per journal or year.
- **Competitive intelligence**: Monitor competitors’ recent publications to identify emerging technologies or gaps.

## What data can you extract?
From a typical PubMed article page you can pull the following publicly available fields:
- **title**: The article headline.
- **authors**: List of contributor names.
- **abstract**: The structured summary.
- **journal**: Publication venue name.
- **year**: Publication date (often extractable as a string).
- **doi**: Digital Object Identifier for cross‑referencing.

Because AlterLab returns data that conforms to a JSON schema you provide, you receive exactly the fields you asked for, with correct types, and no need for brittle regex or XPath logic.

## The extraction approach
Attempting to scrape PubMed with raw HTTP requests and HTML parsing runs into several obstacles:
- Frequent UI changes break CSS selectors.
- JavaScript‑rendered content requires a headless browser.
- Anti‑bot mechanisms (rate limits, CAPTCHAs) demand rotating proxies and retry logic.
- Maintaining parsers at scale consumes engineering effort that could be spent on core product work.

A data API like AlterLab abstracts these concerns. You specify the desired output shape; the platform handles retrieval, rendering, anti‑bot bypass, and validation. The result is predictable, typed JSON that integrates directly into downstream systems.

## Quick start with AlterLab Extract API
First, install the Python SDK (or use cURL directly). The quickstart guide explains installation and authentication.

```python title="extract_pubmed-ncbi-nlm-nih-gov.py" {5-12}
import alterlab

client = alterlab.Client("YOUR_API_KEY")

schema = {
  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "description": "The title field"
    },
    "authors": {
      "type": "string",
      "description": "The authors field"
    },
    "abstract": {
      "type": "string",
      "description": "The abstract field"
    },
    "journal": {
      "type": "string",
      "description": "The journal field"
    },
    "year": {
      "type": "string",
      "description": "The year field"
    },
    "doi": {
      "type": "string",
      "description": "The doi field"
    }
  }
}

result = client.extract(
    url="https://pubmed.ncbi.nlm.nih.gov/34567890/",
    schema=schema,
)
print(result.data)
```

The highlighted lines (5‑12) show the schema definition and the extract call. The response `result.data` is a Python dict that matches the schema exactly.

Equivalent cURL request:

```bash title="Terminal"
curl -X POST https://api.alterlab.io/v1/extract \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://pubmed.ncbi.nlm.nih.gov/34567890/",
    "schema": {
      "properties": {
        "title": {"type": "string"},
        "authors": {"type": "string"},
        "abstract": {"type": "string"},
        "journal": {"type": "string"},
        "year": {"type": "string"},
        "doi": {"type": "string"}
      }
    }
  }'
```

Both examples return JSON like:

```json
{
  "title": "Deep learning for protein structure prediction",
  "authors": "Smith J; Lee A; Patel R",
  "abstract": "We present a novel architecture...",
  "journal": "Nature Methods",
  "year": "2023",
  "doi": "10.1038/s41592-023-01800-5"
}
```

## Define your schema
The Extract API expects a JSON Schema draft‑07 document under the `schema` key. You can describe nested objects, arrays, enums, or formats (e.g., `"format": "date"`). AlterLab validates the extracted content against this schema before returning it, guaranteeing that every field exists and is of the correct type. If a field cannot be found, its value will be `null` (unless you mark it `"required"`). This contract‑first approach eliminates guesswork and makes versioning your extraction pipeline straightforward.

## Handle pagination and scale
For bulk extraction—say, all articles matching a query—you’ll need to iterate over result pages. PubMed’s search results page includes a “Next” link; you can fetch each page, extract the list of article URLs, then call the Extract API in parallel.

```python title="batch_pubmed_extract.py" {8-15}
import asyncio
import alterlab
from typing import List

client = alterlab.Client("YOUR_API_KEY")

async def extract_one(url: str) -> dict:
    schema = {"type": "object", "properties": {"title": {"type": "string"}}}
    resp = await client.extract_async(url=url, schema=schema)
    return resp.data

async def main(urls: List[str]) -> List[dict]:
    tasks = [extract_one(u) for u in urls]
    return await asyncio.gather(*tasks)

# Example: first 50 search result URLs
search_urls = [f"https://pubmed.ncbi.nlm.nih.gov/?term=cancer&page={i}" for i in range(1, 6)]
# In practice you would parse each search page to get article links, then call main()
```

The SDK’s `extract_async` method enables non‑blocking I/O, letting you process hundreds of URLs with minimal latency. Adjust concurrency based on your plan; see the pricing page for rate‑limit details and cost estimates.

## Key takeaways
- AlterLab’s Extract API turns any public PubMed page into typed JSON with a single POST.
- Define a JSON schema to get exactly the fields you need, validated and ready for consumption.
- The platform manages rendering, anti‑bot evasion, and scaling so you can focus on data‑driven product work.
- Always respect PubMed’s robots.txt and Terms of Service; this guide covers only publicly accessible data.

- **99.2%** — Extraction Accuracy
- **1.4s** — Avg Response Time
- **100%** — Typed JSON Output

1. **Define Schema** — 
2. **Call Extract API** — 
3. **Receive Typed JSON** — 

<div data-infographic="try-it" data-url="https://pubmed.ncbi.nlm.nih.gov" data-description="Extract structured academic data from PubMed"></div>
```

## Frequently Asked Questions

### Is there an official PubMed data API?

PubMed offers E-utilities for programmatic access to bibliographic records, but they return XML/JSON with limited field control. AlterLab provides a flexible data API that lets you define exactly which fields you need as typed JSON, simplifying integration for AI and analytics workflows.

### What PubMed data can I extract with AlterLab?

You can extract any publicly visible fields such as title, authors, abstract, journal, publication year, and DOI by defining a JSON schema. The platform returns validated, typed output that matches your specification, eliminating post‑processing parsing.

### How much does PubMed data extraction cost?

AlterLab charges per successful extraction, with costs clamped between $0.001 and $0.50 per call. There are no minimums, no expiration on balances, and you only pay for what you use — see the pricing page for details.

## Related

- [Build a Price Monitor with AlterLab + Supabase](<https://alterlab.io/blog/price-monitor-alterlab-supabase>)
- [How to Scrape Without Getting Blocked: The Complete Guide](<https://alterlab.io/blog/how-to-scrape-without-getting-blocked>)
- [arXiv Data API: Extract Structured JSON in 2026](<https://alterlab.io/blog/arxiv-data-api-extract-structured-json-in-2026>)