# Hacker News Comments Scraper (`deriverge/hacker-news-comments-scraper`) Actor

Every comment under the Hacker News stories you list, one row each with text, username, time, parent comment and depth, so threads can be rebuilt or read flat. Paste story links or IDs; a new-only mode returns just the comments added since your last run.

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

## Pricing

from $0.10 / 1,000 comments

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 Comments Scraper

Hacker News Comments Scraper returns the comments under the Hacker News stories you give it, one row per comment: the text, the commenter's username, when it was posted, the comment it replies to and its depth, so you can rebuild the tree or read the discussion flat. Paste story links such as `https://news.ycombinator.com/item?id=44567857` or bare IDs and click **Start**. Each story takes a single request, and the thread comes back up to the cap you set, 1,000 comments by default. It costs $0.20 per 1,000 comments on the Free plan ($0.10 on Business), and the $5 of monthly credit in Apify's Free plan covers about 25,000 comments.

### What data does it return?

| Field | Description |
|---|---|
| `id`, `hnUrl` | The comment's ID and its own page, such as `https://news.ycombinator.com/item?id=48434690`. |
| `storyId`, `storyTitle` | ID and title of the story the comment sits under. |
| `parentId` | ID of the comment this one answers, `null` when it replies to the story itself. |
| `depth` | Level in the thread: `0` under the story, `1` for an answer to that, and so on. For a comment link, the linked comment is `0`. The five threads in our test went 15 levels deep. |
| `author` | Hacker News username of the commenter. |
| `createdAt` | When the comment was posted, ISO 8601 in UTC. |
| `text` | The comment as plain text. Paragraph breaks become blank lines, quotes and links keep their visible text. |
| `type`, `key` | Always `comment`, and the key `comment:<id>` that new-only mode compares between runs. |

### How to scrape Hacker News comments

1. In **Stories**, enter one story per line, either as a link from news.ycombinator.com or as the number after `id=`, such as `44567857`. A link to a single comment returns that comment and the replies under it.
2. Set **Maximum comments per story**. It counts replies too, and the thread is read from the top, so a cap keeps the oldest comments with their replies.
3. Set **Maximum rows** if you want a cap for the whole run (20,000 by default), and click **Start**.
4. The comments land in the **Output** tab in thread order, each one followed by its replies, and you can export them as CSV, Excel or JSON. The `SUMMARY` record in the key-value store counts comments and lists links it could not use.

For the API:

```json
{
  "stories": [
    "https://news.ycombinator.com/item?id=44567857",
    "41523070"
  ],
  "maxCommentsPerStory": 5000
}
```

### Example output

A reply two levels deep in a June 2026 thread with 1,056 comments, read on 11 October 2026. The line starting with `>` quotes the comment it answers. The username is replaced with `hn_user`; the other values are as returned.

```json
{
  "type": "comment",
  "key": "comment:48434469",
  "id": 48434469,
  "storyId": 48434312,
  "storyTitle": "LLMs are eroding my software engineering career and I don't know what to do",
  "parentId": 48434423,
  "depth": 2,
  "author": "hn_user",
  "createdAt": "2026-06-07T13:10:35.000Z",
  "text": "> Exactly zero percent of the market is willing to pay for hand-built software.\n\nPeople are increasingly associating “AI art” with cheap slop. I wonder if the same will ever happen to programming.",
  "hnUrl": "https://news.ycombinator.com/item?id=48434469"
}
```

### How much does it cost to scrape Hacker News comments?

| | Free plan | Starter | Scale | Business |
|---|---|---|---|---|
| 1,000 comments | $0.20 | $0.16 | $0.13 | $0.10 |

You pay only for the events in the table. There is no start fee, and compute time and proxies are included.

Five large threads about language models, with 6,207 comments between them, cost $1.2414 on the Free plan and $0.6207 on Business. In new-only mode you pay only for comments posted since the previous run.

### Limits

- Comments on the same level come oldest first. That is the order of posting, which differs from the ranking Hacker News shows on the story page.
- The default cap of 1,000 comments per story cuts off busy threads: the largest of our five test threads had 1,627 comments. Raise **Maximum comments per story** to read them in full.
- Deleted comments are skipped. A reply to a deleted comment keeps that comment's ID in `parentId`.
- Story details such as points and the link are not part of the rows; `storyTitle` is the only story field. Hacker News Search Scraper returns stories with their numbers.
- A story that does not exist is named in the `notes` of the `SUMMARY` record and adds no rows.
- The five test threads, 6,207 comments in all, took 8.5 seconds on 11 October 2026.

### Following a live discussion

Save the input as a task, or give it a **Watch name**, turn on **Return only rows new since the last run** and schedule it every hour while a story is active. Each run returns only the comments that no earlier run of the watch returned. Keep **Maximum comments per story** above the size of the thread, because comments past it are not read. Comments that **Maximum rows** or your spending limit cut off are not counted as seen, and the next run returns them: a thread of 1,056 comments with **Maximum rows** at 400 came in three runs of 400, 400 and 256 on 11 October 2026.

### FAQ

#### Is it legal to scrape Hacker News comments?

Comments on Hacker News are public, and the actor reads them through the public Hacker News search API at hn.algolia.com without logging in. Each row holds the comment and the username it was posted under; profiles, karma and email addresses are not collected. You are responsible for how you use and quote the comments.

#### How do I rebuild the thread?

Every comment has `parentId` and `depth`. Comments with `parentId` set to `null` start the branches, and the rest attach to the comment named in `parentId`. For a flat reading order, sort by the row order of the dataset, which already follows the thread.

#### Where do I find the stories to read?

Hacker News Search Scraper finds stories by keyword, date and points, and its `id` column can be pasted straight into **Stories**.

### Related scrapers

- [Hacker News Search Scraper](https://apify.com/deriverge/hacker-news-search)
- [Hacker News Scraper](https://apify.com/deriverge/hacker-news-scraper)

### Support

This actor is built and maintained by deriverge s.r.o., a software company based in the Czech Republic. If a run fails or a field you need is missing, please open an issue in the **Issues** tab or write to us at info@deriverge.com. We respond in English and Czech. Runs can be scheduled in Apify Console or started from the **API** tab, which has examples for Python, JavaScript and cURL and works with Make, Zapier, n8n and the Apify MCP server. If the actor saves you time, a short review helps other people find it.

# Changelog

This Actor's version history is a separate document: https://apify.com/deriverge/hacker-news-comments-scraper/changelog.md

# Actor input Schema

## `stories` (type: `array`):

Hacker News item links (news.ycombinator.com/item?id=...) or numeric ids. A link to a single comment returns that comment and the replies under it.

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

Replies count towards the cap; the tree is walked from the top.

## `newOnly` (type: `boolean`):

Keeps a snapshot per watch name (or per saved task) and returns only comments that were not there before. Schedule it and you have a thread alert that bills only for new comments.

## `watchName` (type: `string`):

Name of the snapshot used by the new-only mode, for example "ai-alert". Runs from a saved task get a snapshot automatically even without a name.

## `maxItems` (type: `integer`):

Hard cap on returned rows in the run.

## Actor input object example

```json
{
  "stories": [
    "https://news.ycombinator.com/item?id=1"
  ],
  "maxCommentsPerStory": 1000,
  "newOnly": false,
  "maxItems": 20000
}
```

# Actor output Schema

## `rows` (type: `string`):

One row per comment with author, date, text, depth, parent and the story it belongs to.

## `changes` (type: `string`):

Comments that appeared since the previous snapshot of the same watch name or task.

## `summary` (type: `string`):

Counts per list and search term, what filters dropped, what was charged and notes.

# 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 = {
    "stories": [
        "https://news.ycombinator.com/item?id=1"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("deriverge/hacker-news-comments-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 = { "stories": ["https://news.ycombinator.com/item?id=1"] }

# Run the Actor and wait for it to finish
run = client.actor("deriverge/hacker-news-comments-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 '{
  "stories": [
    "https://news.ycombinator.com/item?id=1"
  ]
}' |
apify call deriverge/hacker-news-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,deriverge/hacker-news-comments-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/9ecS6b1himigBJRWU/builds/1R9sXkpsIDWue84YS/openapi.json
