```yaml
product: AlterLab
title: AP News 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-20
canonical_facts:
  - "Get structured AP News data via API using AlterLab's Extract API. Define a JSON schema for headline, author, date and receive validated output — no parsing needed."
source_url: https://alterlab.io/blog/ap-news-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
To get structured AP News data via API, use AlterLab's Extract API with a defined JSON schema for the fields you need (headline, author, etc.). Simply POST the article URL and schema to receive validated, typed JSON output — no HTML parsing required. This approach handles anti-bot measures and delivers ready-to-use data for pipelines.

## Why use AP News data?
AP News provides timely, authoritative coverage across global events, business, and technology. Extracting structured data enables:
- **AI training**: Feed NLP models with real headlines and summaries for sentiment analysis or topic modeling.
- **Analytics**: Track keyword frequency or entity mentions over time to identify emerging trends.
- **Content enrichment**: Augment internal datasets with verified news metadata for recommendation systems.

## What data can you extract?
From publicly accessible AP News article pages, you can reliably extract:
- `headline`: The main title of the article
- `author`: Byline or reporting entity
- `published_date`: ISO timestamp of publication
- `source`: Typically "Associated Press" or wire service credit
- `summary`: Lead paragraph or abstract
These fields appear consistently in article metadata and are safe to extract as public information.

## The extraction approach
Direct HTTP requests to apnews.com return HTML that requires fragile parsing. Selectors break when AP News updates its frontend, and anti-bot measures (like JavaScript challenges) necessitate headless browsers — adding maintenance overhead. AlterLab's data API solves this by:
- Automatically handling JavaScript rendering and proxy rotation
- Applying your JSON schema to extract only specified fields
- Returning typed, validated output ready for downstream consumption
This shifts the burden from HTML wrangling to data utilization.

## Quick start with AlterLab Extract API
Begin by installing the AlterLab SDK ([getting started guide](/docs/quickstart/installation)). The Extract API converts a URL and schema into structured JSON.

```python title="extract_apnews-com.py" {5-12}
import alterlab

client = alterlab.Client("YOUR_API_KEY")

schema = {
  "type": "object",
  "properties": {
    "headline": {
      "type": "string",
      "description": "The headline field"
    },
    "author": {
      "type": "string",
      "description": "The author field"
    },
    "published_date": {
      "type": "string",
      "description": "The published date field"
    },
    "source": {
      "type": "string",
      "description": "The source field"
    },
    "summary": {
      "type": "string",
      "description": "The summary field"
    }
  }
}

result = client.extract(
    url="https://apnews.com/example-article",
    schema=schema,
)
print(result.data)
```

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://apnews.com/example-article",
    "schema": {"properties": {"headline": {"type": "string"}, "author": {"type": "string"}, "published_date": {"type": "string"}}}
  }'
```

For batch processing, use async jobs:
```python title="batch.py"
import asyncio
import alterlab

async def extract_article(url, schema):
    client = alterlab.Client("YOUR_API_KEY")
    return await client.extract_async(url=url, schema=schema)

async def main():
    urls = [
        "https://apnews.com/article1",
        "https://apnews.com/article2",
        "https://apnews.com/article3"
    ]
    schema = {"type": "object", "properties": {"headline": {"type": "string"}}}
    tasks = [extract_article(url, schema) for url in urls]
    results = await asyncio.gather(*tasks)
    for r in results:
        print(r.data)

if __name__ == "__main__":
    asyncio.run(main())
"
```

## Define your schema
The JSON schema parameter tells AlterLab exactly which fields to extract and their expected types. In the Python example above:
- Each property specifies `type: string` (AlterLab also supports numbers, booleans, arrays)
- The `description` field aids model understanding but isn't required for validation
- AlterLab validates the LLM's output against this schema before returning data
If the extracted data doesn't match (e.g., a number where a string is expected), the API returns a validation error — preventing malformed data from entering your pipeline.

## Handle pagination and scale
For high-volume extraction:
1. **Batching**: Group 10-50 URLs per async job to optimize throughput
2. **Rate limiting**: AlterLab enforces polite defaults; adjust concurrency based on your /pricing tier
3. **Error handling**: Implement retries with exponential backoff for transient 429s
4. **Cost estimation**: Use the `/v1/estimate` endpoint to preview expenses before large batches
Remember: AlterLab manages infrastructure scaling, but you remain responsible for respecting AP News's crawl-delay in robots.txt and implementing application-level throttling.

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

## Key takeaways
- Structured output via schema eliminates brittle HTML parsing
- Validation ensures data consistency for ML models and analytics
- AlterLab handles compliance complexity for public data extraction
- Cost scales linearly with usage — see [pricing](/pricing) for details
- Start small: extract single articles before scaling to pipelines

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

## Frequently Asked Questions

### Is there an official AP News data API?

AP News offers limited APIs for partners but no public self-service option for arbitrary article extraction. AlterLab provides structured JSON access to publicly available news data via schema-defined extraction, handling compliance and anti-bot measures.

### What AP News data can I extract with AlterLab?

Publicly available fields like headline, author, published_date, source, and summary from article pages. AlterLab validates output against your JSON schema, ensuring typed, consistent data without HTML parsing fragility.

### How much does AP News data extraction cost?

AlterLab charges per extraction based on complexity, clamped between $0.001 and $0.50. No minimums or expiration — pay only for what you use. See pricing for detailed estimates based on your schema and volume.

## Related

- [TechCrunch Data API: Extract Structured JSON in 2026](<https://alterlab.io/blog/techcrunch-data-api-extract-structured-json-in-2026>)
- [How to Scrape Nordstrom Data: Complete Guide for 2026](<https://alterlab.io/blog/how-to-scrape-nordstrom-data-complete-guide-for-2026>)
- [How to Scrape Zara Data: Complete Guide for 2026](<https://alterlab.io/blog/how-to-scrape-zara-data-complete-guide-for-2026>)