Hacker News API

Get Hacker News data as clean JSON with one key: 25 endpoints, 1 to 5 credits per call, the same response shape as every other platform.

What you get#

Onekey exposes Hacker News as 25 endpoints behind one API key: 4 endpoints return one record (data is an object) and 21 endpoints return a list (data is an array). Every answer uses the same envelope (success, data, metadata, error), the cost is reported in metadata.credits_charged, and fields are mapped onto the unified schema so the code you write for Hacker News also works for the rest of the messaging & communities category.

Endpoints#

EndpointWhat it doesParametersCreditsStatus
ask_hnLatest Ask HN posts.cursor5stable
askstoriesLatest Ask HN story ids.-5stable
author_commentsComments written by a Hacker News user.user*, cursor5stable
author_submissionsStories submitted by a Hacker News user.user*, cursor5stable
beststoriesBest story ids on Hacker News.-5stable
front_pageHacker News front page (Algolia).cursor5stable
itemA Hacker News item (Algolia, with points and counts).id*1stable
item_commentsTop-level comments of a Hacker News item (children of the comment tree).id*5stable
item_firebaseA Hacker News item (official Firebase API).id*1stable
jobsHacker News job posts.cursor5stable
jobstoriesLatest job story ids.-5stable
maxitemCurrent maximum Hacker News item id.-1stable
newstoriesNewest story ids on Hacker News.-5stable
pollsHacker News polls.cursor5stable
searchSearch Hacker News stories by keyword.q*, cursor1stable
search_by_dateSearch Hacker News stories, newest first.q*, cursor5stable
search_commentsSearch Hacker News comments.q*, cursor5stable
search_urlStories that link to a URL or domain.q*, cursor5stable
show_hnLatest Show HN posts.cursor5stable
showstoriesLatest Show HN story ids.-5stable
story_commentsComments of a Hacker News story (flat, newest first).id*, cursor1stable
topstoriesTop story ids on Hacker News.-5stable
updated_profilesRecently changed Hacker News usernames.-5stable
updatesRecently changed Hacker News item ids.-5stable
userFetch a Hacker News user profile.username*1stable

A * marks a required parameter. Each endpoint name links to its reference page with the full parameter table, caching window and a recorded response.

Make a request#

This calls hackernews.item (1 credit, stable). Replace YOUR_API_KEY with your key; sign up, no card. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack.

curl "https://api.onekey.dev/v1/hackernews/item?id=8863" \
  -H "x-api-key: YOUR_API_KEY"

Fields you get back#

These unified fields come back from Hacker News, with the same names as on every other platform. The count is how many of its 25 mapped endpoints return the field; a field the source lacks is null, never missing. 1 platform-specific field (ext.<name>) come on top, documented on each endpoint page.

FieldTypeEndpoints
content.idstring23
author.usernamestring17
content.createdAtISO 8601 date15
content.textstring15
content.titlestring14
content.urlURL14
engagement.likesinteger14
engagement.commentsinteger10
content.threadIdstring3
author.idstring2
content.parentIdstring1
content.typestring1

The full schema is in Unified schema.

Pricing#

Hacker News calls cost 1 to 5 credits, flat per endpoint. Free when served from cache (0.2 credit for a cached response over 100 KB). Invalid, failed or not-found calls are not charged. See pricing for credit packs.