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

Track Hacker News stories by category with scores, comments, and author data via the official Firebase API. Pull top, new, best, ask, show, and job posts for monitoring and research workflows.

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

## Pricing

from $0.47 / 1,000 post extracteds

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?

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 & Tracker

Track Hacker News discussions for competitive intelligence, developer sentiment, and trending topics in tech. Instead of scraping HTML, this actor queries the official HN Firebase API to pull stories by category — top, new, best, ask, show, or job — with scores, comment counts, and author data. Schedule it daily to build a signal feed for product launches, technology trends, and community buzz.

### Features

- **Six categories** — fetch top, new, best, ask, show, or job stories in a single run
- **Official API** — uses the Hacker News Firebase API for reliable, structured data
- **Rich metadata** — includes score, comment count, author, timestamp, and source domain
- **Domain extraction** — automatically parses the hostname from each story URL
- **Bulk fetching** — retrieve up to 500 stories per run with batched API calls
- **No browser required** — pure API access means fast execution and low resource usage
- **Pay-per-result pricing** — only pay for stories extracted, with built-in charge limits

### Input

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `category` | `string` | No | `top` | Story category to fetch: `top`, `new`, `best`, `ask`, `show`, or `job` |
| `maxItems` | `integer` | No | `100` | Maximum number of stories to fetch (1-500) |
| `timeoutSeconds` | `integer` | No | `15` | Per-request API timeout in seconds (1-120) |

#### Input Example

```json
{
  "category": "top",
  "maxItems": 50,
  "timeoutSeconds": 15
}
```

### Output

Each dataset item represents one Hacker News story. Key fields:

- `id` (`number`) — HN story ID
- `title` (`string`) — story headline
- `url` (`string`) — link to the external content (or HN discussion if self-post)
- `domain` (`string`) — hostname of the linked URL (e.g. `github.com`)
- `score` (`number`) — upvote count
- `by` (`string`) — author username
- `time` (`number`) — Unix timestamp of submission
- `descendants` (`number`) — total comment count
- `type` (`string`) — item type (`story`, `job`, etc.)

#### Output Example

```json
{
  "id": 38945678,
  "title": "Show HN: I built an open-source alternative to Datadog",
  "url": "https://github.com/example/monitoring-tool",
  "domain": "github.com",
  "score": 342,
  "by": "techfounder",
  "time": 1705334400,
  "descendants": 187,
  "type": "story"
}
```

### Pricing

| Event | Cost |
|-------|------|
| Post Extracted | Pay-per-event (see actor pricing page) |

### Use Cases

- **Competitive intelligence** — monitor when competitors or their products get discussed on HN
- **Developer sentiment** — track how the community reacts to new tools, frameworks, and launches
- **Trend detection** — identify rising technologies by analyzing top and best story patterns over time
- **Content research** — find high-engagement topics for technical blog posts or developer marketing
- **Job market analysis** — scrape the monthly "Who is Hiring?" threads for hiring trends
- **AI agent feeds** — supply structured HN data to LLM pipelines for tech news summarization

### Related Actors

| Actor | What it adds |
|-------|-------------|
| [Google News Scraper](https://apify.com/andok/google-news-scraper) | Broaden coverage beyond HN to mainstream news outlets |
| [RSS & Atom Feed Parser](https://apify.com/andok/rss-parser) | Parse the HN RSS feed or any other RSS source for simpler use cases |
| [Reddit Scraper](https://apify.com/andok/reddit-json-scraper) | Track discussions on Reddit for a complementary community signal |

# Actor input Schema

## `category` (type: `string`):

Which Hacker News story list to fetch. Options: top (front page), new (latest), best (highest-rated), ask (Ask HN), show (Show HN), job (hiring).

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

Maximum number of stories to fetch. The HN API provides up to 500 story IDs per category.

## `timeoutSeconds` (type: `integer`):

Per-request timeout for HN Firebase API calls in seconds.

## Actor input object example

```json
{
  "category": "top",
  "maxItems": 100,
  "timeoutSeconds": 15
}
```

# Actor output Schema

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

No description

## `resultsCsv` (type: `string`):

No description

## `run` (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 = {
    "category": "top"
};

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

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

```

## MCP server setup

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