# Hacker News Scraper (`gogumaa/hacker-news-scraper`) Actor

Hacker News stories and comments: keyword search with filters, front page, a user's submissions, and full comment threads. Public Algolia JSON API, no login, no browser.

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

## Pricing

$2.00 / 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

**Hacker News scraper for stories, comments, users and the front page, with no login and no API key.** Search Hacker News by keyword with date and points filters, grab the current front page, pull everything a user posted, or download whole comment threads. It uses the public Algolia HN Search API, so runs are fast and you pay per result.

### What you can do with it

- **Brand / topic monitoring** — schedule `search` mode with `sortBy: date` for your product, competitor or technology and push new threads into Slack, a sheet, or an LLM summarizer.
- **Launch and trend research** — `type: show_hn` or `ask_hn` with `minPoints` shows what the community actually upvotes.
- **Sentiment and feedback mining** — `story_comments` mode returns every comment of a thread as plain text, ready for analysis.
- **Founder / author tracking** — `user` mode lists everything a user submitted or commented on, newest first.
- **Front page snapshots** — run `front_page` hourly to build a ranking history.
- **Automated feeds** — Schedule it on Apify and pipe results to Google Sheets, Slack, n8n or Make via the Apify integration.
- **Hiring and job leads** — search `query: "who is hiring"` with `sortBy: date`, then pull the thread with `story_comments` to get every job post as text.

### Output example

Story (`type: "story"`):

```json
{
  "type": "story",
  "id": "46111542",
  "title": "Rust 1.91 released",
  "url": "https://blog.rust-lang.org/…",
  "hn_url": "https://news.ycombinator.com/item?id=46111542",
  "author": "pg",
  "points": 512,
  "num_comments": 301,
  "created_at": "2026-10-30T14:02:11Z",
  "story_text": null,
  "comment_text": null,
  "story_id": null,
  "parent_id": null,
  "tags": ["story", "author_pg", "story_46111542"]
}
```

Comment (`type: "comment"`; `title` is null, `story_id` points to the thread):

```json
{
  "type": "comment",
  "id": "8952",
  "title": null,
  "url": null,
  "hn_url": "https://news.ycombinator.com/item?id=8952",
  "author": "sama",
  "points": null,
  "num_comments": null,
  "created_at": "2015-02-22T10:00:00Z",
  "story_text": null,
  "comment_text": "Plain text of the comment, HTML stripped.",
  "story_id": "8863",
  "parent_id": "8870",
  "tags": ["comment", "author_sama", "story_8863"]
}
```

### Input

| Field | Description |
|---|---|
| `mode` | `search` (default), `front_page`, `user`, `story_comments` |
| `query` | Mode `search`. Keywords; empty = browse by type / date / points. |
| `type` | Modes `search`, `user`. `story` (default), `comment`, `ask_hn`, `show_hn`, `all` (stories + comments). |
| `sortBy` | Mode `search`. `relevance` (default) or `date` (newest first). |
| `minPoints` | Modes `search`, `user`. Minimum points. |
| `dateFrom`, `dateTo` | Modes `search`, `user`. `YYYY-MM-DD`, UTC, inclusive. |
| `user` | Mode `user`. HN username. |
| `storyIds` | Mode `story_comments`. Story ids (the number in `item?id=…`). |
| `maxItems` | Stop after N rows total. Default 100. |

### Pricing

Pay per item: one event per dataset row (story or comment). Nothing is charged for rows that are never produced.

### Notes

- The search API returns at most 1000 hits per query. For larger exports, split the run into `dateFrom` / `dateTo` windows.
- `user` mode is always newest first. Comment rows have `points: null`.
- `story_comments` returns all comments in the thread (not only top-level); use `parent_id` to rebuild the tree.

### FAQ

#### Do I need an API key or account?

Algolia's public HN Search API needs no key or account. It is rate-limited per IP, which normal runs stay well under.

#### How much does it cost?

$0.002 per result and nothing else: with pay-per-event pricing you are not billed for Apify compute. 100 results cost $0.20, and the Apify free plan's $5 monthly credit covers about 2,500 results. Rows that are never produced are never charged.

#### How do I get the data into Google Sheets or my app?

Export the run's dataset as CSV, JSON or Excel from the Apify Console, read it from the dataset API endpoint, or connect it to Google Sheets, Slack, n8n, Make or Zapier with Apify integrations.

#### Is it legal to scrape Hacker News?

It only reads public data via the platform's public API and respects rate limits. You are responsible for complying with Hacker News's terms and applicable law.

#### Can I export more than 1,000 results for one search?

Not in one query: the search API returns at most 1,000 hits per query. Split the export into `dateFrom` / `dateTo` windows (for example one month per run) and combine the datasets.

### Related Actors

- [Lemmy Scraper](https://apify.com/gogumaa/lemmy-scraper)
- [Substack Posts Scraper](https://apify.com/gogumaa/substack-posts-scraper)
- [Hugging Face Hub Scraper](https://apify.com/gogumaa/huggingface-hub-scraper)

# Actor input Schema

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

search = keyword search. front_page = current front page. user = everything a user posted. story_comments = all comments of given stories.

## `query` (type: `string`):

Mode=search. Leave empty to browse by type / date / points only.

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

Mode=search and user. all = stories and comments.

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

Mode=search. relevance or newest first.

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

Mode=search and user. Skip items with fewer points.

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

Mode=search and user. YYYY-MM-DD (UTC), inclusive.

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

Mode=search and user. YYYY-MM-DD (UTC), inclusive.

## `user` (type: `string`):

Mode=user. HN username, e.g. pg, dang.

## `storyIds` (type: `array`):

Mode=story_comments. Numeric ids from news.ycombinator.com/item?id=…

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

Stop after this many rows (total).

## Actor input object example

```json
{
  "mode": "search",
  "query": "rust",
  "type": "story",
  "sortBy": "relevance",
  "user": "pg",
  "storyIds": [
    "8863"
  ],
  "maxItems": 100
}
```

# Actor output Schema

## `items` (type: `string`):

One record per story / comment: title, url, author, points, comment count, date, text, ids and tags.

# 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 = {
    "query": "rust",
    "user": "pg",
    "storyIds": [
        "8863"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gogumaa/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 = {
    "query": "rust",
    "user": "pg",
    "storyIds": ["8863"],
}

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

```

## MCP server setup

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