# Hacker News Scraper - Stories, Comments, Search, Jobs (`fabrikit/hacker-news-scraper`) Actor

Hacker News scraper: top, new, best, Ask HN, Show HN and job stories, full-text search with filters (points, comments, dates), and comment threads. Official Firebase and Algolia APIs, no usernames collected. From US$0.30 per 1,000 items.

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

## Pricing

from $0.30 / 1,000 item 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 - stories, comments, jobs and full-history search

Collect Hacker News data from its two official, open APIs: the live Firebase lists (top, new, best, Ask HN, Show HN, jobs) and the Algolia search index for the whole history. One flat dataset for stories, jobs, polls and comments. **US$0.30 per 1,000 items.**

### Modes

| Mode | Use it for |
|---|---|
| `lists` | The live front page and other lists: top and new (500), best (200), Show HN (~150), Ask HN and jobs (~30) |
| `search` | Full-text search over every story and comment since 2006 with filters: content type, minimum points/comments, date range, sort by date or relevance. Newest-first searches can go back through any number of results |
| `items` | Specific stories or comments by ID or news.ycombinator.com link |

Switch on **Include comments** to add the comment thread of each story (top-level comments first, up to a per-story cap) as extra items.

### Input examples

Front page with comments:

```json
{ "mode": "lists", "lists": ["top"], "maxItems": 500, "includeComments": true, "maxCommentsPerStory": 50 }
```

Everything mentioning a topic, last year, popular only:

```json
{ "mode": "search", "queries": ["\"large language model\""], "tags": ["story"], "minPoints": 100, "dateFrom": "2025-10-01", "maxItems": 2000 }
```

Monthly "Who is hiring" style comment mining:

```json
{ "mode": "search", "queries": ["python remote"], "tags": ["comment"], "dateFrom": "2026-10-01", "maxItems": 1000 }
```

Ask HN and Show HN posts:

```json
{ "mode": "search", "tags": ["story", "ask_hn"], "sortBy": "date", "maxItems": 500 }
```

### Output

```json
{
  "id": 50073879,
  "type": "story",
  "title": "Gemini 4 Argon",
  "url": "https://deepmind.google/models/gemini/",
  "domain": "deepmind.google",
  "points": 294,
  "numComments": 247,
  "createdAt": "2026-10-13T16:03:16.000Z",
  "text": null,
  "parentId": null,
  "storyId": 50073879,
  "storyTitle": null,
  "author": null,
  "hnUrl": "https://news.ycombinator.com/item?id=50073879",
  "source": "list:top",
  "scrapedAt": "2026-10-13T17:14:17.109Z"
}
```

`type` is `story`, `job`, `poll` or `comment`. Ask HN, Show HN and comment bodies are in `text` as plain text (HTML removed, links kept). Comments have `parentId` and `storyId`.

**Privacy:** Hacker News usernames are not collected. The `author` field exists for compatibility and is always `null`.

### Pricing

| Event | Price |
|---|---|
| Item saved (story, job, poll or comment) | US$0.30 per 1,000 (US$0.0003 each) |

Use **Max items in total** to cap the bill; comments count as items.

### FAQ

**Is this allowed?** It uses Hacker News's official Firebase API and Algolia's public HN Search API, both intended for programmatic access.

**How many results can a search return?** Algolia serves 1,000 hits per query call; date-sorted searches automatically continue backwards in time, so you can pull tens of thousands of items. Relevance-sorted searches are limited to the 1,000 best hits.

**How fast is it?** About 60 stories per second from the lists (parallel requests) and several thousand items per second from search.

**Do I need a proxy?** No. It starts with direct requests and switches to a residential proxy automatically if an API rejects the IP.

**Use cases:** tech trend and launch monitoring, brand and competitor mentions, lead and hiring intelligence, content curation, sentiment analysis, datasets for LLM training and RAG.

### En español

Scraper de Hacker News con las APIs oficiales (Firebase y Algolia): listas en vivo (top, new, best, Ask, Show, jobs), búsqueda de texto completo con filtros (puntos, comentarios, fechas) y hilos de comentarios. No se recopilan nombres de usuario. Precio: US$0.30 por cada 1.000 ítems.

# Actor input Schema

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

Lists = the live front page lists (top, new, best, Ask HN, Show HN, jobs). Search = full-text search over all of Hacker News history with filters. Items = specific stories or comments by ID or URL.

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

Which Hacker News lists to read. top and new hold up to 500 stories, best 200, Show HN ~150, Ask HN and jobs ~30 each.

## `queries` (type: `array`):

Keywords or phrases, one per line (`"large language model"`, `rust`, `postgres`). Leave empty to list everything that matches the tags and filters.

## `tags` (type: `array`):

story / comment / job / poll are alternatives (any of them); ask_hn, show_hn and front_page narrow the result further (all selected must match). Default: stories.

## `sortBy` (type: `string`):

Newest first (can go back through the whole history, any number of results) or relevance (the API returns at most the 1,000 most relevant hits per query).

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

Optional start date (UTC).

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

Optional end date (UTC, inclusive).

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

Only items with at least this many points (stories). Applies to search and lists.

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

Only stories with at least this many comments. Applies to search and lists.

## `itemIds` (type: `array`):

Hacker News item IDs (8863) or links (https://news.ycombinator.com/item?id=8863).

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

Adds the comment thread of every story as extra items (type comment, with parentId and storyId). Each comment is billed as one item.

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

Cap for comments collected per story (top-level comments first, then replies).

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

Cap for each list or search query. Leave empty for no per-source cap.

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

Hard cap for the whole run, comments included. Each item is billed once.

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

Both Hacker News APIs are open, so no proxy is used by default. If they reject the Actor's IP (HTTP 403/429), it automatically switches to a residential proxy for the rest of the run.

## Actor input object example

```json
{
  "mode": "lists",
  "lists": [
    "top"
  ],
  "queries": [],
  "tags": [
    "story"
  ],
  "sortBy": "date",
  "itemIds": [],
  "includeComments": false,
  "maxCommentsPerStory": 100,
  "maxItems": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

All records collected during the run

# 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"
    ],
    "maxItems": 50,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("fabrikit/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 = {
    "lists": ["top"],
    "maxItems": 50,
    "proxyConfiguration": { "useApifyProxy": False },
}

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

```

## MCP server setup

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