# Hacker News Scraper: Stories, Comments & Search (`klyve1/hacker-news-api-scraper`) Actor

Get Hacker News stories and comments from the official API: top, new, best, Ask HN, Show HN, jobs, or keyword search with date and points filters. Optional comment threads. Fast and cheap, no browser.

- **URL**: https://apify.com/klyve1/hacker-news-api-scraper.md
- **Developed by:** [Nico Klyve](https://apify.com/klyve1) (community)
- **Categories:** News, 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 $0.50 / 1,000 story or comments

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 and keyword search

Get Hacker News data as clean JSON, CSV or Excel in seconds. Pick the front page, newest, best, Ask HN, Show HN or job posts, or search every story and comment ever posted by keyword, with date and points filters. Optionally add the full comment thread of each story.

The Actor uses the official Hacker News API (Firebase) and the public HN Search API by Algolia. No browser, no proxy, no login: fast, reliable and cheap.

### What people use it for

- **Brand and product monitoring**: search your company name, domain or product every day and get every new mention in stories and comments.
- **Launch tracking**: follow how your Show HN or Launch HN post ranks, its points and every comment.
- **Trend research**: collect the top stories about AI, Rust, startups or any topic over a date range.
- **Hiring and job leads**: export the job posts published on Hacker News.
- **Datasets for analysis and LLMs**: build a corpus of high-quality tech discussions with authors, dates and reply structure.

### Example output

A story:

```json
{
  "type": "story",
  "id": 50520182,
  "title": "Grazing sheep in fields with solar arrays",
  "url": "https://news.cornell.edu/stories/2026/10/sheep-grazing-solar-fields-offers-farmers-economic-ecological-gains",
  "domain": "news.cornell.edu",
  "text": null,
  "author": "PaulHoule",
  "points": 33,
  "commentsCount": 5,
  "createdAt": "2026-11-16T17:27:46.000Z",
  "hnUrl": "https://news.ycombinator.com/item?id=50520182",
  "rank": 1
}
```

A comment (when "Include comments" is on):

```json
{
  "type": "comment",
  "id": 50385491,
  "storyId": 50381687,
  "storyTitle": "Launch HN: Rivet (YC W23) – Scale and Orchestrate Agents on S3",
  "parentId": 50381687,
  "depth": 1,
  "author": "kianN",
  "text": "As someone who is not incredibly deep in the agent space, but works a lot on scientific and distributed computing, this really caught my eye...",
  "repliesCount": 2,
  "createdAt": "2026-11-05T22:36:30.000Z",
  "hnUrl": "https://news.ycombinator.com/item?id=50385491"
}
```

### Input

| Field | What it does |
|---|---|
| What to get | Front page, newest, best, Ask HN, Show HN, jobs, or Search by keyword. |
| Search keywords | Words to search (Search mode). |
| Search in | Stories, comments, or both (Search mode). |
| Sort search results by | Newest first or most relevant (Search mode). |
| Posted on or after / before | Date range (Search mode). |
| Minimum points | Keep only stories with at least this many upvotes. |
| Max stories or search results | How many stories or results to save. |
| Include comments | Add the comment thread of each story, with depth and parent id. |
| Max comments per story / Max reply depth | Limit the size of each thread. |

### Pricing

Pay per result: **$0.0005 per story or comment saved** ($0.50 per 1,000 items). Deleted items and empty results are free. Set a maximum charge per run to stay in control.

### Good to know

- Comment text is converted from HTML to plain text, links are kept as plain URLs.
- `rank` is the position of the story in the selected list at the time of the run.
- Schedule the Actor (for example every hour in Search mode sorted by newest) to get alerts on new mentions.
- Data comes from public, official Hacker News APIs. Please respect the people behind the comments when you reuse them.

# Actor input Schema

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

Pick a Hacker News list (front page, newest, best, Ask HN, Show HN, jobs) or Search to find stories and comments by keyword.

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

Only used in Search mode. Words to look for in titles, URLs, story text and comments, for example "rust" or "your-brand.com".

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

Only used in Search mode: search stories, comments, or both.

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

Only used in Search mode: newest first, or most relevant first.

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

Only used in Search mode: keep items posted on or after this date (YYYY-MM-DD).

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

Only used in Search mode: keep items posted on or before this date (YYYY-MM-DD).

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

Keep only stories with at least this many points (upvotes). Leave empty to keep all.

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

Maximum number of stories (or search results) to save. Comments are counted separately.

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

Also save the comment thread of each story, one row per comment, with depth and parent id.

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

Maximum number of comments saved for each story when comments are included.

## `maxCommentDepth` (type: `integer`):

How deep to follow replies: 1 keeps only top-level comments, 3 keeps replies to replies.

## Actor input object example

```json
{
  "mode": "top",
  "searchType": "story",
  "sortBy": "date",
  "maxItems": 10,
  "includeComments": false,
  "maxCommentsPerStory": 50,
  "maxCommentDepth": 3
}
```

# Actor output Schema

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

All rows produced by 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 = {
    "mode": "top",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("klyve1/hacker-news-api-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 = {
    "mode": "top",
    "maxItems": 10,
}

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,klyve1/hacker-news-api-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/ImHUGptrKxEZ5seXX/builds/bSPEGk6e1DIIPkts7/openapi.json
