
Hacker News Data API: Extract Structured JSON in 2026
Hacker 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...
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.
Run a live request from this page. No sign-up needed.
TL;DR
To get structured Hacker News data via API, use AlterLab's Extract endpoint with a JSON schema defining your desired fields (title, author, published_date, tags, URL). Pass the schema and target URL to receive validated, typed JSON output—eliminating fragile HTML parsing. The process requires only two lines of Python code after setup.
Why use Hacker News data?
Hacker News provides real-time insights into tech trends, making it valuable for:
- AI training datasets: Collecting technical article titles and discussions for natural language processing models
- Competitive intelligence: Monitoring emerging technologies and startup announcements mentioned in threads
- Content aggregation: Building tech news feeds or trend analysis tools for developer communities
What data can you extract?
From public Hacker News pages, you can extract these structured fields:
title: The headline of the story or discussionauthor: The username of the submitterpublished_date: Timestamp when the item was postedtags: Associated categories or keywords (if visible in the snippet)url: Direct link to the external article or internal discussion
All fields are publicly visible on the news.ycombinator.com homepage and item pages. AlterLab's AI identifies and extracts them based on your schema definition.
The extraction approach
Raw HTTP requests combined with HTML parsing fail frequently on Hacker News due to:
- Dynamic content loaded via JavaScript
- Frequent frontend updates breaking CSS selectors
- Anti-bot measures requiring session handling
A data API approach solves these by:
- Handling JavaScript rendering and anti-bot challenges automatically
- Returning structured data matching your schema instead of raw HTML
- Providing built-in retry logic and rate limit management
- Eliminating the need for maintenance-heavy parsing code
Quick start with AlterLab Extract API
First, install the AlterLab Python client and follow the Getting started guide. Then extract data with minimal code:
from alterlab import AlterLabSync
client = AlterLabSync("YOUR_API_KEY")
schema = {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The title field"
},
"author": {
"type": "string",
"description": "The author field"
},
"published_date": {
"type": "string",
"description": "The published date field"
},
"tags": {
"type": "string",
"description": "The tags field"
},
"url": {
"type": "string",
"description": "The url field"
}
}
}
result = client.scrape(
url="https://news.ycombinator.com/item?id=40000000",
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://news.ycombinator.com/item?id=40000000",
"schema": {"properties": {"title": {"type": "string"}, "author": {"type": "string"}, "published_date": {"type": "string"}}}
}'Both examples return structured JSON like:
{
"title": "Example Tech Article",
"author": "techblogger",
"published_date": "2026-03-15T14:30:00Z",
"tags": ["programming", "ai"],
"url": "https://example.com/tech-article"
}Define your schema
The schema parameter drives AlterLab's extraction accuracy. Key principles:
- Type safety: Define
string,number,boolean, orarraytypes for each field - Description hints: Help the AI understand context (e.g., "ISO 8601 timestamp")
- Required fields: Omit
"required"array to allow partial extraction when data is missing - Nested objects: Extract complex structures like comment threads using
objecttypes
AlterLab validates output against your schema, returning only matching fields. If the AI cannot find a field, it returns null for that key—never inventing data.
Handle pagination and scale
For extracting multiple Hacker News pages:
- Batch processing: Use async requests with
alterlab.extract_batch()for concurrent processing - Rate limiting: AlterLab automatically respects Hacker News's crawl-delay; adjust via
max_concurrencyparameter - Error handling: Check
result.successflag andresult.errorfor failed extractions - Cost optimization: See AlterLab pricing for volume discounts—pay only for successful extractions
Example async batch job:
from alterlab import AlterLab
import asyncio
client = AlterLab("YOUR_API_KEY")
urls = [
"https://news.ycombinator.com",
"https://news.ycombinator.com/news?p=2",
"https://news.ycombinator.com/news?p=3"
]
schema = {
"type": "object",
"properties": {
"title": {"type": "string"},
"url": {"type": "string"}
}
}
async def extract_all():
tasks = [
client.scrape(url=url, extraction_schema=schema)
for url in urls
]
results = await asyncio.gather(*tasks)
for result in results:
if result.success:
print(result.data)
asyncio.run(extract_all())Key takeaways
- AlterLab's Extract API converts public web pages into typed JSON without parsing fragility
- Define your exact data needs via JSON schema for validated, consistent output
- The service handles JavaScript, anti-bot measures, and rate limiting automatically
- Start with a single endpoint call; scale to batches using async patterns
- Always verify compliance with robots.txt and Terms of Service before extraction
Begin extracting structured Hacker News data today—visit the Extract API docs for full reference.
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

Ethical Web Scraping: Robots.txt, Rate Limits, and ToS

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

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

Ethical Web Scraping: Robots.txt, Rate Limits, and ToS

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

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.