# Hacker News Scraper — Stories, Comments, Jobs & Users (`haketa/hackernews-scraper`) Actor

Scrape Hacker News: stories, Show HN, Ask HN, comments and users with title, URL, author, points, comment count and date. Search by keyword or tag, filter by points, pull a story's comments (incl. Who's Hiring jobs) and user profiles. For tech trends, research and sourcing.

- **URL**: https://apify.com/haketa/hackernews-scraper.md
- **Developed by:** [Haketa](https://apify.com/haketa) (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 $1.75 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
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, Jobs & Users

> **Scrape Hacker News at scale: stories, Show HN, Ask HN, comments and user profiles — with title, URL, author, points, comment count and date.** Search by keyword or tag, filter by points/comments, pull any story's comments (including monthly **"Who's Hiring"** job posts), and fetch user profiles. Clean JSON/CSV/Excel in seconds. Built for tech-trend tracking, research and sourcing.

[![Hacker News](https://img.shields.io/badge/Hacker%20News-API-ff6600)]()
[![Stories + Comments](https://img.shields.io/badge/Stories%20%2B%20Comments%20%2B%20Users-2da44e)]()
[![Who's Hiring](https://img.shields.io/badge/Who's%20Hiring%20Jobs-8250df)]()
[![Export](https://img.shields.io/badge/Export-JSON%20%2F%20CSV%20%2F%20Excel-fb8500)]()

***

### What This Actor Does

Pull structured data from Hacker News:

- **Stories** — title, URL, author, **points**, comment count, date, self-post text, HN link
- **Show HN / Ask HN / front page** — by tag
- **Comments** — author, text, points, parent story — including the job posts inside **"Ask HN: Who is hiring?"** threads
- **Users** — karma, about, account age, submission count

Search by keyword, filter by **minimum points or comments**, sort by popularity or date, pull a specific story's comments, or fetch user profiles.

***

### Why Use This

- **Track tech trends.** Pull top or newest stories on any topic with points and discussion counts.
- **Mine "Who's Hiring".** Extract every job post from the monthly hiring thread as structured rows.
- **Research & monitoring.** Follow Show HN launches, Ask HN questions and front-page movement.
- **Open and free.** Reads the public HN Search (Algolia) and official APIs — no key, no login, no anti-bot.

***

### Quick Start

#### Run it in the console (no code)

1. Add **search terms** and a **tag** (story, show_hn, ask_hn…), or **story IDs** for comments, or **usernames**.
2. Optionally set **min points / comments** and **sort** order.
3. Set **Max items**, click **Start**, export as **JSON, CSV, Excel or HTML**.

#### Top stories on a topic (Python)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("YOUR_USERNAME/hackernews-scraper").call(run_input={
    "searchTerms": ["rust"], "tags": "story", "minPoints": 100, "maxItems": 500,
})
for s in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(s["points"], "·", s["title"], "·", s["url"])
```

#### Extract "Who is hiring?" job posts (Python)

```python
## Pass the monthly thread's story ID (find it by searching "Ask HN: Who is hiring?")
run = client.actor("YOUR_USERNAME/hackernews-scraper").call(run_input={
    "storyIds": ["22665398"], "maxItems": 1000,
})
for c in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(c["author"], "·", c["commentText"][:120])
```

***

### Input Parameters

| Field | Type | Description |
|---|---|---|
| `searchTerms` | array | Keywords to search stories/comments. |
| `tags` | string | `story`, `show_hn`, `ask_hn`, `front_page`, `poll` or `comment`. |
| `sortBy` | string | `popularity` (relevance) or `date` (newest). |
| `minPoints` | integer | Only items with ≥ this many points. |
| `minComments` | integer | Only items with ≥ this many comments. |
| `storyIds` | array | Fetch the comments of these story IDs (e.g. a Who's Hiring thread). |
| `users` | array | HN usernames to fetch profiles for. |
| `maxItems` | integer | Max items across all queries. `0` = no limit. |
| `maxPagesPerQuery` | integer | Pagination cap per query (100 per page). |
| `proxyConfiguration` | object | Apify Proxy. Datacenter is enough (public API). |

***

### Output

```json
{
  "id": "22238335", "type": "story",
  "title": "Why Discord is switching from Go to Rust",
  "url": "https://blog.discord.com/...", "author": "Sikul",
  "points": 1582, "numComments": 642, "createdAt": "2020-02-04T17:30:40Z",
  "hnUrl": "https://news.ycombinator.com/item?id=22238335"
}
```

Comment and user records use `type: "comment"` / `type: "user"` with the relevant fields (comment text + parent story, or karma + about + submission count).

***

### Use Cases

1. **Tech trend tracking** — top/newest stories on any topic, filtered by points.
2. **"Who's Hiring" job extraction** — turn the monthly thread into a structured job list.
3. **Launch & sentiment monitoring** — Show HN launches, Ask HN questions, front-page movement.
4. **Community research** — user profiles, karma and submission history.

***

### Tips

- **`minPoints`** quickly filters to the signal (e.g. ≥100 points).
- **`sortBy: "date"`** gives newest-first for monitoring; `popularity` for best-of.
- For **Who's Hiring**, first search `"Ask HN: Who is hiring?"` to find the month's story ID, then pass it in `storyIds`.
- **`tags: "show_hn"`** or **`"ask_hn"`** targets those sections directly.
- **Schedule it** with Apify Schedules to track a topic or the monthly hiring thread.

***

### Frequently Asked Questions

**Do I need an account or key?**
No. The HN Search (Algolia) and official APIs are public and free — no login, key or anti-bot.

**How do I get job posts from Who's Hiring?**
Each job is a top-level comment on the monthly "Ask HN: Who is hiring?" story. Pass that story's ID in `storyIds` and the Actor returns every comment.

**Can I get the newest stories instead of the most popular?**
Yes — set `sortBy` to `date`.

**How far back can I search?**
HN Search indexes the full history; use `minPoints`/`minComments` and pagination to scope results.

**What export formats are supported?**
JSON, CSV, Excel, HTML, or via API — plus Google Sheets, webhooks, Make and Zapier.

***

### Legal & Responsible Use

This Actor is an independent tool and is **not affiliated with, endorsed by, or sponsored by Hacker News or Y Combinator.** It reads only public data. Use it responsibly and in line with applicable terms and laws.

# Actor input Schema

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

Keywords to search stories/comments (e.g. "rust", "startup"). Leave empty to get by tag only.

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

HN tag: story, show_hn, ask_hn, front_page, poll, or comment. Default: story.

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

Relevance/points (popularity) or newest first (date).

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

Only stories with at least this many points (0 = no filter).

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

Only stories with at least this many comments (0 = no filter).

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

Fetch the comments of these story IDs — e.g. a monthly "Ask HN: Who is hiring?" thread to extract job posts.

## `users` (type: `array`):

HN usernames to fetch profiles for (karma, about, account age).

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

Maximum items across all queries. 0 = no limit.

## `maxPagesPerQuery` (type: `integer`):

Pagination cap per query (100 per page).

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

Apify Proxy. The API is public — datacenter is enough and enabled by default.

## Actor input object example

```json
{
  "searchTerms": [
    "rust"
  ],
  "tags": "story",
  "sortBy": "popularity",
  "minPoints": 0,
  "minComments": 0,
  "maxItems": 200,
  "maxPagesPerQuery": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

Item/user ID

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

story/comment/user

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

Story title

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

Story link

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

Author username

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

Points/score

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

Comment count

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

Self-post text

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

Comment text

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

Parent story ID

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

Parent story title

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

Parent item ID

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

User karma

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

User about text

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

User submission count

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

Algolia tags

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

Creation date

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

news.ycombinator URL

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

ISO timestamp

# 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 = {
    "searchTerms": [
        "rust"
    ],
    "maxItems": 200,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("haketa/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 = {
    "searchTerms": ["rust"],
    "maxItems": 200,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("haketa/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 '{
  "searchTerms": [
    "rust"
  ],
  "maxItems": 200,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call haketa/hackernews-scraper --silent --output-dataset

```

## MCP server setup

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