# Hacker News Scraper (`originalvi/hacker-news-scraper`) Actor

Search and scrape Hacker News stories and comments by keyword, author, date range, points, or comment count. Fast, official API, no browser.

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

## Pricing

from $1.00 / 1,000 item scrapeds

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Hacker News Scraper — search HN stories & comments as structured data

Search **Hacker News** and get back clean, structured data. Look up any keyword, company, domain, author, or topic and pull matching **stories** and **comments** — title, URL, author, points, comment count, date, and full text.

Fast and reliable: powered by the official Hacker News (Algolia) Search API — no browser, no blocking, no API key, no rate-limit headaches.

### What you get

One dataset item per story:

```json
{
  "type": "story",
  "objectId": "48852295",
  "title": "Show HN: I built an open-source alternative to X",
  "url": "https://example.com/project",
  "author": "pg",
  "points": 412,
  "numComments": 168,
  "createdAt": "2026-07-09T20:59:19Z",
  "text": null,
  "discussionUrl": "https://news.ycombinator.com/item?id=48852295",
  "query": "open source",
  "status": "SUCCEEDED"
}
```

Or per comment (when searching comments):

```json
{
  "type": "comment",
  "objectId": "48852338",
  "author": "dang",
  "text": "This is a great write-up. One thing to add…",
  "createdAt": "2026-07-09T21:10:02Z",
  "storyTitle": "Show HN: I built an open-source alternative to X",
  "storyUrl": "https://example.com/project",
  "commentUrl": "https://news.ycombinator.com/item?id=48852338",
  "query": "open source",
  "status": "SUCCEEDED"
}
```

### How to scrape Hacker News

1. Enter one or more **search queries** — a keyword, company name, domain, or topic.
2. Pick what to search: **stories**, **comments**, both, or **Ask HN / Show HN** posts only.
3. Optionally filter by **author**, **minimum points**, **minimum comments**, or a **date range**.
4. Click **Start** and export the dataset as JSON, CSV, or Excel — or pull it via API.

Results arrive in seconds. A typical query finishes in under 15 seconds.

### Input

| Field | Description |
|---|---|
| `queries` | One keyword search per line (company, domain, topic, technology…) |
| `searchType` | Stories, comments, both, or Ask HN / Show HN only |
| `sortBy` | Most recent, or most popular / relevant |
| `maxItemsPerQuery` | Cap per query (index returns up to 1,000 per search) |
| `minPoints` | Only items with at least this many points |
| `minComments` | Only stories with at least this many comments |
| `author` | Restrict to one Hacker News username |
| `startDate` / `endDate` | Restrict to a date range (`YYYY-MM-DD`) |
| `proxyConfiguration` | Optional — the API needs no proxy |

### Pricing

You pay a small fee **per item delivered** (story or comment) — $1.00 per 1,000 items plus a few cents of platform usage. Searches that return nothing, or that fail, are never charged. No subscriptions, no minimums.

### Use cases

- **Brand & product monitoring** — track every time your company, product, or domain is posted or discussed on HN.
- **Launch tracking** — watch Show HN and Ask HN for your space, or see how a competitor's launch landed.
- **Developer trend research** — follow a technology or topic and measure how discussion changes over time.
- **Sentiment & voice-of-community analysis** — pull the full comment threads behind any story and run them through an LLM.
- **Recruiting & lead research** — find who's building or hiring in your niche via Who is hiring? threads and Show HN.
- **Pipelines** — schedule runs (e.g. hourly, last-24h) and pull results via the Apify API into your own alerts or dashboards.

### Run it from your own code

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("originalvi/hacker-news-scraper").call(run_input={
    "queries": ["anthropic", "claude"],
    "searchType": "all",
    "sortBy": "byDate",
    "maxItemsPerQuery": 200,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["title"] if item["type"] == "story" else item["text"][:80])
```

Works the same with the JavaScript `apify-client`, raw HTTP API, or no-code tools (Make, Zapier, n8n).

### FAQ

**Does this use the official Hacker News API?**
Yes — the HN Search API operated by Algolia, the same one that powers hn.algolia.com. It's public, documented, and requires no key. That makes this scraper unusually fast and stable: no HTML parsing, no blocking.

**How many results can I get per query?**
The search index returns up to 1,000 items per query. To go deeper on a broad term, split the run into date ranges with `startDate` / `endDate` — the Actor will happily fetch 1,000 per range.

**Can I get all comments of one specific story?**
Search comments with the story's URL or title as the query, or filter by `author` for a specific user's comment history.

**Can I monitor HN mentions of my company automatically?**
Yes — schedule the Actor (e.g. hourly) with `sortBy: byDate` and a webhook or the Apify API on the other end. Each run only costs what it returns.

**Is scraping Hacker News allowed?**
The data comes from a public, official API that exists precisely so people can build tools on it. No login, no personal data beyond public usernames.

### Tips

- Search your domain (`yourcompany.com`) as a keyword to catch every submission that links to you.
- Combine `minPoints: 100` with `sortBy: byDate` and a schedule to build a "trending in my space" feed.
- Ask HN / Show HN mode is great for tracking launches and pain-point research — filter by `minComments` to find active discussions.

### More Actors by this developer

- [Google News Scraper](https://apify.com/originalvi/google-news-scraper) — structured news articles by keyword, 20 country editions
- [Google Trends Explorer](https://apify.com/originalvi/google-trends-explorer) — interest over time, related queries & topics
- [eBay Sold Listings Scraper](https://apify.com/originalvi/ebay-sold-listings) — real sold prices + price statistics
- [App Store Reviews Scraper](https://apify.com/originalvi/app-store-reviews-scraper) — iOS reviews & ratings across 20+ countries
- [Website Screenshot Pro](https://apify.com/originalvi/website-screenshot-pro) — pixel-perfect full-page screenshots

### Found a problem?

Open an issue on the **Issues** tab and I'll fix it fast — usually within a day.

# Actor input Schema

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

One search per line, e.g. `artificial intelligence`, `your-company.com`, `rust`. Leave empty only if you set a filter below (author or date range).

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

Stories (posts), comments, or both. Ask HN / Show HN restrict to those post types.

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

Newest first, or by popularity/relevance.

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

Upper limit per search. The Hacker News search index returns at most 1,000 results per query — narrow with a date range or filters to go deeper.

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

Only return stories/comments with at least this many points.

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

Only return stories with at least this many comments.

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

Restrict results to a single Hacker News username (exact match, case-sensitive), e.g. `pg`.

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

Only items on or after this date. Accepts `YYYY-MM-DD`.

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

Only items on or before this date. Accepts `YYYY-MM-DD`.

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

Proxies to use. Optional for this actor — the Hacker News API is open and does no blocking. Leave off to keep runs fast and cheap.

## Actor input object example

```json
{
  "queries": [
    "artificial intelligence"
  ],
  "searchType": "story",
  "sortBy": "byDate",
  "maxItemsPerQuery": 100,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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": [
        "artificial intelligence"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("originalvi/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 = {
    "queries": ["artificial intelligence"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("originalvi/hacker-news-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": [
    "artificial intelligence"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call originalvi/hacker-news-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=originalvi/hacker-news-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/ituANL7P4RBfaaca2/builds/8qQDj3lleSl173Vmz/openapi.json
