Hacker News Search & Threads: Stories, Comments & Users avatar

Hacker News Search & Threads: Stories, Comments & Users

Pricing

from $0.40 / 1,000 hacker news rows

Go to Apify Store
Hacker News Search & Threads: Stories, Comments & Users

Hacker News Search & Threads: Stories, Comments & Users

Search Hacker News stories, comments and users, fetch a story's full comment tree, or read the front page, from the official free Algolia HN API. Filter by query, tag, date range, points and author. Flat rows out, one per story or comment. Free on errors.

Pricing

from $0.40 / 1,000 hacker news rows

Rating

0.0

(0)

Developer

Data Done Right

Data Done Right

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

12 days ago

Last modified

Features

Limited permissions

Share

This Hacker News search Actor reads the official, free Algolia HN Search API (hn.algolia.com/api) and returns flat rows: search stories and comments by keyword, tag, date range, points or author, export a story's full comment tree, look up user profiles, or read the front page. No API key, no browser, no proxy.

What it does not do. It only reads what the public Algolia HN API offers. It does not log in, post, vote or read private data. It does not scrape news.ycombinator.com pages, and it is not real-time monitoring (Algolia's index can lag HN by a short while). A relevance search returns at most 1,000 hits (an API limit); only newest-first searches can go further back. User rows carry karma and the "about" text only, no submission history (use search with author for that). Deleted and dead comments are not in the data. It is not affiliated with Y Combinator, Hacker News or Algolia.

What you get

  • Four modes: search, comments (the whole thread of one or more stories), user, frontPage.
  • One row per story, comment or user, with the same fields in every row (author, text, points, story title and link, parent id, depth, time, HN link).
  • Comment text as plain text by default, links kept in full. Failed inputs go to a FAILED record and cost nothing.

How to search Hacker News by keyword and date

  1. Keep mode search, type a query (for example apify) and choose a contentType (stories, comments, Ask HN, Show HN, jobs, polls or everything).
  2. Optionally set dateFrom and dateTo (UTC days), minPoints, minComments or author.
  3. Set sortBy to date for newest first. Run it and read the dataset.

How to export all comments of a Hacker News story

Use mode comments and put story ids or links in storyIds (8863 or https://news.ycombinator.com/item?id=8863). Each story costs one API request, and the tree is flattened depth-first in reading order: depth 1 is a top-level comment, parentId points to the parent. maxDepth limits the nesting, includeStoryRow adds the story itself as a first row.

How to look up Hacker News user profiles

Use mode user and list the names in usernames. You get karma and about. Unknown names produce no row and no charge; they are listed in FAILED. (The API answers HTTP 500 for unknown names, so a short outage looks the same.)

How to get the Hacker News front page

Use mode frontPage. You get the stories the API currently tags as front page, in the order the API returns them.

Input

FieldDefaultWhat it does
modesearchsearch, comments, user or frontPage. Required.
queryapify (prefill)Words to search for.
contentTypestoriesstories, comments, ask_hn, show_hn, jobs, polls, all.
sortByrelevancerelevance (max 1,000 hits) or date (newest first, can read further back).
dateFrom, dateToemptyUTC days, YYYY-MM-DD, both inclusive.
authoremptyOnly items by this user.
inStoryIdemptySearch inside one story's thread.
minPoints, minComments0Filters (comments have no points).
storyIdsemptyMode comments: story ids or links.
maxDepth0Comment tree depth limit, 0 = whole tree.
includeStoryRowtrueAdd the story as a row before its comments.
usernamesemptyMode user: user names.
plainTexttrueComments as plain text instead of HTML.
maxItems100Most rows delivered and charged (max 100,000).
maxRequests3000Safety cap on API requests per run.

Input example:

{"mode": "search", "query": "apify", "contentType": "stories", "maxItems": 20}

Output

From a real local run of the input above (the first row):

{
"type": "story",
"id": 4058874,
"hnUrl": "https://news.ycombinator.com/item?id=4058874",
"title": "HackerNews API: What if HN does not have API? Make API on the fly with APIfy",
"author": "sathish316",
"text": null,
"points": 132,
"numComments": 49,
"storyId": 4058874,
"storyTitle": "HackerNews API: What if HN does not have API? Make API on the fly with APIfy",
"storyUrl": null,
"parentId": null,
"depth": null,
"externalUrl": "http://apify.heroku.com/resources/4fca535156983f0001000002",
"createdAt": "2012-06-02T19:16:33+00:00",
"createdAtUnix": 1338664593,
"karma": null,
"about": null
}

A comment row from the tree of story 8863 (real run):

{"type": "comment", "id": 8865, "hnUrl": "https://news.ycombinator.com/item?id=8865", "author": "dhouston",
"text": "oh, and a mac port is coming :)", "storyId": 8863, "storyTitle": "My YC app: Dropbox - Throw away your USB drive",
"parentId": 8863, "depth": 1, "createdAt": "2007-04-04T19:22:55+00:00", "createdAtUnix": 1175714575}

Fields that do not apply to a row type are null (shortened above). The SUMMARY record counts rows and API requests; FAILED lists inputs that could not be read; NOTES explains skipped items and limits.

Rate limits and respect for the API

The API allows 10,000 requests per hour per IP. This Actor sends at most 2 requests per second, one at a time, stops at maxRequests (default 3,000), waits for Retry-After on HTTP 429 and gives up after a few attempts. It reads robots.txt of hn.algolia.com first (the site has none at the time of writing, which allows the API), talks only to hn.algolia.com over https, never follows redirects and uses no proxy. Many runs sharing one IP can still hit the hourly limit; if so the run ends with the rows already read and a clear message.

Use with the Apify API, MCP, n8n and Make

Python:

from apify_client import ApifyClient
client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("data-done-right/hacker-news-search").call(run_input={
"mode": "search", "query": "web scraping", "contentType": "comments", "sortBy": "date", "maxItems": 200})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
print(row["createdAt"], row["author"], (row["text"] or "")[:80])

JavaScript:

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: '<APIFY_TOKEN>' });
const run = await client.actor('data-done-right/hacker-news-search').call({ mode: 'comments', storyIds: ['8863'] });
const { items } = await client.dataset(run.defaultDatasetId).listItems();

In n8n or Make use the Apify node with the Actor name and the same JSON. With Apify's MCP server (mcp.apify.com) an AI assistant can call it, for example "what did Hacker News say about my product this month?".

Use cases

  • Track mentions of your product, a competitor or a technology in stories and comments, newest first.
  • Pull a whole discussion thread into a table or an LLM prompt for sentiment or objection mining.
  • Read the comments of the monthly "Ask HN: Who is hiring?" thread (comments mode with its story id) into a spreadsheet.
  • Collect the most upvoted Show HN posts in a date range (minPoints).
  • Look up the karma of a list of HN accounts, or list everything one author posted.

How much does it cost

Pay per event: $0.0005 per row delivered (hn-row, $0.50 per 1,000). Failed inputs, duplicates and empty items are free. Plan discounts apply (Silver about 10%, Gold and higher about 20%).

  • 1,000 rows: $0.50.
  • 10,000 rows: $5.
  • 100,000 rows: $50.

maxItems caps rows and cost, and if you set a maximum spend per run the Actor stops cleanly when it is reached. Apify platform usage is included in the price.

FAQ

Is this the official Hacker News API?

It uses the official search API run by Algolia for Hacker News (hn.algolia.com/api), free and without a key. It is the data behind the HN search page, not the Firebase API.

All of Hacker News history is indexed. A relevance search returns the best 1,000 hits only. With sortBy: date the Actor moves through time and can return more than 1,000 rows. That continuation is covered by unit tests with a mocked API; live, only one run of about 500 rows was tried.

Is the data complete and real-time?

No. Algolia's index can trail HN, and deleted or dead items are missing. Use it for research and monitoring on an hourly scale, not for exact counts.

Why do some comment rows have no depth?

depth is only known in comment-tree mode. Search hits do not carry it; they carry parentId and storyId.

What happens if the API fails or I hit the rate limit?

Requests are retried with backoff. If they keep failing, the run ends with the rows already read, a status message and the error in SUMMARY. Rows delivered are charged; nothing else is.

Can I read private or personal data?

No. Only public items and the public profile fields (name, karma, about) are returned.

  • RSS Feed Reader & Monitor: RSS/Atom to JSON, Full Text to follow feeds of blogs and news sites next to Hacker News.
  • Remote Jobs & Work From Home Jobs: 5 Boards, Salaries, Alerts for job boards beyond the Hacker News hiring threads.
  • Keyword Extractor: Extract Keywords & Keyphrases from Text to pull topics out of the comment text you collect.