# Hacker News Scraper - Stories, Comments, Show HN & Ask HN (`scrolahdata/hacker-news-scraper`) Actor

Hacker News scraper (HN scraper): Hacker News search for stories and comments by keyword, points and date; front page, Show HN, Ask HN, Hacker News jobs; full Hacker News comments threads; user karma. $0.20 per 1,000 items. Ycombinator news data.

- **URL**: https://apify.com/scrolahdata/hacker-news-scraper.md
- **Developed by:** [Leping Gong](https://apify.com/scrolahdata) (community)
- **Categories:** News, Developer tools, Social media
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.16 / 1,000 items

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Hacker News Scraper — Stories, Comments, Front Page, Show HN & Users

Scrape **Hacker News (news.ycombinator.com)** fast and cheap. **Search stories and comments** by keyword, points, comment count, date and author, get the **front page, New, Best, Ask HN, Show HN and Jobs** lists with ranks, **full comment threads**, and **user karma**. Built on the official HN API and the Algolia HN Search API — no browser, no blocking, no login.

### Why this scraper?

- 🔎 **Search all of HN history** — stories, comments, Ask HN, Show HN, jobs, polls. Filter by **min points**, **min comments**, **date range** and **author**. Sort by relevance or date
- ♾️ **No 1,000-result cap** — date-sorted searches walk back in time, so you get *every* match (e.g. all stories mentioning your product since 2015)
- 📰 **Live lists** — front page (top), new, best, Ask HN, Show HN, jobs with rank, points and comment counts
- 💬 **Comment threads** — every comment of a story with author, depth and parent, nested replies flattened
- 👤 **Users** — karma, about, account creation date, number of submissions
- 🧹 Clean plain text (HTML removed, links kept) or original HTML
- ⚡ **$0.20 per 1,000 items**, thread comments **$0.10 per 1,000**, no start fee, no proxy needed
- 💸 Deleted items and unknown users return a free error row

### Input

```json
{
  "searchQueries": ["rust", "openai"],
  "contentType": "story",
  "sort": "date",
  "maxItemsPerQuery": 2000,
  "minPoints": 10,
  "dateFrom": "2025-01-01",
  "lists": ["top", "show"],
  "maxCommentsPerStory": 20,
  "itemUrls": ["https://news.ycombinator.com/item?id=8863"],
  "users": ["pg"]
}
```

### Output

Story:

```json
{
  "type": "story",
  "id": 8863,
  "title": "My YC app: Dropbox - Throw away your USB drive",
  "url": "http://www.getdropbox.com/u/2/screencast.html",
  "domain": "getdropbox.com",
  "hnUrl": "https://news.ycombinator.com/item?id=8863",
  "author": "dhouston",
  "points": 104,
  "numComments": 71,
  "createdAt": "2007-04-04T19:16:40Z"
}
```

Comment:

```json
{"type": "comment", "id": 9007, "author": "vlad", "text": "Drew, this is awesome! ...", "createdAt": "2007-04-05T01:48:11Z", "parentId": 8865, "storyId": 8863, "storyTitle": "My YC app: Dropbox - Throw away your USB drive", "depth": 2}
```

User: `{"type": "user", "username": "pg", "karma": 157316, "about": "Bug fixer.", "createdAt": "2006-10-09T18:21:32Z", "submissionsCount": 15000}`

### Use cases

- **Brand & competitor monitoring** — every HN mention of your product, domain or competitors (schedule daily runs with a date filter)
- **Developer sentiment & market research** — what developers say about a tool, language or startup
- **Trend analysis** — top stories by topic and points over time
- **Launch tracking** — Show HN posts, their points and comments
- **Hiring & jobs data** — HN job posts and "Who is hiring" comment threads
- **AI & NLP datasets** — clean comment text with threads for LLM training and RAG
- **Lead research** — users with karma and bios

### Limits

Relevance-sorted search returns at most 1,000 items per query (Algolia limit) — use **Date** sort for more. Lists contain what HN currently shows (up to 500 for top/new/best).

### Pricing

- **Item** — per story, search comment or user row
- **Thread comment** — per comment row from a story's comment thread

Discounts for Apify Silver, Gold and higher plans.

### How to use Hacker News Scraper

1. Click **Try for free** (the Apify free plan includes monthly credit).
2. Fill in the input — the example input is already pre-filled, so you can just press **Start**.
3. Download results as **JSON, CSV, Excel or HTML**, or open them in the dataset table view.

### Integrations & API

- **API** — run it from Python, Node.js or any language with the Apify API / `apify-client` and get results as JSON.
- **Schedules & monitoring** — run it hourly, daily or weekly and get only fresh data.
- **Zapier, Make, n8n, Google Sheets, Slack, webhooks** — send results to your tools automatically.
- **AI agents (MCP)** — use it from Claude, ChatGPT, Cursor or any MCP client through the Apify MCP server.

### FAQ

**Do I need an API key, login or cookies?** No. It reads publicly available data only.

**How much does it cost?** You pay only for results (see the Pricing tab), no start fee. Error rows are free. Higher Apify plans get automatic discounts.

**Is it legal?** It collects public data only. Make sure your use complies with the website's terms and data-protection laws (e.g. GDPR) — don't collect personal data without a legal basis.

**Something doesn't work or you need a feature?** Open an issue in the **Issues** tab — we usually reply within a day.

### More from ScrolahData

- [Bluesky Scraper](https://apify.com/scrolahdata/bluesky-scraper)
- [Substack Scraper](https://apify.com/scrolahdata/substack-scraper)
- [Telegram Channel Scraper](https://apify.com/scrolahdata/telegram-channel-scraper)
- [Google News Scraper](https://apify.com/scrolahdata/google-news-scraper)
- [Google Autocomplete Keyword Tool](https://apify.com/scrolahdata/google-autocomplete-keyword-tool)

# Actor input Schema

## `searchQueries` (type: `array`):

Keywords to search Hacker News stories or comments for, e.g. "rust", "openai", "yourcompany.com".

## `lists` (type: `array`):

Current stories from HN lists, with their rank.

## `itemUrls` (type: `array`):

Item URLs like https://news.ycombinator.com/item?id=8863 or IDs. Outputs the item and its full comment thread.

## `users` (type: `array`):

HN usernames or user URLs. Outputs karma, about, account date.

## `contentType` (type: `string`):

What to search.

## `sort` (type: `string`):

Relevance returns up to 1,000 items; date returns all matches.

## `maxItemsPerQuery` (type: `integer`):

Maximum stories/comments per search query.

## `minPoints` (type: `integer`):

Only items with at least this many points (stories).

## `minComments` (type: `integer`):

Only stories with at least this many comments.

## `dateFrom` (type: `string`):

Only items created on or after this date.

## `dateTo` (type: `string`):

Only items created before this date.

## `author` (type: `string`):

Only items by this username (works with or without search queries).

## `maxItemsPerList` (type: `integer`):

Items from each HN list (front page = 30).

## `maxCommentsPerStory` (type: `integer`):

Also output the comment thread of every scraped story (nested comments flattened with depth). 0 = off. For item URLs, 0 means all comments.

## `keepHtml` (type: `boolean`):

Keep original HTML in text fields instead of plain text.

## `maxConcurrency` (type: `integer`):

Parallel requests.

## `proxyConfiguration` (type: `object`):

Not needed — official public APIs.

## Actor input object example

```json
{
  "searchQueries": [
    "python"
  ],
  "contentType": "story",
  "sort": "relevance",
  "maxItemsPerQuery": 100,
  "minPoints": 0,
  "minComments": 0,
  "maxItemsPerList": 30,
  "maxCommentsPerStory": 0,
  "keepHtml": false,
  "maxConcurrency": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchQueries": [
        "python"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrolahdata/hacker-news-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchQueries": ["python"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("scrolahdata/hacker-news-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchQueries": [
    "python"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call scrolahdata/hacker-news-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrolahdata/hacker-news-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/X9bygW5u9mnYVws7i/builds/ZIAKbjn6EfIqwOItt/openapi.json
