# Hacker News Search Scraper | Stories & Comments (`genial_candlestand/hacker-news-search-scraper`) Actor

Search Hacker News by keyword, author, points and date. Returns title, link, author, points, comment count, text and publish date for stories, comments, Ask/Show HN, polls and jobs. Many queries per run, no login or proxy.

- **URL**: https://apify.com/genial_candlestand/hacker-news-search-scraper.md
- **Developed by:** [Flowo](https://apify.com/genial_candlestand) (community)
- **Categories:** News, Social media, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.38 / 1,000 hacker news items

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 Search Scraper | Stories & Comments

![Hacker News Search Scraper | Stories & Comments](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/news-ycombinator-com-post-content-search-by-keyword-banner-95186aec.png)

This actor searches Hacker News and returns one row per matching story, comment, Ask HN, Show HN, poll or job ad. Each row has the title, link, author, points, comment count, text and publish date. You can filter by keyword, author, minimum points, minimum comments, date range and item type, and run many search terms in one run.

### What does Hacker News Search Scraper do?

It takes search terms and filters, queries the public Hacker News search index (hn.algolia.com, the engine behind HN's own search box) and saves clean rows to a dataset. Every row records which search term found it (`query`) and its rank (`position`).

It is built for developer-relations and marketing teams tracking mentions, researchers who need discussion datasets, recruiters who collect job ads, and AI agents that need a cheap, well-defined search call.

### How to scrape Hacker News stories and comments

![How Hacker News Search Scraper works: Sends each search term to the public HN search index (hn.algolia.com); Applies type, author, points, comments and date filters in the request; Pages through resul](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/news-ycombinator-com-post-content-search-by-keyword-how-9baa40d1.png)

1. Open the actor in Apify Console and go to the **Input** tab.
2. Enter one or more **Search terms** (one per line), or leave them empty and set an author, a date range or a type.
3. Choose the **Item type** (stories, comments, Ask HN, Show HN, jobs and so on) and **Sort by**.
4. Add filters such as minimum points or a date range, and set **Max results per search term**.
5. Click **Start** and download the results as JSON, CSV or Excel from the **Output** tab.

### How much does it cost to scrape Hacker News?

Price per event by Apify plan:

| Event | Free | Bronze | Silver | Gold and above |
|---|---|---|---|---|
| Hacker News item | $0.45 per 1,000 | $0.405 per 1,000 | $0.36 per 1,000 | $0.315 per 1,000 |
| Actor start | $0.00005 | $0.00005 | $0.00005 | $0.00005 |

A test run with the API example input below returned 200 rows in 2 s.

The actor uses pay-per-event pricing. One `result` event is charged for each item saved to the dataset: $0.45 per 1,000 items. A small start event ($0.00005 per GB of memory) is charged once per run. Searches with no matches are free. Apify proxy is not needed.

Examples on the Free plan, start fee included:

| Scenario | Items | Cost |
|---|---|---|
| Top 30 stories for two terms (rust, postgres) | 60 | about $0.027 |
| One term, 1,000 results by relevance | 1,000 | about $0.45 |
| All `llm` stories since 2023, by date | 5,000 | about $2.25 |
| A very large history export | 100,000 | about $45 |

### Input

![Hacker News Search Scraper input example: Search terms, Item type, Sort by, Max results per search term, Search in, Exact words only (no typo matching), Only new since the last run](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/news-ycombinator-com-post-content-search-by-keyword-input-4a9fc3e7.png)

The main fields:

- **Search terms** (`queries`): supports "exact phrases" and `-exclude`.
- **Item type** (`type`): story, comment, all, ask_hn, show_hn, front_page, poll, job.
- **Sort by** (`sort`): relevance (max 1000 per term) or date (newest first, no 1000 limit).
- **Max results per search term** (`maxItemsPerQuery`): 1 to 100000, default 100.
- **Filters**: `author`, `minPoints`, `minComments`, `dateFrom`, `dateTo` (YYYY-MM-DD, UTC).
- **Search options**: `searchIn` (all, title, url, text), `exactMatch` (no typo matching), `onlyNew` (only items not returned in earlier runs).
- **Max results in total** (`maxItems`) and an optional proxy.

```json
{
  "queries": ["rust", "postgres"],
  "type": "story",
  "minPoints": 100,
  "maxItemsPerQuery": 30
}
```

### What data can you extract from Hacker News?

![Hacker News Search Scraper output example: Title, Type, Author, Points, Comments, Posted](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/news-ycombinator-com-post-content-search-by-keyword-output-c75735eb.png)

| Field | Meaning |
|---|---|
| `id`, `type`, `url` | Item id, type and its Hacker News page |
| `title`, `text`, `textHtml` | Title, plain text and HTML text (text posts and comments) |
| `externalUrl`, `domain` | Linked page and its domain |
| `author`, `authorUrl` | HN username and profile link |
| `points`, `commentsCount` | Points and comment count (empty for comments and jobs) |
| `storyId`, `storyTitle`, `storyUrl`, `storyExternalUrl` | The story a comment belongs to |
| `isAskHn`, `isShowHn`, `isFrontPage` | Flags |
| `publishedAt`, `updatedAt` | ISO timestamps |
| `query`, `position`, `scrapedAt` | Search term, rank, scrape time |

Example row (shortened):

```json
{
  "id": "22238335",
  "type": "story",
  "title": "Why Discord is switching from Go to Rust",
  "url": "https://news.ycombinator.com/item?id=22238335",
  "externalUrl": "https://blog.discordapp.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f",
  "domain": "blog.discordapp.com",
  "author": "Sikul",
  "points": 1582,
  "commentsCount": 642,
  "publishedAt": "2020-02-04T17:30:40.000Z",
  "query": "rust",
  "position": 1
}
```

### Use cases

- **Brand and technology monitoring:** schedule a date-sorted comment search with "Only new since the last run" to see fresh mentions of a product or competitor.
- **Topic research:** collect the best-voted stories for several terms in one run.
- **Historical datasets:** export every story or comment on a topic over years, past the 1000-result cap, using date sort.
- **Hiring and launches:** pull job ads, "Ask HN" hiring threads, or Show HN posts that link to GitHub.
- **Author analysis:** list everything a given user posted.

### Limitations

- With Sort by Relevance, Hacker News search returns at most 1000 results per term; use Sort by Date for more.
- Comment trees (replies), author karma and GitHub star enrichment are not provided. Use type Comments to get the comments of a topic.
- Comments and jobs have no points or comment count, so those fields are empty and the minimum points/comments filters are rejected for those types.
- Title and URL search do not work with comments. Jobs match only in title and URL.
- Usernames are case-sensitive; a wrong case returns no results.
- Without search terms you must set an author, date range, points/comments filter or a type such as Front page, otherwise the run stops with an input error.

### Tips and troubleshooting

- Zero rows? Check the author's capitalisation, the date range, and whether the type fits the filter.
- Terms like `rust` also match "just" and "trust" by default; turn on **Exact words only** for cleaner results.
- For monitoring, combine Sort by Date, "Only new since the last run" and a schedule.
- Use `"quotes"` for exact phrases and `-word` to exclude a word.
- Set **Max results in total** to cap the whole run when you search many terms.
- No proxy is needed; enable it only if runs get blocked.

### API, MCP and integrations

Run the actor from your code with the same JSON input as in Console. Your API token is in [Console → Settings → API & Integrations](https://console.apify.com/settings/integrations).

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("genial_candlestand/hacker-news-search-scraper").call(run_input={
    "queries": ["rust", "postgres"],
    "type": "story",
    "sort": "relevance",
    "maxItemsPerQuery": 100,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**Node.js** (`npm install apify-client`):

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('genial_candlestand/hacker-news-search-scraper').call({
    "queries": ["rust", "postgres"],
    "type": "story",
    "sort": "relevance",
    "maxItemsPerQuery": 100,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**HTTP** — one request runs the actor and returns the results (runs up to 5 minutes; longer ones: [run asynchronously](https://docs.apify.com/api/v2/act-runs-post)):

```bash
curl -X POST "https://api.apify.com/v2/acts/genial_candlestand~hacker-news-search-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"queries":["rust","postgres"],"type":"story","sort":"relevance","maxItemsPerQuery":100}'
```

**AI agents (MCP).** Add the actor as a tool of the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp). Claude Code:

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=genial_candlestand/hacker-news-search-scraper"
```

Claude Desktop, Cursor or VS Code: `{"mcpServers": {"apify": {"url": "https://mcp.apify.com?tools=genial_candlestand/hacker-news-search-scraper"}}}`. Then ask, for example:

- "Find the 30 most upvoted Hacker News stories about rust with at least 100 points"
- "Get the latest 200 Hacker News comments mentioning postgres, newest first"
- "List 20 recent Hacker News posts and comments by user pg"

**Integrations.** Run it on a schedule with [Apify Schedules](https://docs.apify.com/platform/schedules) and send the results to Google Sheets, Slack, Zapier, Make, n8n or your webhook — see [Apify integrations](https://docs.apify.com/platform/integrations).

### FAQ

**Is it legal to scrape Hacker News?**<br>
The actor reads public data that Hacker News shows to everyone, including usernames of posters. You are responsible for how you use it and for complying with applicable law and privacy rules.

**Where does the data come from?**<br>
From the public Hacker News search index at hn.algolia.com, the same one HN's search box uses. No login or API key is needed.

**How is it different from other Hacker News actors?**<br>
It accepts several search terms per run and labels each row with its term, supports author, points, comments and date-range filters, goes past 1000 results per term with date sort, and returns plain text and HTML. It costs $0.45 per 1,000 items, against $5 per 1,000 for the leading Hacker News search actor.

**Can I get comments?**<br>
Yes, set Item type to Comments. Each comment row includes the parent story's title and link.

### Also useful

- [Google News Scraper](https://apify.com/genial_candlestand/google-news-articles-search-scraper) — add mainstream news articles by keyword and topic
- [YouTube Comments Scraper](https://apify.com/genial_candlestand/youtube-comments-and-replies-scraper) — collect discussion from YouTube videos as well
- [Google Trends Scraper](https://apify.com/genial_candlestand/google-trends-scraper) — check how interest in the same topics changes over time
- [Google Jobs Scraper](https://apify.com/genial_candlestand/google-jobs-scraper) — find job listings beyond Hacker News hiring posts

# Actor input Schema

## `queries` (type: `array`):

Keywords to search on Hacker News, one per line. Each term is a separate search and every row shows which term found it. Use "exact phrase" in quotes and -word to exclude. Leave empty to browse by author, date range, points or a type such as Front page.

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

What to search: stories (link and text posts), comments, all types, only Ask HN, only Show HN, polls, job ads, or stories that reached the front page. Minimum points/comments do not work with Comments or Jobs (they have no points on HN).

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

Relevance (best match first, at most 1000 results per search term — a limit of Hacker News search) or Date (newest first, no 1000 limit: use it to collect everything or to monitor new posts).

## `maxItemsPerQuery` (type: `integer`):

Stop each search term after this many results. With Sort by Relevance at most 1000 are available; with Sort by Date up to 100000.

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

Only items posted by this Hacker News user, e.g. pg or a profile URL like https://news.ycombinator.com/user?id=pg. Usernames are case-sensitive. Works with or without search terms.

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

Only items with at least this many points (upvotes). Works for stories, Ask/Show HN, front page and polls; not for Comments or Jobs. With type All, comments and jobs drop out of the results.

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

Only items with at least this many comments. Works for stories, Ask/Show HN, front page and polls; not for Comments or Jobs. With type All, comments and jobs drop out of the results.

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

Only items posted on or after this day (UTC), format YYYY-MM-DD, e.g. 2024-01-01. Works with every type and sort.

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

Only items posted on or before this day (UTC, the whole day included), format YYYY-MM-DD, e.g. 2024-01-31. Must not be earlier than Posted from.

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

Where the search terms must match: everywhere (title, link, text, author), only the title, only the link URL (e.g. github.com) or only the post/comment text. Title and URL work for stories, Ask/Show HN, front page, polls and jobs, not for Comments. Needs search terms.

## `exactMatch` (type: `boolean`):

Turn off Hacker News search's typo tolerance, so rust no longer also matches just or trust. Fewer, cleaner results. Off by default, as on hn.algolia.com.

## `onlyNew` (type: `boolean`):

Monitoring: return only items this search did not return in earlier runs with this option on (remembered for 90 days, separately for each set of search settings). Best with Sort by Date and a schedule.

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

Stop the whole run after this many results across all search terms. Leave empty for no total limit (Max results per search term still applies).

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

Not needed: Hacker News search answers without a proxy. Turn on Apify Proxy only if your runs get blocked.

## Actor input object example

```json
{
  "queries": [
    "rust",
    "postgres"
  ],
  "type": "story",
  "sort": "relevance",
  "maxItemsPerQuery": 100,
  "searchIn": "all",
  "exactMatch": false,
  "onlyNew": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Dataset with all found Hacker News items

# 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 = {
    "queries": [
        "rust",
        "postgres"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("genial_candlestand/hacker-news-search-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 = { "queries": [
        "rust",
        "postgres",
    ] }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,genial_candlestand/hacker-news-search-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/3WXEEOLzLsnYtHJoF/builds/h5uDnC8TP8bgQ5ARt/openapi.json
