Modern async Hacker News API client
Project description
hnx
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.
Table of Contents
Features
- Async-first API built on
httpx - Fully typed Pydantic models combining data from both Algolia & Firebase APIs
- Individual and concurrent batch item retrieval
Installation
Requires Python 3.10 or higher.
pip
pip install hnx
uv
uv add hnx
Poetry
poetry add hnx
Pipenv
pipenv install hnx
Quick Start
Fetch a Story
from hnx import HackerNews
async def main():
async with HackerNews() as hn:
story = await hn.item(44321234)
print(story.title)
print(story.score)
Fetch Top Stories
from hnx import HackerNews
async def main():
async with HackerNews() as hn:
ids = await hn.top()
print(ids[:10])
Fetch a Complete Thread
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)
Documentation
Complete documentation, API reference, guides, and examples are available at:
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hnx-0.5.1.tar.gz.
File metadata
- Download URL: hnx-0.5.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b320410b552bde43f1890dd634b05a3b674aa7c3afa99c32598f10c2012feced
|
|
| MD5 |
82b80a7729f3e875bdfadbe37abe5af4
|
|
| BLAKE2b-256 |
28e32a4dd68a6ed3c8c62833e78cf39f41e3231ac5c11cdd5294e01612218c52
|
File details
Details for the file hnx-0.5.1-py3-none-any.whl.
File metadata
- Download URL: hnx-0.5.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13119c09a5ebe0030cf4e474bfa0b1e71cd916aea4695b455597e4dcff1877be
|
|
| MD5 |
87d4684c17de4044bf4d07ccd3996245
|
|
| BLAKE2b-256 |
f13c2cf1fc3b93be4543d1bea01295700f0c2cabeaecf206ad5f8d60f0b2d35f
|