# Hacker News Scraper: Stories, Search, Comments & Users (`winterlock/hacker-news-scraper`) Actor

Scrape Hacker News front page and new story lists, full-text search across every story and comment, whole comment threads, and user profiles. Uses the official Firebase and Algolia APIs. No key, no login.

- **URL**: https://apify.com/winterlock/hacker-news-scraper.md
- **Developed by:** [Alex Burton](https://apify.com/winterlock) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 story, comment or jobs

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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, Search, Comments & Users

Collect Hacker News data through its **two official free APIs** — the Firebase feed that powers the site and the Algolia index behind its search box. No key, no login, no HTML parsing.

| Mode | What you get |
|---|---|
| **Story lists** | Front page, newest, best, Ask HN, Show HN and Jobs, with a rank on every row |
| **Search** | Full-text search over every story and comment ever posted, with points, comment-count and date filters |
| **Item + comments** | Any story plus its whole reply tree, flattened with a depth number |
| **Users** | Karma, about text, join date and submission count |

### Why use this one

- **Both official APIs in one tool.** The Firebase API gives live, ranked lists; Algolia gives deep history and filtering. Most HN scrapers use only one and inherit its blind spot.
- **Search the full archive.** Points, comment count and date-range filters are passed straight through, so "every Show HN since January with 100+ points" is one run.
- **Comment trees that terminate.** The walk is breadth-first with a seen-set and hard caps, so a malformed reply chain can't spin forever or blow up your bill.
- **Monitor a keyword.** Turn on *Sort search by newest*, schedule the Actor, and every run returns the latest mentions.
- **Flat output.** Stories, comments and users come back as plain rows, not nested JSON.

### How to use it

1. Choose **What to scrape**.
2. Fill in the matching field: **Story lists**, **Search terms**, **Items** or **Users**.
3. Set your caps — these drive both runtime and cost.
4. Click **Start**, then download results as JSON, CSV, Excel or HTML, or fetch them through the Apify API.

#### Example input: today's front page

```json
{
  "mode": "stories",
  "storyLists": ["top"],
  "maxStoriesPerList": 30
}
```

#### Example input: every Show HN this year with 100+ points

```json
{
  "mode": "search",
  "contentType": "showHn",
  "searchTerms": [""],
  "minPoints": 100,
  "postedAfter": "2026-01-01",
  "newestFirst": true,
  "maxResultsPerSearch": 500
}
```

#### Example input: a story and its whole discussion

```json
{
  "mode": "item",
  "items": ["https://news.ycombinator.com/item?id=8863"],
  "includeComments": true,
  "commentDepth": 10,
  "maxCommentsPerItem": 1000
}
```

### Output

Every row has a `type` field: `story`, `comment`, `job`, `poll` or `user`. The dataset ships with **Stories & comments** and **Users** views.

**Story**

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

**Comment**

```json
{
  "type": "comment",
  "id": 9224,
  "parentId": 8863,
  "storyId": 8863,
  "commentDepth": 1,
  "text": "I have a few qualms with this app…",
  "author": "BrandonM",
  "createdAt": "2007-04-05T15:16:54Z",
  "hnUrl": "https://news.ycombinator.com/item?id=9224"
}
```

### Pricing

Pay only for results:

| Result | Price |
|---|---|
| Story, comment or job | $2.00 per 1,000 |
| User profile | $4.00 per 1,000 |

Set a maximum spend per run in the run options and the Actor stops cleanly when it's reached.

### Limits to know about

- **One request per item.** The Firebase API has no bulk endpoint, so 500 front-page stories costs 500 calls and a 1,000-comment thread costs about 1,000. Runtime and cost both scale with your caps, not with the number of stories you asked for.
- **Search returns at most 1,000 hits per query.** That is the index's own ceiling. Narrow with a date range to go deeper into the archive.
- **List lengths are HN's.** Top, new and best publish up to 500 ids; Ask, Show and Jobs publish about 200.
- **Comment counts drift.** `commentCount` is the story's `descendants` value, which can differ from the number of comments actually returned once dead and deleted ones are skipped.
- **Deleted and flagged items** come back with `deleted` or `dead` set to true and little else.
- `storyId` is filled on search hits and on walked comments, but the Firebase item endpoint only gives `parentId`, so a comment fetched on its own has no story id.

### FAQ

**Do I need an API key?** No. Both APIs are public and free.

**Which API does each mode use?** Story lists, Item + comments and Users use Firebase. Search uses Algolia.

**Can I track mentions of my product?** Yes. Use Search with *Sort search by newest*, schedule it, and connect the dataset to Slack or email.

**Why are some comments missing from a thread?** Either your depth or comment cap was reached, or the comments were deleted or flagged dead.

**Is this allowed?** Both endpoints are published by Hacker News for exactly this purpose. The Firebase API is documented at github.com/HackerNews/API and the search index at hn.algolia.com/api. Output contains public usernames and post text, so handle it in line with any privacy law that applies to you.

### Feedback

Found a bug or need a field that's missing? Open an issue on the Actor's **Issues** tab.

# Actor input Schema

## `mode` (type: `string`):

A ranked story list, a full-text search, one item with its comment thread, or user profiles.

## `storyLists` (type: `array`):

Which ranked lists to read.

## `searchTerms` (type: `array`):

For Search. One query per line. Leave empty and set an author to list everything that account posted.

## `items` (type: `array`):

For Item + comments. Use numeric ids (8863) or links (https://news.ycombinator.com/item?id=8863).

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

For Users. Use usernames (pg) or profile links.

## `maxStoriesPerList` (type: `integer`):

Each story is one extra request, so 500 stories means 500 calls. Hacker News publishes at most 500 ids per list.

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

Restrict a search to one kind of item.

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

Restrict a search to one username.

## `newestFirst` (type: `boolean`):

Best for monitoring a keyword over time.

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

Only return search results with at least this score.

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

Only return search results with at least this many comments.

## `postedAfter` (type: `string`):

A date (2026-01-31) or a unix timestamp. Search only.

## `postedBefore` (type: `string`):

A date (2026-12-31) or a unix timestamp. Search only.

## `maxResultsPerSearch` (type: `integer`):

The search index returns at most 1,000 hits for one query.

## `includeComments` (type: `boolean`):

For Item + comments. Walks the reply tree below each item.

## `commentDepth` (type: `integer`):

How many reply levels to walk.

## `maxCommentsPerItem` (type: `integer`):

Each comment is one request, so busy threads get expensive.

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

Stop the run after saving this many items. Leave empty for no limit.

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

Lower this if you see rate-limit retries in the log.

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

Not needed for most runs. Both APIs are open and generous.

## Actor input object example

```json
{
  "mode": "stories",
  "storyLists": [
    "top"
  ],
  "searchTerms": [
    "apify"
  ],
  "maxStoriesPerList": 30,
  "contentType": "story",
  "newestFirst": false,
  "maxResultsPerSearch": 100,
  "includeComments": true,
  "commentDepth": 5,
  "maxCommentsPerItem": 500,
  "maxConcurrency": 4,
  "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 = {
    "searchTerms": [
        "apify"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("winterlock/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 = { "searchTerms": ["apify"] }

# Run the Actor and wait for it to finish
run = client.actor("winterlock/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 '{
  "searchTerms": [
    "apify"
  ]
}' |
apify call winterlock/hacker-news-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,winterlock/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/HdmPFV8BmdrPjqk3K/builds/E2OiqmT7fRQCjANTF/openapi.json
