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

Scrape Hacker News stories (top, new, best, ask, show, jobs) plus per-story metadata in one call. We handle pagination, fan-out, retries, and rate-limit pacing — you get typed dataset rows with title, URL, score, author, comment count, timestamp, and permalink.

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

## Pricing

Pay per event

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

<div align="center">
  <img src=".actor/icon.svg" width="160" alt="Devil Scrapes mark" />

## Hacker News Scraper

**💰 $2.00 / 1 000 results** &nbsp;·&nbsp; pay only for results &nbsp;·&nbsp; no credit card to try

_We do the dirty work so your dataset stays clean._ 😈

Scrape Hacker News stories (top, new, best, ask, show, jobs) plus per-story metadata in one call. We handle pagination, fan-out, retries, and rate-limit pacing — you get typed dataset rows with title, URL, score, author, comment count, posted-at timestamp, and full HN permalink. Schedule it, export it, ship it.

</div>

---

### 🎯 What this scrapes

This Actor walks Hacker News for the story list you pick — `top`, `new`, `best`, `ask`, `show`, or `jobs` — fans out to each story's record, handles retries when the upstream hiccups, and writes one typed dataset row per story. You pick the feed; we deliver clean rows on a schedule, in JSON / CSV / Excel, ready to wire into Sheets, S3, a warehouse, or a webhook.

### 🔥 What we handle for you

- 🛡️ **Browser fingerprint rotation** — `curl-cffi` impersonates real Chrome / Firefox / Safari TLS handshakes so the target sees a browser, not Python.
- 🌐 **Residential proxy rotation** via Apify Proxy — fresh session and exit IP on every block.
- 🔁 **Retries with exponential backoff** on `408 / 429 / 5xx` — up to 5 attempts per page, `Retry-After` honoured.
- 🧱 **Rate-limit-aware pacing** — when the target pushes back, we slow down instead of getting banned.
- 🧊 **Clean, typed dataset rows** — Pydantic-validated, ISO-8601 timestamps, stable IDs, JSON / CSV / Excel export straight from the Apify Console.
- 💰 **Pay-Per-Event pricing** — you only pay for results that hit your dataset. No data, no charge.

### 💡 Use cases

- **Trend monitoring** — diff top stories hourly to see which posts gain traction fastest.
- **Comment-volume alerts** — pipe rows into Slack when a story passes 100 comments.
- **Lead gen for dev tools** — surface Show HN launches that mention your stack and reach out.
- **Newsletter curation** — feed the top 10 stories from `best` into a weekly digest.
- **ML training data** — historical top story metadata for clickbait or score-prediction models.

### ⚙️ How to use it

1. Click **Try for free** at the top of the page.
2. Fill in the input form — most fields have sensible defaults.
3. Click **Start**. Output streams into the run's dataset.
4. Export from **Storage → Dataset** as JSON, CSV, or Excel — or fetch via the API.

### 📥 Input

| Field | Type | Required | Default | Notes |
|---|---|:--:|---|---|
| `feed` | `string` | no | 'top' | Which Hacker News story feed to pull from. <code>top</code> mirrors the front page; <code>best</code> is the time-decaye |
| `maxResults` | `integer` | no | 100 | Total dataset items to keep. The feeds expose up to 500 items each; pulling all of them costs ~500 results. Set to <code |
| `includeText` | `boolean` | no | True | Fetch the full self-post body for Ask HN / Show HN entries. Has no effect on regular link stories. |
| `concurrency` | `integer` | no | 8 | How many story records to fetch in parallel. The Firebase endpoint is generous; 8 is comfortable. |
| `proxyConfiguration` | `object` | no | {'useApifyProxy': False} | Apify Proxy is optional here — the Firebase API is happy to be hit directly. Enable proxy only if you're routing all tra |

#### Example input

```json
{
  "feed": "top",
  "maxResults": 3,
  "includeText": false,
  "concurrency": 4,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
````

### 📤 Output

Every row is one dataset item.

| Field | Type | Notes |
|---|---|---|
| `id` | `integer` | Hacker News story ID (stable, monotonically increasing). |
| `type` | `string` | HN item type — `story`, `job`, `ask`, `show`, `comment`, `poll`. |
| `title` | `string` | Story headline. |
| `url` | `['string', 'null']` | Outbound link (null for self-posts). |
| `permalink` | `string` | Hacker News permalink (`news.ycombinator.com/item?id=...`). |
| `by` | `string` | Author username on Hacker News. |
| `score` | `['integer', 'null']` | Upvotes — null for jobs / dead items. |
| `descendants` | `['integer', 'null']` | Total comment count, including replies. |
| `text` | `['string', 'null']` | Self-post body (Ask HN / Show HN). HTML, only present when includeText=true. |
| `time` | `integer` | Unix epoch seconds — when the story was posted. |
| `posted_at` | `string` | ISO-8601 UTC timestamp derived from `time`. |
| `scraped_at` | `string` | ISO-8601 UTC timestamp of when this row was recorded. |
| `rank` | `integer` | Position of this story in the feed at scrape time (1-indexed). |

#### Example output

```json
{
  "id": 39000000,
  "type": "story",
  "title": "Show HN: Devil Scrapes \u2014 public-data Apify Actors with honest pricing",
  "url": "https://apify.com/DevilScrapes",
  "permalink": "https://news.ycombinator.com/item?id=39000000",
  "by": "devilscrapes",
  "score": 142,
  "descendants": 33,
  "text": null,
  "time": 1747353600,
  "posted_at": "2026-05-15T20:00:00+00:00",
  "scraped_at": "2026-05-15T20:05:00+00:00",
  "rank": 1
}
```

### 💰 Pricing

Pay-Per-Event — you pay only when these events fire:

| Event | USD | What it is |
|---|---:|---|
| `actor-start` | $0.005 | One-off warm-up charge per run |
| `result` | $0.002 | Per dataset item |

Example: 1 000 results at the rates above ≈ **$2.00**. No subscription, no minimum, no card to start — Apify gives every new account $5 of free credit.

### 🚧 Limitations

Comment threads aren't expanded — we return `descendants` (the count) but not the tree. Dead and deleted stories are skipped. The `text` field for self-posts is HTML, not Markdown — render it through your own sanitiser before display.

### ❓ FAQ

**Is this legal?**

Yes — Hacker News publishes this data through its documented Firebase API (https://github.com/HackerNews/API). We respect their terms, surface every fetch in the logs, and pace requests so we stay a good citizen on the upstream.

**Why use this instead of the Firebase API directly?**

You get scheduled Apify runs, typed output rows, ISO timestamps, and the `rank` column the raw API doesn't provide. Plus it integrates with every Apify downstream — Sheets, S3, webhooks.

**Can I scrape comments too?**

Not in this Actor — comment trees fan out 10–100x per story and would blow up cost. We'll ship a sibling `hacker-news-comments-scraper` if there's demand.

**How fresh is the data?**

The Firebase API updates in near-real-time. Your run reflects whatever the front page looked like the moment your scrape hit each story.

### 💬 Your feedback

Spotted a bug, hit a weird edge case, or need a new field? Open an
issue on the Actor's **Issues** tab on Apify Console — we ship
fixes weekly and we read every report.

***

<div align="center">

Built by **[Devil Scrapes](https://apify.com/DevilScrapes)** 😈 — a small fleet of
opinionated public-data Actors. Honest pricing, real engineering, zero fine print.

</div>

# Actor input Schema

## `feed` (type: `string`):

Which Hacker News story feed to pull from. <code>top</code> mirrors the front page; <code>best</code> is the time-decayed best-of; <code>ask</code> / <code>show</code> / <code>jobs</code> are the dedicated sub-feeds.

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

Total dataset items to keep. The feeds expose up to 500 items each; pulling all of them costs ~500 results. Set to <code>0</code> for the feed's full length (up to 500).

## `includeText` (type: `boolean`):

Fetch the full self-post body for Ask HN / Show HN entries. Has no effect on regular link stories.

## `concurrency` (type: `integer`):

How many story records to fetch in parallel. The Firebase endpoint is generous; 8 is comfortable.

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

Apify Proxy is optional here — the Firebase API is happy to be hit directly. Enable proxy only if you're routing all traffic through Apify for compliance reasons.

## Actor input object example

```json
{
  "feed": "top",
  "maxResults": 100,
  "includeText": true,
  "concurrency": 8,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

All dataset items as JSON.

## `datasetItemsCsv` (type: `string`):

Same data exported to CSV.

## `datasetView` (type: `string`):

Open the run dataset in the Console.

# 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 = {
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

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

# Run the Actor and wait for it to finish
run = client.actor("devilscrapes/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 '{
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call devilscrapes/hacker-news-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Hacker News Scraper",
        "description": "Scrape Hacker News stories (top, new, best, ask, show, jobs) plus per-story metadata in one call. We handle pagination, fan-out, retries, and rate-limit pacing — you get typed dataset rows with title, URL, score, author, comment count, timestamp, and permalink.",
        "version": "0.5",
        "x-build-id": "FmCY2tOMESbaUbMUL"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/devilscrapes~hacker-news-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-devilscrapes-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/devilscrapes~hacker-news-scraper/runs": {
            "post": {
                "operationId": "runs-sync-devilscrapes-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/devilscrapes~hacker-news-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-devilscrapes-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": {
                    "feed": {
                        "title": "Story feed",
                        "enum": [
                            "top",
                            "new",
                            "best",
                            "ask",
                            "show",
                            "jobs"
                        ],
                        "type": "string",
                        "description": "Which Hacker News story feed to pull from. <code>top</code> mirrors the front page; <code>best</code> is the time-decayed best-of; <code>ask</code> / <code>show</code> / <code>jobs</code> are the dedicated sub-feeds.",
                        "default": "top"
                    },
                    "maxResults": {
                        "title": "Max stories",
                        "minimum": 0,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Total dataset items to keep. The feeds expose up to 500 items each; pulling all of them costs ~500 results. Set to <code>0</code> for the feed's full length (up to 500).",
                        "default": 100
                    },
                    "includeText": {
                        "title": "Include story text (Ask/Show HN)",
                        "type": "boolean",
                        "description": "Fetch the full self-post body for Ask HN / Show HN entries. Has no effect on regular link stories.",
                        "default": true
                    },
                    "concurrency": {
                        "title": "Concurrent fetches",
                        "minimum": 1,
                        "maximum": 32,
                        "type": "integer",
                        "description": "How many story records to fetch in parallel. The Firebase endpoint is generous; 8 is comfortable.",
                        "default": 8
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Apify Proxy is optional here — the Firebase API is happy to be hit directly. Enable proxy only if you're routing all traffic through Apify for compliance reasons.",
                        "default": {
                            "useApifyProxy": false
                        }
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
