# Hacker News Scraper - Search Stories, Comments and Show HN (`turboextract/hacker-news-search`) Actor

Hacker News stories, comments, Show HN, Ask HN and front page posts by keyword, author, points, comment count and date: title, link, domain, points, comments, author, text and HN link. Uses the official Hacker News search API. Fast, no login.

- **URL**: https://apify.com/turboextract/hacker-news-search.md
- **Developed by:** [Moses Ndambuki](https://apify.com/turboextract) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 story or comment delivereds

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: Search Stories, Comments and Show HN

**Search Hacker News stories, comments, Show HN, Ask HN, jobs and the live front page by keyword, author, points, comment count and date.** Each row has the title, link, domain, points, comments, author, text and HN link. Uses the official Hacker News search API, so runs are fast and there is no login.

In one test, the actor returned 250 recent stories about web scraping, 19 comments mentioning a product from the past 60 days, and the 30 most-voted Show HN scraping launches.

***

### Who this is for

- **Founders and marketers** tracking mentions of their product and competitors
- **Developer relations teams** finding discussions to join
- **Investors and analysts** spotting launches with traction on Show HN
- **Researchers** studying developer sentiment and trends
- **AI and data teams** collecting high-quality technical discussion

***

### What you get

```json
{
  "type": "story",
  "id": 7066479,
  "title": "Show HN: Kimono – Never write a web scraper again",
  "url": "http://kimonify.kimonolabs.com/...",
  "domain": "kimonify.kimonolabs.com",
  "hnUrl": "https://news.ycombinator.com/item?id=7066479",
  "author": "username",
  "points": 717,
  "comments": 230,
  "createdAt": "2014-01-15T21:59:50Z",
  "text": null,
  "query": "scraper"
}
```

Comment rows also carry `storyId`, `storyTitle`, `storyUrl` and `parentId`.

***

### How it works

```mermaid
flowchart LR
    A[Search queries] --> C[Official HN search API]
    B[Type, author, points, date] --> C
    C --> D[Newest first or most relevant]
    D --> E[Story and comment rows]
```

***

### Quick start

1. Click **Try for free**.
2. Add **Search queries**, like `web scraping` or your product name.
3. Pick a **Type**: stories, comments, Show HN, Ask HN, jobs, polls or the front page.
4. Optional: set **Minimum points**, **Authors** or **Posted within (days)**.
5. Click **Start**, then export to CSV, JSON or Google Sheets.

#### API

```bash
curl -X POST "https://api.apify.com/v2/acts/Turboextract~hacker-news-search/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "searchQueries": ["your product"],
    "contentType": "comment",
    "postedWithinDays": 1
  }'
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("Turboextract/hacker-news-search").call(run_input={
    "searchQueries": ["open source"],
    "contentType": "show_hn",
    "minPoints": 100,
    "sort": "relevance",
})
for s in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(s["points"], s["title"], s["hnUrl"])
```

***

### Input

| Field | Default | What it does |
|---|---|---|
| `searchQueries` | – | Keywords. Empty lists the newest items of the type |
| `contentType` | story | Stories, comments, Show HN, Ask HN, front page, jobs or polls |
| `sort` | date | Newest first or most relevant |
| `authors` | – | Only these HN usernames |
| `minPoints` | 0 | Stories only |
| `minComments` | 0 | Stories only |
| `postedWithinDays` | 0 (all) | Only recent items |
| `maxResultsPerQuery` | 100 | Per query |
| `maxResults` | 500 | Total cap per run |

***

### Pricing

**$0.003 per story or comment delivered.** 1,000 items cost $3.

| Option | 1,000 items |
|---|---|
| **Hacker News Scraper** | **$3**, stories, comments and front page in one actor |
| Other Hacker News actors on Apify | $0.20 to $2.35 |
| Social listening tools | $50+ a month |

***

### Use cases

- **Mention alerts**: your product and competitors in comments, every hour
- **Launch research**: top Show HN posts in your category
- **Content ideas**: Ask HN questions about your topic
- **Trend tracking**: story counts and points for a keyword over time
- **Community outreach**: authors who comment often on your topic

***

### Tips

- Newest-first search can page past 1,000 results, so large backfills work.
- Use quotes for exact phrases, like `"web scraping"`.
- Dedupe on `id` across scheduled runs.
- For HN "Who is hiring" job posts, use [HN Hiring Leads](https://apify.com/Turboextract/hn-hiring-leads).

***

### Pairs well with

- [HN Hiring Leads](https://apify.com/Turboextract/hn-hiring-leads): companies hiring in the monthly HN threads
- [GitHub Trending Repos](https://apify.com/Turboextract/github-trending-repos): the projects HN is talking about
- [Google News Scraper](https://apify.com/Turboextract/google-news-feed): press coverage of the same topics

***

### FAQ

**Do I need a Hacker News account?** No. The actor uses the official public search API.

**How far back does it go?** To the start of Hacker News in 2007.

**Does it return full comment threads?** It returns each matching comment with its story and parent IDs. Search by type `comment` with a query to find the ones you need.

**How fast is it?** A few hundred items take seconds.

**Is it legal?** It uses Hacker News' public search API for public posts.

***

### Support

- Docs and examples: https://github.com/andersonjames38phd-cpu/hacker-news-search
- Community Discord: https://discord.gg/8SrXSCpvgj

Built and maintained by [Turboextract](https://apify.com/Turboextract) on the Apify platform.

# Actor input Schema

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

Keywords to search titles, links and text, like web scraping or your product name. Leave empty to list the newest items of the chosen type.

## `contentType` (type: `string`):

What to search.

## `sort` (type: `string`):

Newest first, or most relevant first.

## `authors` (type: `array`):

Only items by these HN usernames.

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

Stories only. Skip stories with fewer points.

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

Stories only. Skip stories with fewer comments.

## `postedWithinDays` (type: `integer`):

Only items from the last N days. 0 means no limit.

## `maxResultsPerQuery` (type: `integer`):

Per search query, or for the whole run when no query is given.

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

Stop after this many items in total. You only pay for what is delivered.

## Actor input object example

```json
{
  "searchQueries": [
    "web scraping"
  ],
  "contentType": "story",
  "sort": "date",
  "minPoints": 0,
  "minComments": 0,
  "postedWithinDays": 0,
  "maxResultsPerQuery": 100,
  "maxResults": 500
}
```

# Actor output Schema

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

One row per story or comment with points, comment count, author, link and text.

# 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 = {
    "searchQueries": [
        "web scraping"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("turboextract/hacker-news-search").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 = { "searchQueries": ["web scraping"] }

# Run the Actor and wait for it to finish
run = client.actor("turboextract/hacker-news-search").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 '{
  "searchQueries": [
    "web scraping"
  ]
}' |
apify call turboextract/hacker-news-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,turboextract/hacker-news-search"
        }
    }
}
```

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/8pQ8bYV3oJ5YJlcsG/builds/ZDVdIlzVQEKTOB7gA/openapi.json
