A Modern async Hacker News API client for Python.

hnx combines the official Hacker News Firebase API with Algolia's search API to provide a clean, fully-typed interface for working with stories, comments, users, and complete discussion threads.

Features

  • Async-first API built on httpx
  • Fully typed Pydantic models for all Hacker News resources
  • Unified data models powered by both Firebase and Algolia
  • Access to all major Hacker News feeds, including Top, Best, New, Ask HN, Show HN, and Jobs
  • Fetch individual items, users, or batches of items concurrently
  • Retrieve complete discussion threads with recursively nested comments
  • Consistent Pythonic interface over multiple Hacker News data sources
  • Python 3.10+

Example

from hnx import HackerNews

async def main():
    async with HackerNews() as hn:
        thread = await hn.thread(44321234)

        print(thread.root.title)
        print(thread.comment_count)

Continue with the Quick Start.