Modern async Hacker News API client for Python.
hnx combines the Hacker News Firebase API & Algolia's search API to provide a unified, fully-typed interface for working with stories, comments, users, & discussion threads.
- Async-first API built on
httpx - Fully typed Pydantic models combining data from both Algolia & Firebase APIs
- Individual and concurrent batch item retrieval
Requires Python 3.10 or higher.
pip install hnxuv add hnxpoetry add hnxpipenv install hnxfrom hnx import HackerNews
async def main():
async with HackerNews() as hn:
story = await hn.item(44321234)
print(story.title)
print(story.score)from hnx import HackerNews
async def main():
async with HackerNews() as hn:
ids = await hn.top()
print(ids[:10])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)
for comment in thread.comments:
print(comment.author)Complete documentation, API reference, guides, and examples are available at: