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

Scrapes Hacker News via the Algolia HN Search API and returns clean JSON (title, URL, author, points, comment count, HN item link). Search stories, Show HN, Ask HN, or comments by keyword, or grab the current front page. Main use: track a company, pr

- **URL**: https://apify.com/dami\_studio/hacker-news-scraper.md
- **Developed by:** [Dami's Studio](https://apify.com/dami_studio) (community)
- **Categories:** News, Developer tools, Integrations
- **Stats:** 1 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.00 / 1,000 item returneds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Scraper

Scrape [Hacker News](https://news.ycombinator.com/) via the **public Algolia HN Search API** — no API key, no login, no anti-bot. Search stories, Show HN, Ask HN, comments, or the current front page; sort by relevance or date; filter by minimum points.

### What it does

- Queries `https://hn.algolia.com/api/v1/search` (relevance) or `search_by_date` (newest first).
- Paginates automatically until it has collected `maxItems`.
- Returns clean, normalized JSON for each item (HTML stripped from story/comment text).
- Deduplicates by Hacker News `objectID`.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `query` | string | `"openai"` | Keywords to search for. Empty = newest/front-page items for the chosen tag. |
| `tags` | select | `story` | `story`, `show_hn`, `ask_hn`, `comment`, or `front_page`. |
| `sortBy` | select | `relevance` | `relevance` or `date` (newest first). |
| `minPoints` | integer | — | Only items with at least this many points. |
| `maxItems` | integer | `50` | Max items to return (1–1000). |
| `proxyConfiguration` | proxy | off | Optional; the public API has no anti-bot, so no proxy is needed. Only enable it if you hit IP rate limits at very high volume. |

> **`front_page` note:** the `front_page` tag always returns the ~30 items currently on the HN front page (no keyword search). For topic searches use `story`/`show_hn`/`ask_hn`/`comment` instead.

### Output

Each successful item:

```json
{
  "ok": true,
  "objectId": "44159823",
  "type": "story",
  "title": "OpenAI ...",
  "url": "https://example.com/article",
  "author": "someuser",
  "points": 412,
  "numComments": 188,
  "createdAt": "2026-06-01T12:34:56.000Z",
  "text": "",
  "hnUrl": "https://news.ycombinator.com/item?id=44159823"
}
```

For comments, `type` is `comment`, `title`/`url` reflect the parent story, and `text` is the (HTML-stripped) comment body.

Some fields can be `null` depending on the item: `url` (Ask HN/text posts and self-posts have no external link), `points` and `numComments` (often absent on comments), and `text` (empty string for link stories). `title`, `author`, `objectId` and `hnUrl` are present for well-formed items but defensively default to `null` if the API omits them.

On failure or no results, a single diagnostic row is emitted with `ok:false` and an `errorCode` (e.g. `NO_RESULTS`, `RATE_LIMITED`, `NETWORK`) — and nothing is charged.

### Pricing

Pay-per-result: one charge per returned item (`item` event). Diagnostic/empty rows are never charged.

# Actor input Schema

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

Keywords to search Hacker News for (e.g. "openai", "rust async"). Leave empty to get the newest/front-page items for the chosen tag.

## `tags` (type: `string`):

Which kind of Hacker News items to return: stories, Show HN, Ask HN, comments, or current front page.

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

Order results by Algolia relevance (best match) or by date (newest first).

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

Only return items with at least this many points (upvotes). Leave empty for no minimum. Applies mainly to stories.

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

Maximum number of items to return. The actor paginates the API until it has this many (or runs out).

## `notionConnector` (type: `string`):

Optional. Write each item as a page into your Notion when the run finishes. Authorize a Notion connector once in Settings → API & Integrations → MCP connectors, then pick it here. Leave empty to skip (default) — results are always saved to the dataset regardless.

## `notionParentId` (type: `string`):

Optional. The Notion data source ID of the database to write into (only used if a Notion connector is set). Leave empty to create the pages privately in your workspace instead.

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

Optional proxy for the Algolia HN API requests. The API is public with no anti-bot, so a proxy is NOT required and is off by default. Only enable Apify Proxy if you hit IP-based rate limits at very high volume.

## Actor input object example

```json
{
  "query": "openai",
  "tags": "story",
  "sortBy": "relevance",
  "maxItems": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Scraped rows are stored in the default dataset (one row per result). Blocked/empty/error runs return a single uncharged diagnostic row instead.

# 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 = {
    "query": "openai"
};

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

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

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/pFOUA19lu2B3FJMMs/builds/iBHpXU9F3fSwghDPj/openapi.json
