Hacker News API
Official Firebase API for Hacker News stories, comments and users.
What it does
The official Hacker News API (hosted on Firebase) exposes every item — stories, comments, jobs, polls — and user profiles, plus the current top/new/best/ask/show/job story lists and the latest item id. It is read-only and returns raw item trees.
Base URL
Authentication
None. No key, no rate limit. For full-text search use the separate Algolia HN Search API (https://hn.algolia.com/api/v1/search), also key-less.
Code examples
curl -s https://hacker-news.firebaseio.com/v0/topstories.json # array of ids curl -s https://hacker-news.firebaseio.com/v0/item/8863.json # one item curl -s "https://hn.algolia.com/api/v1/search?query=rust&tags=story"
import requests
ids = requests.get("https://hacker-news.firebaseio.com/v0/topstories.json", timeout=10).json()
for i in ids[:5]:
it = requests.get(f"https://hacker-news.firebaseio.com/v0/item/{i}.json", timeout=10).json()
print(it.get("score"), it.get("title"), it.get("url"))Rate limits & quotas
No documented rate limit, but fetching a big story with all its comments means one request per item — hundreds of calls. Fetch in parallel, cache, and consider the Algolia API (/items/{id} returns a whole comment tree in one call) for that use case.
Key response fields
| (list endpoints) [ids] | Arrays of item ids, ranked |
| item.type | story, comment, job, poll, pollopt |
| item.title / url / score / by / time | Story fields (time is Unix seconds) |
| item.kids[] | Child comment ids — recurse to build the thread |
| item.text | HTML body for comments and text posts |
Common errors
| null | Deleted or non-existent item id returns JSON null, not a 404. |
| (deep recursion) | Comment trees can be thousands of nodes — bound your depth or use Algolia. |
| (no write API) | You cannot post, vote or comment through the API. |
When to use it (and alternatives)
The go-to for HN readers, ‘show me the front page’ widgets, and dev-news aggregators. Use the Firebase API for live lists and individual items, and the Algolia API for search and for pulling a full comment tree at once.
FAQ
How do I get a story's comments efficiently?
The Firebase API needs one request per comment. Instead call https://hn.algolia.com/api/v1/items/{story_id}, which returns the entire nested comment tree in a single response.
Is there a rate limit?
None is published, and the API is designed to be hammered via Firebase’s CDN. Still cache list endpoints for a minute or two rather than polling every second.
Can I search Hacker News?
Not via the official API. Use Algolia’s hn.algolia.com/api/v1/search (by relevance) or /search_by_date (chronological), with tags and numeric filters.
New to APIs?
Short guides for working with this API — and any other.