Hacker News API

repository·master·Indexed 11 days ago

https://github.com/hackernews/api

A public API hosted via Firebase providing near real-time access to Hacker News data. Version v0 allows developers to retrieve stories, comments, user profiles, and other items using JSON endpoints, including specialized lists for top, new, and best stories.

Tokens
951
Snippets
6
Records
7
Agent score
46%

What's inside Hacker News API

  1. Hacker News API URI and Versioning

    master

    The Hacker News API uses versioned URIs. The current version (v0) uses the base prefix https://hacker-news.firebaseio.com/v0/.

    There is currently no rate limit. When consuming the API, clients should be prepared to handle additional fields gracefully; the API may add new fields that are not part of the current specification, and these should be ignored by the client.

  2. Get the current maximum Item ID

    master

    To discover all items by walking backward from the most recent entry, fetch the current largest item ID from the /v0/maxitem endpoint. This is useful for polling or discovering new content.

    https://hacker-news.firebaseio.com/v0/maxitem.json
  3. Access Hacker News User Profiles

    master

    User profiles are identified by case-sensitive usernames and are available at /v0/user/<id>.json. Note that only users with public activity (comments or story submissions) are available via the API.

    User Fields:

    • id: The user's unique, case-sensitive username.
    • created: Creation date in Unix Time.
    • karma: The user's karma score.
    • about: An optional self-description in HTML.
    • submitted: A list of item IDs representing the user's stories, polls, and comments.
    https://hacker-news.firebaseio.com/v0/user/jl.json?print=pretty
  4. Access Hacker News Items

    master

    All stories, comments, jobs, polls, and Ask HNs are treated as 'items'. Each item is identified by a unique integer id. You can retrieve an item by making a GET request to /v0/item/<id>.json.

    Item Types:

    • job
    • story
    • comment
    • poll
    • pollopt (a part of a poll)

    Common Item Fields:

    • id: The item's unique integer ID.
    • type: The type of item (see above).
    • by: The username of the author.
    • time: Creation date in Unix Time.
    • text: The content (comment, story, or poll text) in HTML format.
    • parent: The ID of the parent item (for comments).
    • kids: An array of IDs of the item's children (e.g., comments on a story), in ranked display order.
    • url: The URL of the story.
    • score: The story's score or pollopt votes.
    • title: The title of the story, poll, or job (HTML).
    • descendants: The total comment count (for stories or polls).
    • deleted: true if the item is deleted.
    • dead: true if the item is dead.
    https://hacker-news.firebaseio.com/v0/item/8863.json?print=pretty
  5. Monitor changed items and profiles

    master

    The /v0/updates endpoint provides a way to observe recent changes in the system. It returns an object containing two arrays: items (a list of recently changed item IDs) and profiles (a list of recently changed usernames).

    https://hacker-news.firebaseio.com/v0/updates.json
  6. Retrieve New, Top, and Best story IDs

    master

    The API provides lists of up to 500 story IDs for different rankings. Note that /v0/topstories also includes job stories. Use these endpoints to get the IDs of the most relevant or recent content.

    https://hacker-news.firebaseio.com/v0/topstories.json
    https://hacker-news.firebaseio.com/v0/newstories.json
    https://hacker-news.firebaseio.com/v0/beststories.json
  7. Retrieve Ask, Show, and Job story IDs

    master

    To access specific categories of stories, use the following endpoints which return up to 200 of the latest IDs for each category:

    https://hacker-news.firebaseio.com/v0/askstories.json
    https://hacker-news.firebaseio.com/v0/showstories.json
    https://hacker-news.firebaseio.com/v0/jobstories.json