# Hacker News Scraper | Firehose Mode, No API Key (`hridayrungta/hackernews-scraper`) Actor

Stories, jobs, polls and comments from Hacker News official public API - no key, no login, no browser. Firehose mode returns only new items since your last run, tracked by permanent item id. Feed modes: top, new, best, ask, show, job. $0.40 per 1,000 rows.

- **URL**: https://apify.com/hridayrungta/hackernews-scraper.md
- **Developed by:** [Hriday Rungta](https://apify.com/hridayrungta) (community)
- **Categories:** Social media, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.19 / 1,000 story scrapeds

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 — firehose mode, no API key

**Read Hacker News's own official public API — no key, no login, no browser.** Pull a curated
feed snapshot (top, new, best, ask, show, job), or turn on firehose mode and get every new story,
job, poll or comment since your last run, tracked by permanent sequential item id — not a
time-window watermark, not a search-result diff.

**$0.40 per 1,000 rows.** No start fee.

***

### What you get

One row per story, job or poll:

| | |
|---|---|
| `id`, `type`, `title`, `url`, `domain` | the item and where it points |
| `by`, `score`, `descendants` | author, points, comment count |
| `createdUtc`, `createdAtIso` | exact publication time |
| `hnUrl` | direct link to the HN discussion thread |

Turn on comments (feed mode) or ask for `comment` items (firehose mode) and each becomes its own
row with `text`, `by`, `parentId`, `storyId` and `depth` — so a thread rebuilds from the flat
table with one self-join, the same contract used by every other comment-tree Actor in this
collection.

### Firehose mode: the part no competing HN Actor on the Store advertises

Checked the three top-ranked competing Hacker News Actors on 2026-09-20: all three snapshot a
feed or run a search. None mention a since-last-run watermark. This Actor's `mode: "changes"`
does exactly that, and it's structurally simpler than the same feature on Reddit or LinkedIn:
**every Hacker News item has a permanent, strictly increasing integer id**, and the API's own
`/v0/maxitem.json` hands you the current ceiling directly. "Everything new since my last run" is
therefore just the integer range between your last mark and that ceiling — no sort order to get
wrong, no timestamp clock-skew, no pagination edge case.

- **First run never bills your entire history.** It seeds from `(current max id − firstRunLookback)`,
  500 ids back by default — a deliberate, bounded starting point, not the whole site's archive.
- **A capped run never skips a gap.** If `maxIdsPerRun` stops a run partway, the mark advances
  only through the longest unbroken run of ids actually processed — even under concurrent
  fetching, where results can complete out of order. The next run picks up exactly where the
  last one actually finished, never later.
- **Comments carry no public score field**, so `minScore` only ever filters stories, jobs and
  polls; a comment is never dropped by it.

### What it needs, and what it never does

Nothing. This Actor works with no proxy and no API key at all — Hacker News's Firebase-backed
API answered every request cold, and ten rapid sequential requests hit zero throttling during
testing. There is no login, no session, no scraped personal data beyond what any HN user already
publishes under their own public username.

### Input at a glance

| Input | Default | Notes |
|---|---|---|
| `mode` | `list` | `list` (a feed snapshot) or `changes` (firehose) |
| `listType` | `top` | `top`, `new`, `best`, `ask`, `show`, `job` — mode `list` only |
| `itemTypes` | `["story"]` | which types to keep in firehose mode |
| `includeComments` | `false` | mode `list` only; one request per comment, no batch endpoint exists |
| `maxCommentsPerStory` / `commentDepth` | `50` / `5` | comment-tree caps |
| `minScore` | `0` | stories/jobs/polls only |
| `maxItems` | `200` | cost cap — billed once per row saved |
| `maxIdsPerRun` | `1000` | mode `changes` only; safety cap per run, never causes a skipped id |
| `firstRunLookback` | `500` | mode `changes` only; how far back a new source's first run reaches |

### Billing

Pay per event, charged once per row saved, **no start fee**:

| Event | Price | When |
|---|---|---|
| `story-scraped` | $0.0004 | one story/job/poll row |
| `comment-scraped` | $0.0004 | one comment row |

Set `maxItems` as your cost cap.

# Actor input Schema

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

"list": a curated feed snapshot. "changes": firehose - only items new since your last run.

## `listType` (type: `string`):

Which curated Hacker News feed to read.

## `itemTypes` (type: `array`):

Which item types to keep from the firehose. Comments are high-volume; leave off unless you want them.

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

Fetch each story's comment tree too. One extra request per comment - HN's API has no batch endpoint.

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

Cap on comment rows per story, mode "list" only.

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

How deep into a reply chain to go, mode "list" only. 0 is top-level comments only.

## `minScore` (type: `integer`):

Drop stories/jobs/polls scoring below this. Comments carry no public score and are never filtered by it.

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

Cost cap - you're billed once per row saved.

## `maxIdsPerRun` (type: `integer`):

Safety cap on how many ids one firehose run walks. A capped run picks up exactly where it left off next time - nothing is skipped.

## `firstRunLookback` (type: `integer`):

A source's first firehose run seeds from (current max id - this), never from zero - so a first run never bills for the site's entire history.

## `concurrency` (type: `integer`):

How many items to fetch at the same time.

## `maxRetries` (type: `integer`):

Retries with backoff for network errors, timeouts, 5xx and 429 responses.

## `stateStoreName` (type: `string`):

Name of the key-value store (in YOUR account) that holds the firehose mark. Leave blank for the default.

## `stateNamespace` (type: `string`):

Advanced: an explicit namespace for the mark key. Leave blank to namespace by your Apify user id automatically.

## Actor input object example

```json
{
  "mode": "list",
  "listType": "top",
  "itemTypes": [
    "story"
  ],
  "includeComments": false,
  "maxCommentsPerStory": 50,
  "commentDepth": 5,
  "minScore": 0,
  "maxItems": 200,
  "maxIdsPerRun": 1000,
  "firstRunLookback": 500,
  "concurrency": 10,
  "maxRetries": 3,
  "stateStoreName": "",
  "stateNamespace": ""
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("hridayrungta/hackernews-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("hridayrungta/hackernews-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 '{}' |
apify call hridayrungta/hackernews-scraper --silent --output-dataset

```

## MCP server setup

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