# Hacker News Scraper – Top, New & Keyword Stories (`biddata/hackernews-scraper`) Actor

Collect Hacker News stories via the official Algolia API with three modes: keyword search, top stories by points, or newest stories by time. Outputs title, external URL, author, points, comment count and timestamp. No key, no browser.

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

## Pricing

from $2.00 / 1,000 result rows

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/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 – Top, New & Keyword Stories

**Hacker News stories with points and comment counts — keyword search, top stories or newest posts, straight from the official Algolia API, no key and no browser.**

Hacker News is the front page of the tech internet: new tools, papers, launches and debates surface there first, and points plus comment counts tell you what the community actually cares about.

Scraping the HTML pages is brittle and slow. This Actor uses the official HN Algolia search API, which is public, anonymous and returns clean JSON, and turns each story into one flat row with its external link, submitter, points, comment count and timestamp.

### Why this Actor

| | Typical scrapers | This Actor |
|---|---|---|
| Data source | HTML listing pages, fragile to layout changes | Official `hn.algolia.com/api/v1` JSON API |
| Keyword, top, newest | Three different scrapers or fragile filters | One Actor, three modes |
| Points & comments | Manual counting or separate parsing | Included in every row |
| API key | Often required or hidden | None needed |
| Output shape | Mixed snippets and nested markup | One flat row per story, fixed schema |

### What you get

One dataset item per Hacker News story.

| Field | Type | Description |
|---|---|---|
| `story_id` | string | Hacker News story id (the Algolia objectID). Stable key for de-duplication. |
| `title` | string | Story title with whitespace collapsed. |
| `url` | string | External article URL, or the Hacker News discussion page when the story has no external link. |
| `author` | string | Submitter's public nickname on Hacker News. No profile links, emails or personal data. |
| `points` | integer | Story score (points) at collection time. |
| `num_comments` | integer | Number of comments on the story at collection time. |
| `created_at` | string | Submission timestamp in ISO 8601, e.g. 2026-11-12T08:44:13.000Z. |
| `mode` | string | Mode the row was collected with: search / top / new. |

- **`story_id`** -- The Algolia objectID, which is the Hacker News story id — use it to de-duplicate across runs.
- **`url`** -- Points to the external article when the story has one; otherwise it falls back to the Hacker News discussion page (`news.ycombinator.com/item?id=<story_id>`).
- **`author`** -- Only the public submitter nickname is kept. This Actor does not collect comment bodies or any personal information from them.
- **`points`** -- The score at the moment of collection. Stories gain and lose points continuously, so re-running the same mode later can return slightly different values.

### Input

| Parameter | Type | Default | Description |
|---|---|---|---|
| `mode` | string (enum) | `top` | **Required.** search = keyword search (relevance + popularity ranked); top = popular stories ranked by points; new = newest stories ranked by time. |
| `query` | string | *(empty)* | Search keyword. Required for meaningful results in search mode; an empty string in search mode returns all stories ranked by popularity. Ignored in practice by top/new, which already rank by points or time. |
| `maxResults` | integer | `50` | Maximum number of stories to save, drawn from one or more API pages. |
| `page` | integer | `1` | Which Algolia page to start from (1 = first page). Useful for paging through results of a previous run. |

#### A note on `mode`

`search` ranks by relevance and popularity for a keyword; `top` returns popular stories ranked by points; `new` returns the newest stories by time. All three share the same output schema.

#### A note on `query`

For `search`, pass a keyword or phrase such as `ai agent`. An empty query in `search` mode returns all stories ranked by popularity, which behaves like `top`.

#### A note on `page`

Start from a later Algolia page to page through results of an earlier run, e.g. `page: 2` with the same keyword.

### Usage examples

**1. Top stories right now**

```json
{
  "mode": "top",
  "maxResults": 50
}
```

**2. Newest stories about ai agents**

```json
{
  "mode": "new",
  "query": "ai agent",
  "maxResults": 25
}
```

Schedule a daily `top` run and keep an eye on which stories gain points, or a daily `new` run with a topic keyword to catch a topic the moment it appears on Hacker News. De-duplicate on `story_id` to build an incremental feed.

### Data notes

- The Actor talks to the public HN Algolia API only. It never renders Hacker News pages and never handles CAPTCHA, logins or anti-bot challenges.
- Points and comment counts change over time; a `top` run reflects the snapshot taken during that run, not a historical record.
- Comment text is deliberately not collected — this Actor keeps to story metadata (title, link, submitter nickname, points, comment count, timestamp).
- For stories without an external link, `url` points to the Hacker News discussion page itself.

### Pricing

This Actor uses pay-per-event pricing. You only pay for what you actually get.

| Event | Price | When it is charged |
|---|---|---|
| Actor start | $0.002 | Once per run |
| Result row | $0.002 per row | For every row saved to the dataset |

That works out to **$2 per 1,000 rows**. A typical run returning 50 rows costs about **$0.10** in total.

No subscription is required. You can cap your spend with the max cost per run setting in Apify Console, and an empty or invalid input charges only the start event.

### FAQ

**Do I need an API key?**

No. The HN Algolia search API is public and anonymous, and this Actor needs nothing else to run.

**Is scraping Hacker News allowed?**

Yes. This Actor only reads public story metadata through the official Algolia search API provided for programmatic access. It does not collect comment bodies or personal data.

**Why are the points different from what I see on the website?**

Points move as users upvote and age the stories. Each run captures the score at collection time, and the API's ranking can also shift between requests.

### Related Actors

More data tools from the same publisher:

- [App Store Reviews Scraper](https://apify.com/biddata/app-reviews-scraper) - App Store and Steam user reviews with ratings, versions and dates.
- [EU Tenders Scraper](https://apify.com/biddata/ted-tenders-scraper) - EU public procurement notices from the official TED API.
- [ClinicalTrials.gov Scraper](https://apify.com/biddata/clinicaltrials-scraper) - Clinical trial records with phase, status and sponsor.
- [Federal Register Scraper](https://apify.com/biddata/federal-register-scraper) - US Federal Register documents, rules and notices.
- [arXiv Scraper](https://apify.com/biddata/arxiv-scraper) - arXiv papers with authors, abstracts and PDF links.
- [Weather Scraper](https://apify.com/biddata/weather-scraper) - Weather forecast and history for any city worldwide.

### Disclaimer

All data is retrieved in real time from **Hacker News** (news.ycombinator.com) via its official Algolia search API. This Actor is an independent tool and is not affiliated with, endorsed by, or sponsored by Y Combinator or the Hacker News community.

The Actor collects only public story metadata: title, external link, submitter nickname, points, comment count and submission time. It deliberately does not collect comment bodies or personal information. Submitter nicknames are public handles chosen by the users themselves.

# Actor input Schema

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

search = keyword search (relevance + popularity ranked); top = popular stories ranked by points; new = newest stories ranked by time.

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

Search keyword. Required for meaningful results in search mode; an empty string in search mode returns all stories ranked by popularity. Ignored in practice by top/new, which already rank by points or time.

## `maxResults` (type: `integer`):

Maximum number of stories to save, drawn from one or more API pages.

## `page` (type: `integer`):

Which Algolia page to start from (1 = first page). Useful for paging through results of a previous run.

## Actor input object example

```json
{
  "mode": "top",
  "query": "",
  "maxResults": 50,
  "page": 1
}
```

# Actor output Schema

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

All collected records in the default dataset, one row per record.

# 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": "top",
    "query": "",
    "maxResults": 50,
    "page": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("biddata/hackernews-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": "top",
    "query": "",
    "maxResults": 50,
    "page": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("biddata/hackernews-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": "top",
  "query": "",
  "maxResults": 50,
  "page": 1
}' |
apify call biddata/hackernews-scraper --silent --output-dataset

```

## MCP server setup

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