explaingit

hackernews/api

13,027Audience · developerComplexity · 1/5Setup · easy

TLDR

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.

Mindmap

mindmap
  root((HN API))
    Data types
      Stories
      Comments
      Job listings
      User profiles
    Endpoints
      Top and best stories
      Ask and Show HN
      Changed items
    Features
      No rate limit
      Real-time via Firebase
      Near-real-time sync
    Clients
      Web Firebase SDK
      Android and iOS
      Server libraries
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Fetch the current top Hacker News stories and display them in your own app, dashboard, or newsletter.

USE CASE 2

Build a real-time HN comment reader that updates automatically when new replies arrive using Firebase change events.

USE CASE 3

Pull Hacker News job listings to aggregate with other job sources in a single feed.

USE CASE 4

Sync a local copy of HN content incrementally by polling the changed-items endpoint.

Tech stack

FirebaseJSON

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

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.

Copy-paste prompts

Prompt 1
Write a JavaScript function that fetches the current top 10 Hacker News stories and displays each title, score, and link.
Prompt 2
Build a Python script that fetches all comments for a given HN story ID by recursively loading child items and saves them as JSON.
Prompt 3
Use the Firebase JavaScript client to listen for real-time updates on the HN top stories list and log each new story as it appears.
Prompt 4
Fetch a Hacker News user profile by username using the API and display their karma score, account age, and bio.
Open on GitHub → Explain another repo

← hackernews on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.