# Hacker News Scraper — Stories, Comments & Trends (`celebrated-quadraphonic/hacker-news-scraper`) Actor

Scrape Hacker News via the official Firebase API: top/new/best/ask/show stories with scores, authors and comment threads. No browser, no proxies, no API key.

- **URL**: https://apify.com/celebrated-quadraphonic/hacker-news-scraper.md
- **Developed by:** [XiaoZhi DataTools](https://apify.com/celebrated-quadraphonic) (community)
- **Categories:** Social media, Developer tools, Automation
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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

Scrape **Hacker News** through the **official Firebase API** + **Algolia full-text search** over plain HTTP. No browser, no proxies, no API key, no practical rate limits.

### Two modes

**Feed mode** (leave `searchQuery` empty) — scrape what's hot *right now*:
pick one of 6 feeds (Top stories, Newest, Best, Ask HN, Show HN, Jobs) and pull the latest stories with their comment threads. Best for trend monitoring and daily digests.

**Search mode** (fill in `searchQuery`) — search *all of HN history*:
full-text search across every story ever posted, e.g. "LLM fine-tuning" returns 565 matching stories ranked by relevance. Best for topic research, sentiment backtracking, and finding every Show HN launch in a category. Comments are still fetched per story via the Firebase API.

### What you get

**Story rows** — title, URL, score, author, comment count, text (for Ask/Show HN), direct HN link, timestamp.

**Comment rows** — top-level comments per story with clean text, author, timestamp, and HN link.

### Key features

- **6 feeds** + **Algolia full-text search** (search overrides feed when set)
- **Keyword filter** on story titles + **minimum score** filter
- **Comment threads** with concurrent fetching — fast even for 30 stories × 10 comments
- **Never silently empty**: API errors become readable error rows

### Input

Pick a feed **or** type a search query for Algolia full-text search, optionally filter by keyword/score, choose how many stories and comments, run.

### Pick your mode

| You need | Fill in | You pay for |
|---|---|---|
| Stories only | Feed / search mode | `story` $0.001 each |
| Comments too | Tick include comments | `comment` $0.0005 each |

Unfilled inputs cost nothing — first 20 items per run are free anyway.

### Pricing

- **$0.001 per story** ($1.00 / 1,000 stories)
- **$0.0005 per comment** ($0.50 / 1,000 comments)
- First **20 items of every run are free** (stories + comments combined)
- Actor start: **$0.00005**
- Setup-guide and error rows are never charged

### Typical uses

- **Tech trend monitoring** (feed mode): what is HN talking about today?
- **Topic research** (search mode): every HN discussion about a technology, ever
- **Startup research**: Show HN launches, Ask HN discussions, hiring threads
- **Content & sentiment datasets** for analysis and ML

# Actor input Schema

## `feed` (type: `string`):

Which Hacker News feed to scrape.

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

Fetch the top-level comments for each story (with text and authors).

## `keyword` (type: `string`):

Only keep stories whose title contains this keyword (case-insensitive). Leave empty for all.

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

How many top-level comments to fetch per story.

## `maxStories` (type: `integer`):

Maximum stories to collect from the feed.

## `minScore` (type: `string`):

Only stories with at least this score. Leave empty for no filter.

## `searchQuery` (type: `string`):

Full-text search across all of Hacker News via Algolia (e.g. 'LLM fine-tuning'). When set, this overrides the feed selection.

## Actor input object example

```json
{
  "feed": "topstories",
  "includeComments": true,
  "keyword": "",
  "maxCommentsPerStory": 10,
  "maxStories": 30,
  "minScore": "",
  "searchQuery": ""
}
```

# 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 = {
    "feed": "topstories",
    "includeComments": true,
    "keyword": "",
    "maxCommentsPerStory": 10,
    "maxStories": 30,
    "minScore": "",
    "searchQuery": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("celebrated-quadraphonic/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 = {
    "feed": "topstories",
    "includeComments": True,
    "keyword": "",
    "maxCommentsPerStory": 10,
    "maxStories": 30,
    "minScore": "",
    "searchQuery": "",
}

# Run the Actor and wait for it to finish
run = client.actor("celebrated-quadraphonic/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 '{
  "feed": "topstories",
  "includeComments": true,
  "keyword": "",
  "maxCommentsPerStory": 10,
  "maxStories": 30,
  "minScore": "",
  "searchQuery": ""
}' |
apify call celebrated-quadraphonic/hacker-news-scraper --silent --output-dataset

```

## MCP server setup

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