# Hacker News Trend Aggregator (`claudethegoat/hacker-news-trend-aggregator`) Actor

Scrape Hacker News stories and comments via the official Algolia + Firebase APIs. Keyword search with date/points filters, plus live top/best/new/ask/show/job rankings. No credentials, no proxy required.

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

## Pricing

$1.00 / 1,000 result scrapeds

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 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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.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/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

## Hacker News Trend Aggregator

**Scrape Hacker News stories and comments at scale — keyword search, date/points filters, and live top/best/new/Ask/Show/Jobs rankings — through YC's official Algolia + Firebase APIs. No account, no API key, no proxy spend.**

The fastest way to turn Hacker News into structured, analysis-ready data for trend monitoring, market research, and AI pipelines. One input, one clean schema, pay only for the rows you keep.

### What it does

- **Keyword search** — query stories and/or comments by relevance or date, with a `since`/`until` date range and `minPoints`/`minComments` thresholds.
- **Live rankings** — pull the current **Top**, **Best**, **New**, **Ask HN**, **Show HN**, or **Jobs** lists straight from HN's Firebase feed.
- **Real depth on date search** — Algolia caps any single query at 1000 hits; this actor walks the time window automatically to pull **well beyond 1000 results per term** in `date` mode (verified live).
- **Unified output** — stories and comments in one dataset with consistent field names, ready for a database, a dashboard, or a RAG index.

### Why use this actor

| Alternatives | Their gap | This actor |
|---|---|---|
| Search-only HN scrapers | No live front-page / ranked lists | Keyword search **and** Top/Best/New/Ask/Show/Jobs |
| Generic multi-source scrapers | No HN-native fields | Native `points`, `num_comments`, and date filtering |
| Roll-your-own API calls | Algolia's 1000-hit wall, item hydration, retries, and charge logic to build and maintain | Time-window pagination, bounded-concurrency hydration, and pay-per-result — done |

Hacker News is the canonical early signal for startups, AI, and developer tooling. What trends here often trends everywhere weeks later — which makes it a high-value input for trend dashboards, competitive research, and AI training/retrieval sets.

**Built to never break your pipeline:** every upstream call is wrapped with retry-and-backoff on transient errors and graceful degradation on hard errors. If HN's API hiccups, the run keeps the results it already has and finishes cleanly — it does not crash to an empty, failed run.

### Output fields

| Field | Type | Description |
|---|---|---|
| `type` | string | `story`, `comment`, `job`, or `poll` |
| `object_id` | string | HN item ID |
| `url` | string | HN permalink (`news.ycombinator.com/item?id=…`) |
| `external_url` | string | Linked article URL (stories) |
| `title` | string | Story title (or parent story title for comments) |
| `text` | string | Self-text (Ask/Show) or comment body |
| `author` | string | HN username |
| `author_url` | string | HN user profile link |
| `points` | integer | Score |
| `num_comments` | integer | Comment count |
| `story_id` | string | Parent story ID (comments) |
| `story_title` | string | Parent story title (comments) |
| `created_at` | string | ISO 8601 timestamp |
| `created_at_i` | integer | Unix timestamp |
| `tags` | array | HN / Algolia tags |

### Usage examples

**High-signal AI stories from 2025, newest first (uses time-window depth to exceed 1000):**

```json
{
  "mode": "search",
  "searchTerms": ["AI agents", "LLM"],
  "itemType": "story",
  "sortBy": "date",
  "minPoints": 50,
  "since": "2025-01-01T00:00:00Z",
  "maxResults": 3000
}
````

**Live front-page snapshot for a daily dashboard:**

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

**Comment mining on a topic (sentiment / discourse analysis):**

```json
{
  "mode": "search",
  "searchTerms": ["kubernetes"],
  "itemType": "comment",
  "sortBy": "date",
  "maxResults": 2000
}
```

### Pricing

**Pay per result:** **$0.001 per item** (story or comment) pushed to your dataset.

Example: 10,000 items ≈ **$10**. You are charged only for rows delivered, and the run stops automatically when your spending limit is reached — no overrun.

### Technical notes

- Uses the official `hn.algolia.com` search API and `hacker-news.firebaseio.com` Firebase API — both free, public, and keyless.
- **Zero proxy cost** — official public APIs, no anti-bot bypass needed.
- **Depth:** `sortBy: "date"` walks the time window to pull far beyond Algolia's 1000-hit-per-query ceiling. `sortBy: "relevance"` returns up to Algolia's 1000 most-relevant hits per term (relevance order is not time-monotonic, so it cannot be windowed — use `date` for large pulls).
- Ranked lists (Top/Best/New/…) are hydrated with bounded concurrency for fast, low-latency runs.
- Resilient by design: transient failures (429 / 5xx / network) retry with exponential backoff; deterministic errors degrade gracefully and preserve partial results. Runs finish clean instead of failing.

### Common use cases

- **AI & startup intelligence** — track what the HN community is building and debating.
- **RAG pipelines** — feed fresh, high-signal tech discourse into retrieval-augmented systems.
- **Trend monitoring** — schedule daily pulls of Top/Best lists into a dashboard.
- **Developer-tooling & market research** — mine Show HN launches and Ask HN demand signals.
- **Sentiment & discourse analysis** — collect full comment threads on any topic.

### Data compliance

This actor accesses only **public** Hacker News data through YC's official, publicly documented APIs. No login credentials are used. Hacker News content is intentionally public; the data is suitable for research and business use.

# Actor input Schema

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

search = keyword query via the Algolia API. top/best/new/ask/show/job = live ranked lists from the official Firebase API.

## `searchTerms` (type: `array`):

Keywords or phrases to search. Each term runs as a separate query. Leave empty to return the most recent/relevant items overall.

## `itemType` (type: `string`):

Restrict search results to stories, comments, or both.

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

relevance = best match first; date = newest first.

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

Only return items with at least this many points. 0 = no filter.

## `minComments` (type: `integer`):

Only return items with at least this many comments. 0 = no filter.

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

Return only items created after this ISO 8601 timestamp (e.g. 2025-01-01T00:00:00Z).

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

Return only items created before this ISO 8601 timestamp (e.g. 2025-12-31T23:59:59Z).

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

Maximum results to return (per search term in search mode, or total for ranked lists). Higher values increase cost and run time.

## Actor input object example

```json
{
  "mode": "search",
  "searchTerms": [
    "AI agents",
    "LLM"
  ],
  "itemType": "story",
  "sortBy": "relevance",
  "minPoints": 0,
  "minComments": 0,
  "maxResults": 500
}
```

# 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 = {
    "searchTerms": [
        "AI agents",
        "LLM"
    ],
    "since": "",
    "until": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("claudethegoat/hacker-news-trend-aggregator").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 = {
    "searchTerms": [
        "AI agents",
        "LLM",
    ],
    "since": "",
    "until": "",
}

# Run the Actor and wait for it to finish
run = client.actor("claudethegoat/hacker-news-trend-aggregator").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 '{
  "searchTerms": [
    "AI agents",
    "LLM"
  ],
  "since": "",
  "until": ""
}' |
apify call claudethegoat/hacker-news-trend-aggregator --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Hacker News Trend Aggregator",
        "description": "Scrape Hacker News stories and comments via the official Algolia + Firebase APIs. Keyword search with date/points filters, plus live top/best/new/ask/show/job rankings. No credentials, no proxy required.",
        "version": "0.1",
        "x-build-id": "G6q7wMudw3l4Z2mGG"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/claudethegoat~hacker-news-trend-aggregator/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-claudethegoat-hacker-news-trend-aggregator",
                "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/claudethegoat~hacker-news-trend-aggregator/runs": {
            "post": {
                "operationId": "runs-sync-claudethegoat-hacker-news-trend-aggregator",
                "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/claudethegoat~hacker-news-trend-aggregator/run-sync": {
            "post": {
                "operationId": "run-sync-claudethegoat-hacker-news-trend-aggregator",
                "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": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "search",
                            "top",
                            "best",
                            "new",
                            "ask",
                            "show",
                            "job"
                        ],
                        "type": "string",
                        "description": "search = keyword query via the Algolia API. top/best/new/ask/show/job = live ranked lists from the official Firebase API.",
                        "default": "search"
                    },
                    "searchTerms": {
                        "title": "Search terms (search mode)",
                        "type": "array",
                        "description": "Keywords or phrases to search. Each term runs as a separate query. Leave empty to return the most recent/relevant items overall.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "itemType": {
                        "title": "Item type (search mode)",
                        "enum": [
                            "story",
                            "comment",
                            "all"
                        ],
                        "type": "string",
                        "description": "Restrict search results to stories, comments, or both.",
                        "default": "story"
                    },
                    "sortBy": {
                        "title": "Sort by (search mode)",
                        "enum": [
                            "relevance",
                            "date"
                        ],
                        "type": "string",
                        "description": "relevance = best match first; date = newest first.",
                        "default": "relevance"
                    },
                    "minPoints": {
                        "title": "Minimum points (search mode)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Only return items with at least this many points. 0 = no filter.",
                        "default": 0
                    },
                    "minComments": {
                        "title": "Minimum comments (search mode)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Only return items with at least this many comments. 0 = no filter.",
                        "default": 0
                    },
                    "since": {
                        "title": "Since date (search mode)",
                        "type": "string",
                        "description": "Return only items created after this ISO 8601 timestamp (e.g. 2025-01-01T00:00:00Z)."
                    },
                    "until": {
                        "title": "Until date (search mode)",
                        "type": "string",
                        "description": "Return only items created before this ISO 8601 timestamp (e.g. 2025-12-31T23:59:59Z)."
                    },
                    "maxResults": {
                        "title": "Max results",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Maximum results to return (per search term in search mode, or total for ranked lists). Higher values increase cost and run time.",
                        "default": 500
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
