# Hacker News Scraper — Posts, Comments & Search (`felixgoldwin/hacker-news-scraper`) Actor

Search public Hacker News posts and comments by keyword, date, author or discussion. Export text, scores, reply counts and links. No account required.

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

## Pricing

from $1.00 / 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.

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

### What does Hacker News Scraper do?

Search and export **public Hacker News stories and comments** for topic research, product feedback, and discussion monitoring. Find posts by keyword, author, date, minimum points, or comment count. Export Ask HN and Show HN stories, or collect indexed comments belonging to specific story IDs.

No Hacker News account, cookies, or private API token are required. This Actor reads the public Hacker News search index and saves structured rows to an Apify dataset. Download JSON, CSV, or Excel, or connect the Actor to your application through the Apify API.

**Price: $1 per 1,000 delivered items, plus $0.005 per run. Platform usage is included.**

### What data can you extract?

Each dataset row is one story or comment. Missing source fields are returned as `null` or an empty array.

| Fields | Description |
| --- | --- |
| `itemId`, `itemType` | Source identifier and `story` or `comment` type |
| `title`, `text` | Source story title and available story or comment content; HTML is removed from the content |
| `author` | Public Hacker News username when available |
| `url`, `hnUrl` | Linked page and Hacker News item URL |
| `points`, `commentCount` | Source-provided score and comment count when available |
| `createdAt`, `createdAtTimestamp` | Creation time in UTC and Unix seconds |
| `storyId`, `storyTitle`, `storyUrl` | Related story metadata when available |
| `parentId` | Parent item ID for comments when available |
| `tags` | Source search-index tags |
| `scrapedAt` | UTC timestamp when the item was collected |

The Actor exports indexed content. It does not reconstruct deleted comments, private data, or the entire live comment tree. The public search index can lag behind Hacker News, omit items, and report estimated totals. It is not a complete official archive. This is an independent tool, not an official Hacker News or Y Combinator product.

### How to scrape Hacker News

1. Choose stories, comments, or both.
2. Enter an optional search query and filters.
3. Set the maximum items and search requests for the run.
4. Start the Actor and inspect the dataset.
5. Check the `SUMMARY` record for coverage, errors, and reasons pagination stopped, then export your results.

The default input collects up to 1,000 latest indexed stories. It does not represent Hacker News's ranked front page.

### Input examples

Search for AI stories with discussion and engagement:

```json
{
  "query": "AI",
  "itemType": "story",
  "sortBy": "date",
  "minPoints": 10,
  "minComments": 5,
  "maxItems": 1000,
  "maxPages": 150
}
```

Collect indexed comments from a specific story:

```json
{
  "itemType": "comment",
  "storyIds": ["https://news.ycombinator.com/item?id=8863"],
  "sortBy": "date",
  "maxItems": 500,
  "maxPages": 30
}
```

Export a larger date range:

```json
{
  "itemType": "story",
  "sortBy": "date",
  "fromDate": "2025-01-01",
  "toDate": "2026-01-01",
  "maxItems": 3000,
  "maxPages": 150
}
```

The last example includes items created on or after January 1, 2025, and before January 1, 2026, in UTC. It requests a maximum, not a guaranteed number of items.

### Input fields

| Input | Default | Details |
| --- | --- | --- |
| `query` | `""` | Search text, up to 200 characters; empty browses matching items |
| `itemType` | `"story"` | `story`, `comment`, or `all` |
| `sortBy` | `"date"` | `date` for newest first, or source `relevance` ranking |
| `storyIds` | `[]` | Up to 100 unique story IDs or official HTTPS HN item URLs; requires `itemType: "comment"` |
| `author` | `""` | Exact public username, using letters, numbers, underscores, or hyphens |
| `storyType` | `"all"` | `all`, `ask_hn`, or `show_hn`; Ask/Show filters require stories |
| `minPoints` | `0` | Minimum source-reported points; positive values require stories |
| `minComments` | `0` | Minimum source-reported comment count; positive values require stories |
| `fromDate` | `""` | Inclusive creation-time lower bound |
| `toDate` | `""` | Exclusive creation-time upper bound |
| `maxItems` | `1000` | Global maximum unique output items; 1–10,000 |
| `maxPages` | `150` | Global maximum logical search requests; 1–500 |

Dates accept `YYYY-MM-DD` or an RFC3339 timestamp with `Z` or an explicit offset, such as `2025-01-01T08:00:00+08:00`. Date-only values mean midnight UTC. Invalid calendar dates and timestamps without a timezone are rejected. If both bounds are set, `fromDate` must be earlier than `toDate`. To include an entire final day, set `toDate` to the next day's midnight.

Story IDs can be positive integer numbers, numeric strings, or URLs such as `https://news.ycombinator.com/item?id=8863`. They are normalized and deduplicated; at most 1,000 entries are allowed before deduplication. Multiple story IDs match comments associated with any selected story, while other filters are combined with them.

`minPoints` and `minComments` accept integers from 0 through 1,000,000. Input field names and enum values are case-sensitive. Unknown fields are rejected so configuration mistakes are visible.

### Can it return more than 1,000 results?

**Yes, with date sorting, when enough matching items are indexed and accessible.** The search source has a 1,000-result window for an individual search. When a date-sorted export needs more, the Actor continues through older creation-time windows. It overlaps the boundary timestamp and deduplicates item IDs to reduce gaps between windows.

For `sortBy: "relevance"`, the Actor exports only the first available search window, up to 1,000 results. It reports the source limit in `SUMMARY` if a larger matching export was requested. Splitting a relevance search into date ranges would change the global ranking, so the Actor preserves the source's available relevance window.

`maxItems` is a limit, not a promise. A run may return fewer items because of your filters, the available search index, a dense timestamp boundary, the search-request limit, source errors, or your spending limit. Index changes during a run can also affect coverage. Always inspect `SUMMARY` when completeness matters.

`maxPages` counts logical search requests across the entire run, including continuation windows. Retrying the same request does not consume another logical page. Results are deduplicated within the run, including resumed runs, but separate scheduled runs may export and charge for the same item again.

### Output and coverage

The default dataset contains the collected stories and comments. The default key-value store contains `SUMMARY`, which reports saved items, search requests, input duplicates removed, estimated source totals, whether date continuation was used, per-window coverage, errors, and stop reasons.

Source totals are estimates from the search index. They do not guarantee that the same number of unique records can be retrieved. A partial export can still contain useful results; the summary distinguishes it from an exhaustive traversal of the available search window.

### Pricing

The Actor charges **$0.001 per item delivered to the dataset**, plus **$0.005 for starting a run**. Platform usage is included.

- 100 delivered items: **$0.105**.
- 1,000 delivered items: **$1.005**.
- Empty results: the **$0.005 start charge** still applies, with no result charge.

Duplicates removed during the run, failed requests, and the `SUMMARY` record do not incur a result charge. Set a spending limit in Apify to control the maximum charge. Each new scheduled run is charged for the items it delivers, even if an earlier run delivered them.

### FAQ and support

#### Why is a comment missing?

The search index can lag or omit content. A comment may have been deleted, may not match the selected filters, or may fall beyond a source or run limit. Story comment counts are not a guarantee of accessible indexed comments.

#### Does it fetch the Hacker News front page or rank by points?

No. The default exports latest indexed stories. Relevance uses the search source's ranking; it is not equivalent to the live front page or a strict points sort.

#### Can I schedule exports and use the API?

Yes. Use Apify schedules for recurring exports and the Actor's **API** tab for integration examples. Download the dataset or connect it to downstream tools with Apify integrations.

#### How do I report a problem?

Open the Actor's **Issues** tab and include the run URL, relevant filters, and what you expected. Do not include account tokens or private credentials.

# Actor input Schema

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

Keyword or phrase to search in public Hacker News stories or comments. Leave empty for all matching indexed items.

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

Collect stories, comments, or both. Story IDs require Comments mode.

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

Date exports newest items first and can continue beyond 1000 using older date windows. Relevance follows source ranking and stops at its search window.

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

Optional Hacker News story IDs or HTTPS item URLs to collect comments from specific discussions. Set itemType to comment. Up to 100 unique IDs; multiple IDs use OR.

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

Optional exact public Hacker News username. This filters content; it does not scrape user profiles.

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

Optional Ask HN or Show HN restriction. Requires Stories mode.

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

Minimum story score. Zero disables the filter. Positive values require Stories mode.

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

Minimum number of comments reported for a story. Zero disables the filter. Positive values require Stories mode.

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

Optional YYYY-MM-DD (UTC midnight) or RFC3339 timestamp with time zone. Include items on or after this time.

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

Optional YYYY-MM-DD (UTC midnight) or RFC3339 timestamp with time zone. Include items before this time. For one whole day, use the following day as the end.

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

Maximum unique stories and comments across the entire run, subject to source availability. Default 1000. Date sorting supports larger exports.

## `maxPages` (type: `integer`):

Global logical search-request limit, including older date windows. HTTP retries do not count. Each request returns up to 100 items.

## Actor input object example

```json
{
  "query": "",
  "itemType": "story",
  "sortBy": "date",
  "storyIds": [],
  "author": "",
  "storyType": "all",
  "minPoints": 0,
  "minComments": 0,
  "fromDate": "",
  "toDate": "",
  "maxItems": 1000,
  "maxPages": 150
}
```

# Actor output Schema

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

No description

## `summary` (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("felixgoldwin/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 = {}

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

```

## MCP server setup

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