# Hacker News API — stories, items & search (no key) (`synthetic.ia/hacker-news`) Actor

Hacker News as a clean HTTP API: top/new/best/ask/show/job stories resolved to full items, a single item by id, and full-text search (by relevance or date). Great for agents and tech-news monitoring. MCP-ready, no key. Pay per query.

- **URL**: https://apify.com/synthetic.ia/hacker-news.md
- **Developed by:** [Synthetic](https://apify.com/synthetic.ia) (community)
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 hn queries

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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?

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 API — stories, items & search (no key)

**Hacker News** as a clean HTTP API (and MCP tool): get the **top/new/best/Ask/Show/Jobs** story lists resolved to full items (title, URL, score, author, comments), fetch a single **item** by id, or run **full-text search** (by relevance or date). Ideal for tech-news monitoring, dashboards, newsletters and agents. **No API key.** Pay per query.

- 🔝 **Stories** — top / new / best / Ask HN / Show HN / Jobs, each item fully resolved (no extra calls).
- 🔎 **Search** — full-text across stories/comments, sorted by relevance or newest-first.
- 📄 **Item** — any story or comment by id, with clean text (no HTML).
- 🔗 Every result includes the HN discussion link.
- 💵 Pay per query · no key.

### The use case it was built for

Track what the tech world is talking about: feed an agent the current top stories, search for mentions of your product or a topic, or build a "trending on HN" panel. Clean, typed rows — no scraping.

### Sample output (`stories`, top)

```json
{
  "ok": true, "type": "top", "count": 20,
  "stories": [
    { "id": 49753878, "type": "story", "title": "…", "url": "https://…", "by": "…",
      "score": 342, "time": "2026-09-18T12:00:00.000Z", "comments": 128,
      "hnUrl": "https://news.ycombinator.com/item?id=49753878" }
  ]
}
```

### How to use

- **HTTP API (Standby):** POST or GET `/stories`, `/item`, `/search`. `GET /` returns help. Example: `GET /search?q=rust&byDate=true`.
- **Normal run:** pass `{ operation, ... }`; results land in the dataset + key-value store.
- **MCP tool:** expose it to your agent via Apify's MCP server.

### Input

- **operation** — `stories` · `item` · `search`.
- **type** — (stories) `top`/`new`/`best`/`ask`/`show`/`job`. **id** — (item) HN id.
- **q / byDate / tags** — (search) text, newest-first, and what to search. **limit** — cap results.

### Pricing

**Per query** from **$0.004** (down to $0.0015 on higher tiers). One call = one query (a `stories` call resolves many items in one query).

### Related Actors

- **[Wikipedia API](https://apify.com/synthetic.ia/wikipedia-api)** — encyclopedic context to pair with the news.

### FAQ

**Do I need a key?** No — HN's Firebase and Algolia APIs are keyless.

**How fresh?** Real-time; stories and search reflect current HN state.

**Comments?** Search with `tags=comment`, or fetch a comment by `item` id.

### Notes & limits

Data from Hacker News (hacker-news.firebaseio.com + hn.algolia.com). Up to 50 items per call.

# Changelog

This Actor's version history is a separate document: https://apify.com/synthetic.ia/hacker-news/changelog.md

# Actor input Schema

## `operation` (type: `string`):

What to fetch.

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

Which list.

## `id` (type: `integer`):

HN item id.

## `q` (type: `string`):

Text to search.

## `byDate` (type: `boolean`):

Newest first instead of by relevance.

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

What to search.

## `limit` (type: `integer`):

Max results (1-50).

## Actor input object example

```json
{
  "operation": "stories",
  "type": "top",
  "q": "openai",
  "byDate": false,
  "tags": "story",
  "limit": 20
}
```

# Actor output Schema

## `result` (type: `string`):

No description

## `runs` (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 = {
    "q": "openai"
};

// Run the Actor and wait for it to finish
const run = await client.actor("synthetic.ia/hacker-news").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 = { "q": "openai" }

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

```

## MCP server setup

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

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/yUw1pV0efntqbM40h/builds/5yP2a1wdpKw4u7umy/openapi.json
