gitmyhub

API

★ 13k updated 1y ago

Documentation and Samples for the Official HN API

Official documentation for the Hacker News public API, which lets developers fetch stories, comments, job posts, and user profiles from the site in near real time through Firebase.

FirebaseJSONsetup: easycomplexity 1/5

This repository contains the official documentation for the Hacker News public API. Hacker News is a social news site run by Y Combinator where people share and discuss technology articles, ask questions, and post job listings. The API makes that data available to developers in near real time through Firebase, a database and networking service.

Everything on Hacker News is represented as an item: stories, comments, job postings, polls, and poll options all share the same basic structure. Each item has a numeric ID, and you retrieve one by making a request to a URL that includes that ID. The response is a JSON object with fields like the author's username, the creation time, the text or URL, the score, and a list of child comment IDs. Retrieving a full comment thread means fetching the parent item and then separately fetching each child, which the documentation acknowledges is a bit awkward but reflects how the site works internally.

Beyond individual items, the API provides lists of the top stories, newest stories, best stories, Ask HN posts, Show HN posts, and job listings, each as an array of item IDs. There is also an endpoint to look up user profiles, which includes the account's karma score, the date it was created, and any bio text the person has written. A separate endpoint returns recently changed items and profiles, useful for clients that want to stay in sync without polling everything.

There is currently no rate limit on the API. The base URL for all requests is https://hacker-news.firebaseio.com/v0/, and Firebase client libraries are available for web, Android, iOS, and server environments. Those libraries can handle change events automatically, so your app updates when new data arrives without polling on a timer.

The repository itself is just documentation and code samples, not a runnable application. No license is specified in the README.

Where it fits