# Hacker News Scraper (`donjuan_mime/hackernews-scraper`) Actor

Scrape Hacker News stories, comments, and jobs from front page lists, keyword search, user profiles, or item links: title, link, points, comments, author, and time. No login needed.

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

## Pricing

$0.50 / 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.

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: stories, comments, and jobs from lists, search, and profiles

Hacker News Scraper collects stories, comments, Ask HN and Show HN posts, and job ads from [Hacker News](https://news.ycombinator.com). Scrape the front page and the other lists, search all of Hacker News by keyword and date, take everything a user has posted, or open a single story. For every item you get the title, external link and its domain, text, points, comment count, author, and post time. Turn on comments to get each story's full discussion, one item per comment, with its parent and depth.

You don't need a Hacker News account, an API key, or any code. Pick lists, add search terms or links, press **Start**, and download the results as JSON, CSV, Excel, XML, or HTML. Or pull them into your app through the Apify API.

### What can you do with Hacker News data?

- **Track what tech people talk about.** Save the front page every hour and see which stories climb, how fast, and how much discussion they draw.
- **Monitor your product or company.** Search for your name, domain, or competitors and catch every story and comment that mentions them.
- **Analyze discussions.** Pull the full comment tree of a launch or a Show HN post and study the feedback.
- **Collect job ads.** Scrape the jobs list or search "Who is hiring" threads to see which companies hire and for what.
- **Build datasets for research.** Clean text, timestamps, and scores make good input for topic, trend, or sentiment analysis.

### What data does Hacker News Scraper extract?

| Group | Fields |
|---|---|
| Item | type (story, comment, job, poll), ID, Hacker News URL, title, text |
| Link | external URL, domain |
| Engagement | points, number of comments |
| Author | username, profile URL |
| Time | post time (ISO 8601, UTC) |
| Threads | for comments: parent ID, story ID, and depth in the thread |

### How to scrape Hacker News

1. Open the actor and go to the **Input** tab.
2. Pick lists, add search queries, or paste Hacker News links. You can mix all three.
3. Set **Items per source**, and turn on **Include comments** if you want the discussions.
4. Press **Start**. When the run finishes, open the **Output** tab to preview the table, or press **Export** to download the data.

### Input

| Field | Type | Description |
|---|---|---|
| `lists` | array of strings | `top` (front page), `new`, `best`, `ask`, `show`, `job`. |
| `searchQueries` | array of strings | Search terms. Each query returns up to 1000 results. |
| `searchType` | string | What search and profiles return: `story`, `comment`, `ask_hn`, `show_hn`, `job`, `poll`, or `all`. |
| `searchSort` | string | `relevance` or `date` (newest first). |
| `since`, `until` | string | Limit search and profile results to this window. Use `2026-10-01` or `2026-10-01T00:00:00Z`. |
| `startUrls` | array | Links to items (`item?id=8863`), user profiles (`user?id=pg`), or list pages (`/newest`, `/ask`, `/show`, `/jobs`). |
| `maxItems` | integer | The maximum number of stories or results from each source. Comments come on top. |
| `includeComments` | boolean | Also collect the full comment thread of every story. |
| `maxCommentsPerItem` | integer | The maximum number of comments from each story. |

Example input:

```json
{
  "lists": ["top"],
  "searchQueries": ["golang"],
  "searchSort": "date",
  "since": "2026-01-01",
  "maxItems": 50,
  "includeComments": true,
  "maxCommentsPerItem": 100
}
```

### Output

One dataset item per story, comment, or job:

```json
{
  "type": "story",
  "id": 8863,
  "url": "https://news.ycombinator.com/item?id=8863",
  "title": "My YC app: Dropbox - Throw away your USB drive",
  "link": "http://www.getdropbox.com/u/2/screencast.html",
  "domain": "getdropbox.com",
  "author": "dhouston",
  "authorUrl": "https://news.ycombinator.com/user?id=dhouston",
  "points": 104,
  "commentsCount": 71,
  "createdAtISO": "2007-04-04T19:16:40Z",
  "input": "https://news.ycombinator.com/item?id=8863"
}
```

Comments carry `text`, `parentId`, `storyId`, and `depth` instead of a title and link.

### Tips and limits

- **Search stops at 1000 results per query.** To go further back, run the same query with consecutive `since` and `until` windows.
- **Comment scores are private.** Hacker News shows points only for stories, so comments always have `points: 0`.
- **Lists hold up to 500 stories** (`job` up to 200), as Hacker News serves them.
- **Deleted and flagged items are skipped.**

### Is it legal to scrape Hacker News?

The scraper reads only public data through Hacker News's official API and the Algolia HN Search API, the same sources many open source tools use. Personal data such as usernames is protected by laws like the GDPR, so collect it only when you have a legitimate reason, and consult a lawyer if you are unsure.

# Actor input Schema

## `lists` (type: `array`):

Hacker News lists to scrape: top (front page), new, best, ask, show, or job.

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

Search Hacker News for these terms. Each query returns up to 1000 results; use dates to go further back.

## `searchType` (type: `string`):

Which kind of item the search and user profiles return.

## `searchSort` (type: `string`):

Order of search results.

## `since` (type: `string`):

Only return search and profile items created on or after this date, as YYYY-MM-DD or 2026-10-01T00:00:00Z.

## `until` (type: `string`):

Only return search and profile items created before this date, as YYYY-MM-DD or 2026-10-15T00:00:00Z.

## `startUrls` (type: `array`):

news.ycombinator.com links: an item (item?id=...), a user profile (user?id=...), or a list page such as /newest, /ask, or /show.

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

The maximum number of stories or search results from each list, search query, or start URL. Comments come on top of this.

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

Also collect the full comment thread of every story, one item per comment, with its parent and depth.

## `maxCommentsPerItem` (type: `integer`):

The maximum number of comments from each story's thread. Leave empty for all of them.

## Actor input object example

```json
{
  "lists": [
    "top"
  ],
  "searchType": "story",
  "searchSort": "relevance",
  "maxItems": 30,
  "includeComments": false
}
```

# Actor output Schema

## `items` (type: `string`):

One item per story, comment, or job.

# 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 = {
    "lists": [
        "top"
    ],
    "maxItems": 30
};

// Run the Actor and wait for it to finish
const run = await client.actor("donjuan_mime/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 = {
    "lists": ["top"],
    "maxItems": 30,
}

# Run the Actor and wait for it to finish
run = client.actor("donjuan_mime/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 '{
  "lists": [
    "top"
  ],
  "maxItems": 30
}' |
apify call donjuan_mime/hackernews-scraper --silent --output-dataset

```

## MCP server setup

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