# Hacker News Search (Stories, Comments, Dates) (`jayraj0975/hackernews-search`) Actor

Search Hacker News via the official Algolia HN API. Returns stories and comments with title, url, author, points, comment counts, ISO dates, and plain text. Pay-per-result.

- **URL**: https://apify.com/jayraj0975/hackernews-search.md
- **Developed by:** [Jay Gaikwad](https://apify.com/jayraj0975) (community)
- **Categories:** News, Agents
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 results

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 Search — stories & comments via Algolia HN API (public)

Search Hacker News through the public **Algolia HN Search API** (`https://hn.algolia.com/api/v1/`) and get structured JSON results — stories and comments with title, URL, author, points, comment counts, ISO dates, and plain-text bodies.

This is an **unofficial** Actor. It is **not affiliated with, endorsed by, or supported by** Y Combinator, Hacker News, or Algolia. The Algolia HN Search API is a public, community-run endpoint; it is not operated by Hacker News.

No API key is required. No login, no captchas, public data only.

### What it does

- Queries `GET https://hn.algolia.com/api/v1/search` (relevance) or `/search_by_date` (newest first).
- Supports full-text `query`, `tags` (`story`, `comment`, `ask_hn`, `show_hn`), date filter (`sinceDays` via `created_at_i` numeric filter) and score filter (`minPoints` via `points` numeric filter).
- Paginates the API by page and stops at `maxItems`.
- Normalizes each hit into:
  - `objectId` — HN item ID
  - `type` — `story` or `comment`
  - `title`, `url` — story title and external link when present
  - `author`, `points`, `numComments`
  - `createdAt` — ISO 8601 UTC (`YYYY-MM-DDTHH:MM:SSZ`)
  - `storyText` / `commentText` — plain text with HTML stripped
  - `hnUrl` — canonical `https://news.ycombinator.com/item?id=…`
- Deduplicates by `objectId` across pages.
- Makes **at most 1 request per second** to the upstream endpoint.
- Fails loudly with `LayoutChangedError` when the API response shape drifts; it does not push empty or malformed items in that case.

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `query` | string | `""` | Full-text search query. |
| `tags` | string | `"story"` | Algolia HN tag filter: `story`, `comment`, `ask_hn`, `show_hn`. Can combine. |
| `sortBy` | string | `"relevance"` | `relevance` → `/search`; `date` → `/search_by_date`. |
| `sinceDays` | integer | unset | Only return items created within the last N days. |
| `minPoints` | integer | unset | Only return items with at least N points. |
| `maxItems` | integer | `100` | Hard cap on returned results (max 1000). |

### Example output (illustrative)

Example record (illustrative; values vary):

```json
{
  "objectId": "40000001",
  "type": "story",
  "title": "Show HN: A small tool for reading HN threads",
  "url": "https://example.com/show-hn",
  "author": "hn_user",
  "points": 42,
  "numComments": 7,
  "createdAt": "2026-11-10T18:12:00Z",
  "storyText": "",
  "commentText": null,
  "hnUrl": "https://news.ycombinator.com/item?id=40000001"
}
```

Numbers, usernames and IDs above are fabricated for format illustration only; run the Actor for real data.

### Pricing

**$2 per 1,000 results.** Every dataset item pushed to the run's dataset = one billed result, charged via Apify's default dataset-item push event. Empty runs and hard errors are not billed. Note that not-found or invalid-input rows that are pushed to the dataset count as billed results like any other row.

### Limits

- Politeness: at most 1 request per second to the upstream Algolia endpoint.
- `maxItems` per run capped at 1,000.
- Only items indexed by the Algolia HN Search API are returned; deletions and edits on HN may lag or not appear.
- Upstream availability and rate limits are outside this Actor's control; on 429 or schema drift the Actor fails loudly rather than push bad rows.
- Data source terms: the Algolia HN Search API is a public, community-run service; its terms may change. Check the upstream API terms before commercial redistribution. Uncertainty: coverage of the HN index, rate-limit thresholds, and terms of use are outside this Actor's control and may change without notice.

### Disclaimer

Unofficial Actor. Not affiliated with, endorsed by, or supported by Y Combinator, Hacker News, or Algolia. Reads the public Algolia HN Search API only; no login, no captchas.

Public data only. Author names and comment bodies are user-generated content that the upstream API already publishes publicly; this Actor reproduces them verbatim as returned by the API and collects no other personal data.

Provided "as is", without warranty of any kind. No guarantees are made about completeness, accuracy, ordering, moderation status, or continued availability of the upstream service.

# Actor input Schema

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

Full-text search query for Hacker News (matches story titles and comment text).

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

Algolia HN tag filter. Use 'story' for stories, 'comment' for comments, or 'ask_hn' / 'show_hn' for those specific story types. Can combine, e.g. 'story'.

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

'relevance' uses the /search endpoint; 'date' uses the /search_by_date endpoint (newest first).

## `sinceDays` (type: `integer`):

Optional: only return items created within the last N days (uses created_at_i numeric filter).

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

Optional: only return items with at least this many points (uses points numeric filter).

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

Maximum number of results to return. The actor paginates the HN API by page and stops at this cap.

## Actor input object example

```json
{
  "tags": "story",
  "sortBy": "relevance",
  "maxItems": 100
}
```

# Actor output Schema

## `results` (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 = {};

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

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

```

## MCP server setup

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