How to hit the Hacker News API

The official Hacker News API is a read-only Firebase database at https://hacker-news.firebaseio.com/v0: everything — stories, comments, polls, jobs — is an item with a numeric id. For search, HN uses Algolia's public API. Every example below runs as-is.

Authentication

None, and no stated rate limit on the Firebase API. Lists like topstories return ids only; fetch each item separately.

Full reference: https://github.com/HackerNews/API

Top stories

Ids of the current front page, best first. The full list is 500; Firebase's orderBy + limitToFirst trims it.

curl 'https://hacker-news.firebaseio.com/v0/topstories.json?orderBy=%22$key%22&limitToFirst=5'
Run in PostTaco
Example response (trimmed)
[
  49820134,
  49817469,
  49821196,
  49820065,
  49821925
]

Get an item

A story, comment, or poll by id. kids are the ids of its direct replies (trimmed below). Item 8863 is Dropbox's launch post.

curl https://hacker-news.firebaseio.com/v0/item/8863.json
Run in PostTaco
Example response (trimmed)
{
  "by": "dhouston",
  "descendants": 71,
  "id": 8863,
  "kids": [
    9224,
    8917,
    8884,
    8887,
    8952
  ],
  "score": 104,
  "time": 1175714200,
  "title": "My YC app: Dropbox - Throw away your USB drive",
  "type": "story",
  "url": "http://www.getdropbox.com/u/2/screencast.html"
}

Get a user

Karma, account age (Unix time), bio, and every item they've submitted (trimmed below).

curl https://hacker-news.firebaseio.com/v0/user/pg.json
Run in PostTaco
Example response (trimmed)
{
  "id": "pg",
  "created": 1160418092,
  "karma": 157316,
  "about": "Bug fixer.",
  "submitted": [
    39667625,
    37278578,
    37278345
  ]
}