# Hacker News Stories & Comments Scraper (`neuro-scraper/hacker-news-stories-comments-scraper`) Actor

Hacker News Scraper SD - Hacker News Scraper is a news data tool that extracts Hacker News stories and comments from the front page, new, best, Ask HN, Show HN, jobs and Who is hiring threads, plus full-text search and comment trees via the official APIs.

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

## Pricing

from $2.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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 and job posts

Hacker News Scraper collects Hacker News stories and comments through the two official public APIs: the HN Firebase API run by Y Combinator, and the Algolia HN Search API. It needs no account and no key, and it never loads the news.ycombinator.com pages.

It does four things, in any mix:

- **Lists** → the live front page (`top`), `new`, `best`, Ask HN, Show HN and YC job posts, in Hacker News' own order (`rank`).
- **Who is hiring?** → the top-level job posts of the latest monthly "Ask HN: Who is hiring?" thread.
- **Search** → full-text search of stories, comments or both, by relevance or newest first, with date and points filters.
- **Story links** → one story (or comment) with its whole comment tree, each comment with its `depth`.

#### Input

| Field | Type | Default | Meaning |
|---|---|---|---|
| `lists` | multi-select | `top` (prefill) | `top`, `new`, `best`, `ask`, `show`, `job`, `whoishiring` |
| `searchTerms` | list | – | Search terms, one per line |
| `searchType` | select | `story` | Stories, comments, or stories + comments + polls |
| `searchSort` | select | `relevance` | Relevance (max 1,000 results) or newest first (no cap) |
| `fuzzyMatching` | boolean | `false` | Algolia typo tolerance; off gives complete, stable results |
| `dateFrom`, `dateTo` | `YYYY-MM-DD` | – | Optional date window for searches |
| `minPoints` | integer | – | Optional minimum points (stories only) |
| `storyUrls` | list | – | `https://news.ycombinator.com/item?id=...` links or ids → item + comment tree |
| `maxResults` | integer | `30` | Rows per list, search term or story link |
| `maxItems` | integer | – | Optional cap on the whole run |
| `proxyConfiguration` | proxy | off | Not needed for the official APIs |

#### Output (one row per story or comment)

| Field | Meaning |
|---|---|
| `type` | `story`, `comment`, `job` or `poll` |
| `id`, `hnUrl` | Hacker News item id and link |
| `title`, `url`, `domain` | Story title, linked URL and its site |
| `text` | Comment text, Ask HN / job text, as plain text (links kept) |
| `author`, `points`, `commentCount`, `createdAt` | Author, score, number of comments, post time (UTC) |
| `storyId`, `storyTitle`, `parentId` | For comments: the story and the parent item |
| `depth` | Story links: 0 = the item, 1 = top-level comment, ...; Who is hiring: 1 |
| `rank` | Lists: position in the live list (1 = top of the front page) |
| `source`, `sourceInput`, `scrapedAt` | `list` / `whoishiring` / `search` / `item`, your input, UTC time |

#### Measured limits (2026-10-03, local runs)

- Lists hold what Hacker News publishes: top 500, new 500, best 200, Ask HN 17, Show HN 148, jobs 31 ids at the time of testing.
- List items are read 50 at a time from Algolia (points and comment counts matched Firebase exactly in our check); items Algolia does not have yet, and all job posts, come from Firebase one by one.
- Relevance search stops at 1,000 results (Algolia's limit). Newest-first search walks back in time and has no cap: 1,500 results in 32 seconds in our test.
- With fuzzy matching on, Algolia answers filtered searches non-exhaustively: the same query returned between 52 and 175 stories on repeated calls. Exact-word matching (the default) returned the same 50 every time.
- Deleted and dead comments are not in the comment tree.
- Speed: 781 rows (three lists + a 250-result search) in 51 seconds, about one request per second.

#### Example

```json
{"lists": ["top", "whoishiring"], "searchTerms": ["web scraping"], "searchSort": "date", "maxResults": 100}
```

Hacker News content is written by its users: keep the `author` and `hnUrl` for attribution.

# Actor input Schema

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

Live Hacker News lists. Top = the front page order. Job = YC company job posts. Who is hiring = the top-level job posts of the latest monthly "Ask HN: Who is hiring?" thread.

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

Full-text search of Hacker News, one term per line. Example: web scraping

## `searchType` (type: `string`):

Search terms only.

## `searchSort` (type: `string`):

Search terms only. Relevance stops at 1,000 results (Algolia's limit); Newest first can go back through all of Hacker News.

## `fuzzyMatching` (type: `boolean`):

Search terms only. Off (recommended) = exact words, complete and stable results. On = Algolia's typo tolerance, which also matches misspellings but answers non-exhaustively (measured: the same query returned between 52 and 175 stories).

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

Search terms only, optional. Date as YYYY-MM-DD.

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

Search terms only, optional. Date as YYYY-MM-DD.

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

Search terms only, optional. Only stories with at least this many points (comments have no points and are excluded when this is set).

## `storyUrls` (type: `array`):

Optional. Links like https://news.ycombinator.com/item?id=8863 or plain ids. Returns the item and its whole comment tree (depth 0 = the item).

## `maxResults` (type: `integer`):

How many rows to return for each list, search term and story link.

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

Optional cap on the whole run. Leave empty for no total cap.

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

Not needed: the official Hacker News APIs are open.

## Actor input object example

```json
{
  "lists": [
    "top"
  ],
  "searchTerms": [],
  "searchType": "story",
  "searchSort": "relevance",
  "fuzzyMatching": false,
  "storyUrls": [],
  "maxResults": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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 = {
    "lists": [
        "top"
    ],
    "searchTerms": [],
    "storyUrls": [],
    "maxResults": 30,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("neuro-scraper/hacker-news-stories-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 = {
    "lists": ["top"],
    "searchTerms": [],
    "storyUrls": [],
    "maxResults": 30,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("neuro-scraper/hacker-news-stories-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 '{
  "lists": [
    "top"
  ],
  "searchTerms": [],
  "storyUrls": [],
  "maxResults": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call neuro-scraper/hacker-news-stories-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,neuro-scraper/hacker-news-stories-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/yijjeJQOAiUgcKBK4/builds/AsmSn876r1gMZ74QC/openapi.json
