# Hacker News Search: Stories, Comments and Top Lists (`scraperworks/hacker-news`) Actor

Search every Hacker News story or comment ever posted, or get the live front page, new, best, Ask HN, Show HN and job lists, with points, comment counts and the top comments. Small, clean JSON for AI agents and research.

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

## Pricing

from $2.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

## Hacker News Search: Stories, Comments and Top Lists

Search every story or comment ever posted on Hacker News, or get the live lists (front page, new, best, Ask HN, Show HN, jobs). Each result comes back as small, clean JSON with points, comment counts and plain text. Stories can include their top comments.

It reads Hacker News's two public APIs: the official Firebase API for the live lists, and Algolia's HN Search API for search. It doesn't scrape the website.

### Who it's for

- **AI agents and assistants** that need "what is HN saying about X" in the middle of a task. Inputs are one line and outputs are small.
- **Founders and marketers** tracking mentions of a product, a competitor or a topic.
- **Researchers and analysts** studying what the tech community discusses, and when.
- **Newsletters and dashboards** that show the front page or the best of the week.

### Input

| Field | What it does |
|---|---|
| **Search for** | Words to search for, e.g. `rust` or `openai`. Leave empty to get a live list instead |
| **List** | When not searching: *Top* (front page), *New*, *Best*, *Ask HN*, *Show HN* or *Jobs* |
| **Search in** | *Stories* or *Comments* |
| **Search order** | *Best match* or *Newest first* |
| **Only from the last N days** | 0 means any time |
| **Minimum points** | Only stories with at least this many upvotes |
| **Max results** | Up to 1,000 (default 20) |
| **Top comments per story** | Adds each story's first N comments (0 to 10), in the order Hacker News shows them |

Examples:

```json
{ "query": "openai", "days": 7, "minPoints": 100, "topComments": 3 }
```

```json
{ "list": "show", "maxItems": 30 }
```

```json
{ "query": "postgres", "searchType": "comments", "sort": "newest", "maxItems": 50 }
```

### Output

One row per story or comment. A real story from the front page, with one top comment (text shortened):

```json
{
  "id": 50152307,
  "type": "story",
  "title": "Wine Ported to OpenBSD",
  "url": "https://marc.info/?l=openbsd-ports&m=179236125692175",
  "domain": "marc.info",
  "text": null,
  "author": "iamnothere",
  "points": 212,
  "comments": 55,
  "createdAt": "2026-10-19T13:35:34Z",
  "hnUrl": "https://news.ycombinator.com/item?id=50152307",
  "rank": 1,
  "scrapedAt": "2026-10-19T16:00:00Z",
  "topComments": [
    {
      "id": 50153536,
      "author": "t-3",
      "text": "I doubt much will be merged upstream. Many updates we have can technically run on other OSes ...",
      "createdAt": "2026-10-19T15:20:01Z",
      "replies": 1
    }
  ]
}
```

A comment from a search has `storyId`, `storyTitle`, `storyUrl` and `parentId` instead of the story fields. `rank` is set only for live lists. `topComments` is there only when you ask for it.

### Pricing

Pay per result: **$2.00 per 1,000 results**. A story with its top comments counts as one result. You can set a spending limit on any run, and the run stops cleanly when it's reached.

### Good to know

- **Search covers all of Hacker News history** (since 2007). Algolia returns at most 1,000 results for one search, so narrow it with days or minimum points if you need more.
- **Live lists** hold up to 500 stories (top, new, best) or 200 (Ask, Show, jobs).
- **No personal contact data.** Email addresses and phone numbers are removed from post and comment text. Usernames are kept, because they're how Hacker News identifies posts.
- **Deleted and flagged items are skipped.**

# Actor input Schema

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

Words to search for in every story (or comment) ever posted on Hacker News, e.g. "rust" or "openai". Leave empty to get one of the live lists below instead.

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

Which live Hacker News list to return, in the order the site shows it.

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

Search stories, or search comments (each comment row says which story it's on).

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

Best match first, or newest first.

## `days` (type: `integer`):

Only stories or comments posted in the last N days. 0 means any time.

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

Only stories with at least this many points (upvotes). Ignored for comments.

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

How many stories or comments to return, up to 1,000.

## `topComments` (type: `integer`):

Add each story's first N comments, in the order Hacker News shows them (0 to 10). Each one adds a little time to the run.

## Actor input object example

```json
{
  "list": "top",
  "searchType": "stories",
  "sort": "relevance",
  "days": 0,
  "minPoints": 0,
  "maxItems": 20,
  "topComments": 0
}
```

# Actor output Schema

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

One row per story or comment.

# 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("scraperworks/hacker-news").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("scraperworks/hacker-news").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 scraperworks/hacker-news --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scraperworks/hacker-news"
        }
    }
}
```

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/bgWMsZfjWPRB9hTCf/builds/U2nz4dzcjKn72sRpc/openapi.json
