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

Collect public Hacker News stories, comments, monthly hiring posts, item trees, and user profiles. Records include author, title, text, points, comment count, dates, URLs, and related item IDs. Search by keyword and filters, or split date windows to work around Algolia’s result limit.

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

## Pricing

from $2.38 / 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.
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 Scraper

**Returns:** one row per Hacker News item with id, type, title, author, points, numComments, createdAt, hnUrl.
**Input:** `{"mode": "search", "searchQueries": ["web scraping"], "contentType": "story", "sortBy": "relevance", "minPoints": 50, "maxItems": 20}`
**Best for:** tracking mentions of a product or topic, collecting Who is hiring leads, exporting discussion threads and user profiles.

```json
{
  "id": "22180559",
  "type": "story",
  "title": "Congrats! Web scraping is legal! (US precedent)",
  "author": "ehurynovich",
  "points": 1057,
  "numComments": 388,
  "createdAt": "2020-01-29T14:06:37.000Z",
  "hnUrl": "https://news.ycombinator.com/item?id=22180559"
}
```

### What does Hacker News Scraper do?

Hacker News Scraper turns results from the public Algolia Hacker News API into consistent dataset records. Use search mode to find stories and comments that mention a topic. Use the hiring mode to read top-level posts in the monthly “Who is hiring?” thread. Use item mode to fetch a specific story and its nested comment tree. Use user mode to look up public profiles by username. Each mode returns stable identifiers and the API URL from which the record was obtained.

Search can favor recent results or Algolia relevance. The Actor requests at most two Algolia pages per second and handles pagination. When a search has more results than Algolia exposes in one result window, it divides the date interval and searches smaller intervals. It deduplicates item identifiers across queries and pages. The `maxItems` input stops collection as soon as that many unique records have been written. A query with no matches finishes with a warning and an empty dataset.

The Actor uses the public API as its data source. The API can lag Hacker News and fields may be absent from a given item. A link post may have a URL and no body text; an Ask HN post may have body text and no external URL. Hiring posts are free-form comments, so the company and location fields are parsed from their first line and can be incomplete. These distinctions are visible in the nullable dataset fields.

### What data can you get?

The output has the same core shape across modes. Empty values are `null`, so a consumer can read one dataset even when it contains several content types. The fields below describe actual keys emitted by the Actor.

| Field | Meaning |
| --- | --- |
| `id` | Stable Hacker News item ID, or username in user mode. |
| `sourceUrl` | Algolia endpoint URL that returned the record. |
| `type` | Story, comment, job, poll, or user classification. |
| `title` | Story title when one exists; for Who is hiring posts, the first line of the post. |
| `url` | External URL associated with a story. |
| `author` | Public username of the item author. |
| `points` | Score provided by Algolia. |
| `numComments` | Discussion count when provided. |
| `text` | Plain text from a story body or comment. |
| `createdAt` | Creation time in ISO format. |
| `hnUrl` | Public news.ycombinator.com page of the item or user. |
| `storyTitle` | Title of the parent story, filled for comments returned by search; otherwise `null`. |
| `storyUrl` | External link of the parent story, filled for comments returned by search when the story has one. |
| `karma` | User karma, filled in user mode only. |
| `about` | User profile text as plain text, filled in user mode when present. |
| `storyId` | Related story ID, when available. |
| `parentId` | Immediate parent item ID for comments. |
| `company` | First header segment of a hiring post. |
| `location` | Location-like header segment of a hiring post. |
| `remote` | Whether a hiring post contains the word “remote”. |
| `domain` | Hostname of an external story URL. |
| `jobCategory` | Optional AI classification of a hiring role. |
| `sentiment` | Optional AI classification of a story or comment relative to a search topic. |

The `company`, `location`, and `remote` fields are simple interpretations of the post text. Review the original `text` before using those fields to contact a company or make a business decision. The `jobCategory` and `sentiment` values are available only when enrichment is enabled and succeeds. Enrichment sends relevant item text to TypeSafe AI, a third-party AI processor. No enrichment value is fabricated when the processor is unavailable.

### How to use

Choose a mode and provide its target. For a keyword search, use `searchQueries` and select a `contentType`. For a hiring run, choose `whoIsHiring` and optionally set `hiringMonth` and `keywordFilter`. For an item tree, pass numeric IDs or Hacker News item URLs in `itemIds`. For public profile lookups, pass `usernames`. Set `maxItems` to bound the dataset. Start a run and read the default dataset after it finishes.

Search mode accepts multiple query strings. Each string is searched separately, and duplicate items are written once. You can search all items of a content type by supplying an empty `searchQueries` array. Sorting by `relevance` uses Algolia's relevance endpoint; sorting by `date` uses its date endpoint. The date boundaries use the item's creation time. Set `exactPhrase` to quote each query before sending it to Algolia.

The `show_hn` and `ask_hn` choices use the corresponding Algolia tags. The `front_page` choice asks Algolia for its front-page tag. The `comment`, `job`, and `poll` choices ask for their matching tags. Scores and comment counts are API values, not measurements made by the Actor.

A hiring run searches for the latest matching monthly thread by the public `whoishiring` account, then reads its top-level comments. The `keywordFilter` is a case-insensitive substring match on each comment's plain text. For example, `remote` includes posts that mention that word anywhere in the text. Choose a specific `YYYY-MM` month when you need a particular monthly thread. A month without a matching thread returns no records and logs a warning.

### Input

| Input | Purpose | Default |
| --- | --- | --- |
| `mode` | Choose `search`, `whoIsHiring`, `item`, or `user`. | `search` |
| `searchQueries` | Keywords to search, one or more strings. | Empty list |
| `itemIds` | Item IDs or Hacker News item URLs. | Empty list |
| `usernames` | Public usernames to look up. | Empty list |
| `hiringMonth` | `latest` or a `YYYY-MM` month. | `latest` |
| `keywordFilter` | Text required inside a hiring post. | Empty string |
| `contentType` | Algolia content tag or Show/Ask HN title filter. | `story` |
| `sortBy` | `date` or `relevance`. | `date` |
| `minPoints` | Minimum item score. | No minimum |
| `minComments` | Minimum discussion count. | No minimum |
| `dateFrom`, `dateTo` | Optional ISO date boundaries. | Open interval |
| `author` | Optional author tag for search. | Any author |
| `exactPhrase` | Quote the search query. | `false` |
| `maxItems` | Maximum number of unique records, from 1 to 100000. | `50` |
| `enrich` | Classify hiring roles or keyword sentiment using TypeSafe AI. | `false` |
| `maxJevCalls` | Cap AI calls in one run, up to 500. | `500` |
| `proxyConfiguration` | Optional Apify Proxy settings for Algolia. | Disabled |

Example input for story research:

```json
{
  "mode": "search",
  "searchQueries": ["web scraping"],
  "contentType": "story",
  "sortBy": "relevance",
  "minPoints": 50,
  "maxItems": 20
}
```

Example input for hiring posts:

```json
{
  "mode": "whoIsHiring",
  "hiringMonth": "latest",
  "keywordFilter": "remote",
  "maxItems": 50
}
```

The item limit is shared across targets, including root stories and comments in item mode. An API call with no input uses search mode, an empty keyword list, story content, date sorting and a limit of 50. The Console prefill is different: it searches web scraping by relevance with at least 50 points and returns up to 20 records. If a valid search is empty, broaden the keywords or remove score, author and date filters. For item or user mode, supply the corresponding target list. Unavailable targets are skipped without dataset error rows.

### Output

The following story record came from a local run of the prefilled search. Some properties are shown as `null` because the story is a link post rather than a hiring comment or AI enriched result.

```json
{
  "id": "22180559",
  "type": "story",
  "title": "Congrats! Web scraping is legal! (US precedent)",
  "url": "https://parsers.me/us-court-fully-legalized-website-scraping-and-technically-prohibited-it/",
  "author": "ehurynovich",
  "points": 1057,
  "numComments": 388,
  "text": null,
  "createdAt": "2020-01-29T14:06:37.000Z",
  "storyId": 22180559,
  "parentId": null,
  "company": null,
  "location": null,
  "hnUrl": "https://news.ycombinator.com/item?id=22180559",
  "storyTitle": null,
  "storyUrl": null,
  "karma": null,
  "about": null,
  "remote": null,
  "companyUrl": null,
  "domain": "parsers.me",
  "jobCategory": null,
  "sentiment": null,
  "sourceUrl": "https://hn.algolia.com/api/v1/search?query=web+scraping&tags=story&numericFilters=created_at_i%3E%3D0%2Ccreated_at_i%3C1791955978%2Cpoints%3E%3D50&hitsPerPage=100&page=0"
}
```

The output always has `id` and `sourceUrl`. A comment's `text`, `storyId`, and `parentId` identify what was said and where it sits in a discussion. An item tree can include the root story and nested comments. A user lookup uses the username as its stable identifier, and `usernames` accepts either names or news.ycombinator.com/user?id= profile URLs. Because the Algolia API can omit fields, use the schema's nullable types in downstream pipelines.

### How much does it cost?

The Actor is charged per result written to the dataset. A successfully AI enriched result can also have an enrichment event. The Pricing tab on the Actor page shows the current charging details. Set `maxItems` to control the maximum number of result records in a run. If a query has no matches, the run writes no result records. The Actor does not push error messages or placeholder items to the dataset.

### Use with AI agents (MCP)

Apify's MCP server can expose this Actor as a tool for an AI agent. Configure the server URL with the Store path:

```text
https://mcp.apify.com/?tools=axiomworks/hacker-news-scraper
```

The agent can then supply an input object and read the resulting dataset. Specific prompts work better than broad requests because they make the intended mode and item limit clear. For example, ask the agent to “Find up to 20 Hacker News stories about web scraping with at least 50 points, sorted by relevance.” To inspect a discussion, ask it to “Get the item tree for Hacker News item 22180559, limited to 30 records.” For hiring research, ask it to “Find up to 25 remote posts from the latest Who is hiring thread.”

Agent callers should inspect `sourceUrl` and `createdAt` before treating a record as current. The source is the Algolia API, which may not yet include the newest Hacker News activity. A hiring company's first-line label and the location heuristic are useful starting points, but the `text` field supplies the original content for review.

### Integrations and API

You can run the Actor through the Apify client, then read its dataset in the same workflow. Replace the token placeholder with your own Apify API token in your environment or client configuration. The Actor does not require a Hacker News account.

Python:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("axiomworks/hacker-news-scraper").call(run_input={
    "mode": "search",
    "searchQueries": ["web scraping"],
    "maxItems": 20,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["id"], item["title"])
```

JavaScript:

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

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('axiomworks/hacker-news-scraper').call({
  mode: 'search',
  searchQueries: ['web scraping'],
  maxItems: 20,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach(item => process.stdout.write(`${item.id}: ${item.title}\n`));
```

cURL:

```bash
curl -X POST \
  'https://api.apify.com/v2/acts/axiomworks~hacker-news-scraper/run-sync-get-dataset-items' \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"mode":"search","searchQueries":["web scraping"],"maxItems":20}'
```

Each API call can choose a different mode and set of filters. The output is structured JSON, so it can feed a spreadsheet, a research notebook, or a scheduled monitoring job. Keep `maxItems` modest when you only need a sample, and add date boundaries when scanning a large historical topic.

### FAQ

**What happens if one item ID, username or search term is bad?** Each target runs on its own. A missing item, an unknown user, a malformed ID or a failed search is logged as a warning and skipped, the remaining targets still run, and the run ends successfully with the results found. No placeholder or error records are written.

**Does this require a Hacker News login?** No. The Actor reads public data via Algolia's Hacker News API. It does not inspect private account information or content behind a login.

**Why is a story missing?** Algolia's index can lag the website. A story may also fall outside the date, author, score, type, or text filters. Try a less restrictive search and inspect the selected sort order.

**Why is the external URL empty?** Text posts, including many Ask HN posts, do not have a separate destination link. Their title and body text can still be present.

**Why is a hiring location empty or surprising?** Hiring authors format their comments differently. The Actor reads the first header line and chooses a location-like segment. The full comment text is the source to review.

**What happens when the API blocks a request?** The Actor backs off and retries transient block and server responses. Proxy configuration can be enabled for runs that need it. A persistent failure skips that target and logs a warning; the run succeeds with any other results. If empty, broaden the filters, check the target IDs, or enable a suitable proxy and retry later.

**Can I fetch a complete discussion?** Item mode reads the item endpoint and walks the returned nested children, stopping at `maxItems`. The API's returned tree determines which comments are available.

**Is AI classification required?** No. Enrichment is off by default. When enabled, relevant text is sent to TypeSafe AI, a third-party AI processor, and a category or sentiment appears only on successful classification.

### Is it legal to scrape Hacker News?

This Actor reads public data exposed by the Algolia Hacker News API. Your use of the output must follow the laws and rules that apply to your project. Public availability does not determine every permitted downstream use. Review your own use case, especially before republishing comments or using hiring data for outreach. This Actor is an independent tool. It is not affiliated with or endorsed by Hacker News, Y Combinator, or Algolia.

### Feedback

If a search mode, field mapping, or hiring post interpretation does not work as expected, share the input, an affected item ID, and the observed result through the Actor's Apify page. An example item helps distinguish an API omission from a parsing problem. Include the mode and filters so the behavior can be reproduced. Avoid posting private information in feedback. The Actor's dataset and snapshot records are intended to make source review practical when a value looks wrong.

# Actor input Schema

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

Choose search (default: newest stories), whoIsHiring (monthly top-level hiring comments), item (story and comment tree), or user (public profiles). Example: "item" requires itemIds; "user" requires usernames. Unavailable targets are skipped; an empty run succeeds with guidance.

## `searchQueries` (type: `array`):

Search-mode keywords as a list, e.g. \["web scraping", "python"]. Each query runs separately; duplicates are removed. Default \[] searches all items matching the search filters. For no matches, broaden keywords or remove filters.

## `itemIds` (type: `array`):

Required for mode="item": a list of numeric IDs or Hacker News item URLs, e.g. \["22180559"] or \["https://news.ycombinator.com/item?id=22180559"]. Returns each root and its nested comments within the shared maxItems budget. Missing targets are skipped; ignored in other modes.

## `usernames` (type: `array`):

Required for mode="user": a list of public usernames or Hacker News profile URLs, e.g. \["pg"] or \["https://news.ycombinator.com/user?id=pg"]. Names accept letters, digits, underscores and hyphens, 1-64 characters. Unknown users are skipped.

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

For mode="whoIsHiring", use "latest" (default) or a YYYY-MM month, e.g. "2026-09". Searches the latest 100 matching monthly threads by whoishiring. If no thread is found, try latest or a more recent month.

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

For mode="whoIsHiring", require this case-insensitive substring in each hiring comment, e.g. "remote" or "python". Default "" keeps every top-level post. This is a text match, so "remote" can also match "no remote". Clear it if no posts match.

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

For mode="search", choose story (default), comment, show_hn, ask_hn, poll, job, or front_page. Example: "comment" returns discussion comments; "show_hn" uses Algolia’s Show HN tag.

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

For mode="search", use "date" (default: newest first) or "relevance" (Algolia relevance), e.g. "relevance" for topic research. Searches exceeding the API window are divided by creation date, so large exports are not globally relevance-sorted.

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

Optional nonnegative integer score threshold for mode="search", e.g. 50. Omitted means no score minimum. Useful for stories; comments may lack points. Remove this filter if the search returns no records.

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

Optional nonnegative integer discussion-count threshold for mode="search", e.g. 10. Omitted means no minimum. Useful for stories; comments may lack num_comments. Remove this filter if no records match.

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

Optional inclusive creation-date boundary for mode="search", e.g. "2026-01-01" or "2026-01-01T00:00:00Z". Omitted starts at the Unix epoch. Use explicit UTC timestamps for precise intervals and choose a date earlier than dateTo.

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

Optional exclusive creation-date boundary for mode="search", e.g. "2026-10-01" or "2026-10-01T00:00:00Z". Omitted uses the current time. A date-only value excludes that day from midnight; widen the interval if empty.

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

Optional exact public username for mode="search", e.g. "pg"; applies Algolia’s author tag. Omitted searches all authors. Use usernames with mode="user" to retrieve profiles instead.

## `exactPhrase` (type: `boolean`):

For mode="search", set true to wrap each nonempty query in quotes before sending it to Algolia, e.g. "web scraping" becomes a quoted phrase. Default false uses normal Algolia search. Turn off if too few records match.

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

Maximum unique dataset rows across all queries, item trees or usernames: 1-100000, default 50, e.g. 20. Includes root items and comments in item mode. Stops when this shared limit or your run cost limit is reached; fewer rows are returned when fewer matches exist.

## `enrich` (type: `boolean`):

Set true to send relevant text to TypeSafe AI, a third-party AI processor. Default false. Hiring mode can fill jobCategory; other modes attempt sentiment using the first search query as the subject. Requires configured runtime access; errors leave classifications null. Successful enrichment has a separate event.

## `maxJevCalls` (type: `integer`):

Maximum TypeSafe AI calls shared across fallback extraction and enrichment: integer 0-500, default 500, e.g. 100. Set 0 to disable all AI calls. Calls require configured runtime access; exceeding this cap leaves optional classifications null.

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

Apify Proxy settings for Algolia requests, e.g. {"useApifyProxy":false} (default). Direct requests are tried first; when enabled, retries use fresh proxy sessions. Persistent failures skip the target. If blocked, enable a suitable proxy or retry later; no Hacker News login is used.

## Actor input object example

```json
{
  "mode": "search",
  "searchQueries": [
    "web scraping"
  ],
  "itemIds": [],
  "usernames": [],
  "hiringMonth": "latest",
  "keywordFilter": "",
  "contentType": "story",
  "sortBy": "relevance",
  "minPoints": 50,
  "exactPhrase": false,
  "maxItems": 20,
  "enrich": false,
  "maxJevCalls": 500,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

No description

# 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 = {
    "mode": "search",
    "searchQueries": [
        "web scraping"
    ],
    "hiringMonth": "latest",
    "contentType": "story",
    "sortBy": "relevance",
    "minPoints": 50,
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("axiomworks/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 = {
    "mode": "search",
    "searchQueries": ["web scraping"],
    "hiringMonth": "latest",
    "contentType": "story",
    "sortBy": "relevance",
    "minPoints": 50,
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("axiomworks/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 '{
  "mode": "search",
  "searchQueries": [
    "web scraping"
  ],
  "hiringMonth": "latest",
  "contentType": "story",
  "sortBy": "relevance",
  "minPoints": 50,
  "maxItems": 20
}' |
apify call axiomworks/hacker-news-scraper --silent --output-dataset

```

## MCP server setup

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