Guide · Open source
How to use the Hacker News API: endpoints, items and users
Updated · written with AI from the project's own documentation and checked against our catalogue data
The Hacker News API is an official, read-only way to pull public Hacker News data such as stories, comments, jobs, polls and user profiles, delivered in near real time through Firebase. This guide explains the URI structure, the main item and user fields, and how to request data from the API. By the end you will know how to fetch an item or user and how to read the JSON that comes back.
Quick start
- 1Read the README. Review the overview and the URI and versioning section to learn the v0 base URI and compatibility rules.
- 2Clone the repository. Run git clone https://github.com/HackerNews/API to get the documentation and samples locally.
- 3Choose a Firebase client. Pick a Firebase client library for your platform, as the README recommends, or use plain HTTP requests.
- 4Fetch an item. Request https://hacker-news.firebaseio.com/v0/item/<id>.json and read fields such as type, title and kids.
- 5Fetch a user. Request https://hacker-news.firebaseio.com/v0/user/<username>.json, remembering that usernames are case-sensitive.
- 6Walk the comment tree. Load each id in kids as its own item to build a thread, since comment counts are not always returned directly.
What the Hacker News API provides
The API exposes public Hacker News data. Stories, comments, jobs, Ask HNs and polls are all stored as items, and user profiles are available for users who have public activity on the site.
This repository is documentation and samples for the API, not a ready-made app or client. The README describes only reading public data, so the API offers no write access.
- Items: stories, comments, jobs, Ask HNs, polls and poll options
- Users: profiles with a case-sensitive id, creation time, karma, optional about text and a list of submissions
- Access through Firebase client libraries for Android, iOS, the web and servers
Understand the base URI and versioning
Every request starts with the v0 base URI: https://hacker-news.firebaseio.com/v0/. The README warns that future changes may not be backward compatible, which is why versioning is used.
Only removal of a non-optional field or a change to an existing field counts as an incompatible change. Clients should ignore fields they do not expect, so your code should not break when new fields appear. The README also states that there is currently no rate limit.
https://hacker-news.firebaseio.com/v0/Fetch an item: stories, comments, jobs and polls
Items live under /v0/item/<id>.json, where the id is a unique integer. The examples in the README add ?print=pretty to the URL to make the JSON readable in a browser.
Key fields include id, type (one of job, story, comment, poll or pollopt), by for the author, time as Unix time, and text as HTML. Stories also carry title, url and score, while stories and polls include descendants for the total comment count. A comment has a parent, and kids lists the ids of its child comments in ranked display order.
Fetching a child means loading its id as a separate item, so reading a full thread takes multiple requests. The README notes that the total comment count is not returned directly for every item; you count it by traversing the tree.
- kids: ids of an item's comments, in ranked display order
- parent: either another comment or the relevant story
- descendants: total comment count for stories or polls
- parts: related pollopts for a poll, in display order
https://hacker-news.firebaseio.com/v0/item/8863.json?print=prettyFetch a user profile
User profiles live under /v0/user/. The id is the username and is case-sensitive, so jl and JL are not the same request. Only users with public activity, such as comments or story submissions, are available.
The profile includes created (Unix time), karma, an optional about field in HTML, and submitted, which lists the ids of the user's stories, polls and comments.
https://hacker-news.firebaseio.com/v0/user/jl.json?print=prettyUse a Firebase client library instead of raw requests
The README recommends using a Firebase client library where you can. The libraries handle networking efficiently and can raise events when data changes, which suits a feed or reader that updates over time.
The repository's install method is listed as clone-based. The only install command given in the source is to clone the repository, so start there and then consult the linked Firebase setup guides for Android, iOS, the web or servers.
- Clone the repository to read the documentation and samples
git clone https://github.com/HackerNews/APIKnow the limits of the design
The README is frank that the v0 API is essentially a dump of internal data structures and is not the ideal public API. Some operations take extra work. For example, the newest page starts at the maximum item id and walks backward, keeping only top-level stories.
The README says it is still possible to implement most of Hacker News with the API. Plan for multi-step requests and for ignoring fields you do not recognize. For bugs, the README asks you to email api@ycombinator.com.
What people use it for
- Building a Hacker News reader or widget that shows stories and comments
- Creating a bot that posts or monitors new stories by type
- Analyzing public Hacker News activity such as user submissions and karma
- Feeding Hacker News content into your own dashboards through Firebase
Frequently asked questions
Is the Hacker News API free to use?
The README does not list pricing, and it states there is currently no rate limit. The source does not state a licence for the API data itself; the repository is listed under the MIT licence.
Do I need an API key to use the Hacker News API?
The README does not mention an API key or any prerequisites. Its examples are plain URLs under the v0 base URI.
Can I post or vote through the Hacker News API?
No. The README describes only reading public data, so it does not offer write access.
How do I get all the comments on a story?
Start with the story's kids list, then load each child id as an item and repeat for its kids. The README notes that you traverse the tree to count comments.
Why does the Hacker News API feel awkward?
The README says the v0 API is essentially a dump of internal data structures and was released in the time available. It is not the ideal public API, but it is workable.
What are the alternatives to the official Hacker News API?
Comparable projects listed for this item include the Algolia Hacker News Search API, hn-scraper and Hacker News Firebase clients. This source does not compare them in detail.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this API if you are a developer building a Hacker News reader, widget, bot or analysis tool and you want official read access to public data. Pick another option if you need write access, a polished and easy-to-use interface, or a ready-made app, since this repository is documentation and samples rather than a client.
Install options & downloads