# 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 a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Hacker News Scraper",
        "description": "Search and scrape Hacker News stories and comments by keyword, author, date range, points, or comment count. Fast, official API, no browser.",
        "version": "1.0",
        "x-build-id": "8qQDj3lleSl173Vmz"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/originalvi~hacker-news-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-originalvi-hacker-news-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/originalvi~hacker-news-scraper/runs": {
            "post": {
                "operationId": "runs-sync-originalvi-hacker-news-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/originalvi~hacker-news-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-originalvi-hacker-news-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "queries": {
                        "title": "Search keywords",
                        "type": "array",
                        "description": "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).",
                        "items": {
                            "type": "string"
                        }
                    },
                    "searchType": {
                        "title": "What to search",
                        "enum": [
                            "story",
                            "comment",
                            "all",
                            "ask_hn",
                            "show_hn"
                        ],
                        "type": "string",
                        "description": "Stories (posts), comments, or both. Ask HN / Show HN restrict to those post types.",
                        "default": "story"
                    },
                    "sortBy": {
                        "title": "Sort by",
                        "enum": [
                            "byDate",
                            "byPopularity"
                        ],
                        "type": "string",
                        "description": "Newest first, or by popularity/relevance.",
                        "default": "byDate"
                    },
                    "maxItemsPerQuery": {
                        "title": "Max items per query",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "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.",
                        "default": 100
                    },
                    "minPoints": {
                        "title": "Minimum points (optional)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Only return stories/comments with at least this many points."
                    },
                    "minComments": {
                        "title": "Minimum comments (optional)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Only return stories with at least this many comments."
                    },
                    "author": {
                        "title": "Author username (optional)",
                        "type": "string",
                        "description": "Restrict results to a single Hacker News username (exact match, case-sensitive), e.g. `pg`."
                    },
                    "startDate": {
                        "title": "From date (optional)",
                        "type": "string",
                        "description": "Only items on or after this date. Accepts `YYYY-MM-DD`."
                    },
                    "endDate": {
                        "title": "To date (optional)",
                        "type": "string",
                        "description": "Only items on or before this date. Accepts `YYYY-MM-DD`."
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "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."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
