Hacker News API - Stories, Points & Comments avatar

Hacker News API - Stories, Points & Comments

Pricing

$0.90 / 1,000 stories

Go to Apify Store
Hacker News API - Stories, Points & Comments

Hacker News API - Stories, Points & Comments

Hacker News has no keyword search and answers one item per request, so building a feed by hand costs hundreds of calls. Send a query, a story id or an item link and get clean JSON: title, url, points, comments, author and dates.

Pricing

$0.90 / 1,000 stories

Rating

0.0

(0)

Developer

Stas K

Stas K

Maintained by Community

Actor stats

1

Bookmarked

2

Total users

1

Monthly active users

5 days ago

Last modified

Features

Limited permissions

Share

Hacker News API

Hacker News has no keyword search and its public API answers one item per request, so building a feed of stories by hand costs hundreds of calls and a lot of glue. This actor turns a search query, a story id or an item link into clean JSON rows: title, url, points, comments, author and dates.

What you send

The queries field takes lines of two shapes, and they are told apart by shape, never by guessing:

  • bare digits (45751400) or an item link (https://news.ycombinator.com/item?id=1) are read as that one story;
  • anything else is a search query over stories (python, show hn).

What you get

One row per story with storyId, hnUrl, title, url, author, points, comments, createdAt (ISO 8601 UTC), itemType, query, matchesTotal, source and billable. A value the source does not publish stays null; nothing is invented.

comments is the comment count the search endpoint publishes. When a row comes from a story id or an item link the source answers with the comment tree instead of a count, so comments is null on that row: the same story found by a query and by its id therefore carries a number in one row and null in the other. That is the source, not a lost field.

What costs money

One delivered story is one paid event. The price is on the actor card.

These come back FREE, each with a reason in the reason field and no story fields:

  • NOT_FOUND - the source does not know that story id;
  • EMPTY - the query matched nothing;
  • INVALID_INPUT - the line is empty or a one-character query;
  • DUPLICATE - the story was already delivered by an earlier line in the same run (a query and a direct id, or two spellings of one link, are one story and one sale);
  • NOT_CHECKED_CAP - the line was cut by maxQueries or by the spending limit;
  • NOT_CHECKED_TIME - the run ran out of time before that line;
  • NOT_CHECKED_BILLING - the price list of the platform could not be read, so nothing was charged;
  • NOT_CHECKED_ERROR - the source refused or answered something unreadable. This is a statement about the source, not about your story: re-run later.

Limits

  • maxStories (default 30, max 200) cuts one search query. A query that fills the number exactly is counted in queriesCutByStoryCap, so a cut is visible and never silent.
  • maxQueries (default 25, max 200) cuts the whole run; lines beyond it get a free NOT_CHECKED_CAP.
  • One line costs one request to hn.algolia.com, and the remaining deadline is asked again before every request. A 429 from the source is retried once with a pause, and the retry reads Retry-After when the source sends it.

What this actor does not do

  • It does not read comment threads: a story row carries the comment count, not the comments. The comment endpoint answers a nested tree that can be hundreds of kilobytes, and selling a cut tree would be a promise this actor does not keep. An id that belongs to a comment or a poll option is refused as a free NOT_FOUND with the item type named, not sold as a story with a null title; a job and a poll do carry a title, so they are sold as story-shaped rows.
  • It does not log in, vote, post or use your Hacker News account.
  • It does not promise "all stories ever": the source reports matchesTotal (how many stories the query matched), and this actor delivers at most maxStories of them.

Run summary

The run writes RUN_SUMMARY into the default key-value store of the run, plus a copy under RUN_SUMMARY-<runId> in the named store hacker-news-summary, so two parallel runs do not overwrite each other. Counters include requested, attempted, delivered, chargedEvents, storiesDelivered (rows that really reached the dataset), storiesRead (rows the source returned, which is more when a batch is cut by the budget), squeezedByDeadline (requests the run's own deadline cut short, so the reason names the budget and not the source), deliveredUncharged, counterMismatch and stopReason.