# Hacker News Scraper — Stories, Comments & Brand Mention Alerts (`xqfech/hacker-news-scraper`) Actor

Scrape Hacker News stories and comments by keyword, phrase or brand, with author, points, timestamps and permalinks. Also tracks state between runs so each run returns only mentions that appeared since the last one — for launch-day monitoring, devtools marketing and founder alerts.

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

## Pricing

from $20.00 / 1,000 change events

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 Mention Monitor — Brand & Keyword Alerts from HN

Someone just mentioned your product in a Hacker News comment. Do you find out in 10 minutes — while the thread is alive and you can still join the conversation — or three days later from a traffic spike you can't explain?

This Actor watches Hacker News for **new mentions** of any phrase — in stories *and* comments — and outputs only what appeared since the last run. Schedule it every 15–30 minutes and pipe mentions to Slack: that's a real-time HN listening post for cents a day.

### What it does

- **Monitor any phrases** — brand names, product names, competitor names, founder names, category terms. Exact match with quotes (`"claude code"`) or loose match without.
- **Stories and comments** — most brand conversation on HN happens in comments; most tools only watch titles. This one reads both.
- **Only the new stuff** — stateful between runs: the first run silently records the current state, every following run emits only fresh mentions. No duplicates, no noise.
- **Point threshold** — optionally ignore low-score stories while keeping all comments.

### Who uses this

- **Founders & devtools teams** — join HN threads about your product while they're hot; HN comment velocity decides whether a thread lives or dies.
- **Marketing & comms** — track competitor mentions and category conversations.
- **Investors & researchers** — monitor portfolio companies and technology trends as they surface.

### Output example

```json
{
  "type": "new_mention",
  "query": "\"claude code\"",
  "kind": "comment",
  "title": "Ask HN: What's your AI coding setup?",
  "excerpt": "I run several AI coding agents — Claude Code, Codex...",
  "author": "somedev",
  "points": null,
  "hnUrl": "https://news.ycombinator.com/item?id=45872011",
  "createdAt": "2026-08-04T09:12:33.000Z",
  "detectedAt": "2026-08-04T09:30:00.000Z"
}
```

### Input

| Field | Description |
| --- | --- |
| `queries` | Phrases to monitor (quotes = exact match) |
| `includeComments` | Watch comments too (default on) |
| `minPoints` | Ignore stories below this score |
| `maxMentionsPerQuery` | Fetch window per run |
| `monitorId` | State namespace shared between runs |

### Reliability

Built on the official HN Algolia search API — public, keyless, and stable for over a decade. Strict schema validation on every item. Deduplication survives across runs via a rolling window of seen IDs.

### Scheduling

This Actor shines on short schedules: every 15–30 minutes via an Apify Schedule, with a Slack or webhook integration. A quiet run costs a fraction of a cent — a day of real-time monitoring costs less than a coffee refill.

# Actor input Schema

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

Brand names, product names or phrases. Use quotes for exact match, e.g. "claude code".

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

Monitor mentions inside comments, not only story titles/links.

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

Ignore stories below this score (comments are always kept).

## `maxMentionsPerQuery` (type: `integer`):

Fetch window per run.

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

State namespace. Runs with the same Monitor ID share the previous-run snapshot.

## `emitBaseline` (type: `boolean`):

When enabled, the first run also outputs the current mentions as baseline items. Disabled by default — most users only want new mentions.

## Actor input object example

```json
{
  "queries": [
    "\"your brand\""
  ],
  "includeComments": true,
  "minPoints": 0,
  "maxMentionsPerQuery": 50,
  "monitorId": "default",
  "emitBaseline": 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": [
        "\"your brand\""
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("xqfech/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": ["\"your brand\""] }

# Run the Actor and wait for it to finish
run = client.actor("xqfech/hacker-news-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": [
    "\\"your brand\\""
  ]
}' |
apify call xqfech/hacker-news-scraper --silent --output-dataset

```

## MCP server setup

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