HN CLI utility.
Project description
hn-query
HN CLI utility.
Tech Stack
- Python 3.12+ with
src/layout - uv — package manager
- Typer — CLI framework
- pytest — testing
- Ruff — linting & formatting
- pre-commit — git hooks
Getting Started
# Install dependencies
uv sync
# Run the CLI
uv run hn-query --help
uv run hn-query top
uv run hn-query top --json
uv run hn-query top --csv
uv run hn-query top --format human --output top.txt
# Run tests
uv run pytest
# Lint & format
uv run ruff check .
uv run ruff format .
# Set up git hooks
uv run pre-commit install
Working with AI Agents
This project includes an AGENTS.md file with instructions for AI coding agents.
Project Structure
See ARCHITECTURE.md for details on how the project is organized and how to grow it as your application evolves.
Commands
hn-query top: fetch top Hacker News stories (implemented)hn-query new: fetch new Hacker News stories (implemented)hn-query best: fetch best Hacker News stories (implemented)hn-query item <id>: fetch one Hacker News item by ID (implemented)
top options
--limit, -n: number of stories, default10, max100--format:human,json, orcsv--json: shortcut for--format json--csv: shortcut for--format csv--output, -o: write output to file--timeout: HTTP timeout seconds
Python API (Scripts and Notebooks)
hn-query exposes a stable import API in hn_query.api and top-level re-exports in
hn_query.
Script example
from hn_query import get_top, stories_to_json
stories = get_top(limit=5, timeout=10.0)
print(stories_to_json(stories))
Notebook example
from hn_query.api import get_item, item_to_json
item = get_item(8863)
item_to_json(item)
Stable exports
Top-level supported imports:
HNStoryHNApiErrorget_top,get_new,get_best,get_itemstories_to_json,stories_to_csvitem_to_json,item_to_csv
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 hn_query-0.2.0.tar.gz.
File metadata
- Download URL: hn_query-0.2.0.tar.gz
- Upload date:
- Size: 16.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d8c5757edf7d7f9cdfd9f0cda8ce828f920981f2cc5c537c4e8c727ab6f7295
|
|
| MD5 |
20dc9c4a676e81541eec0722c2ddcabc
|
|
| BLAKE2b-256 |
4c0e7f1eabe87ffa2eeaeed5949e0c15a9177dfb79bec92649d616d0655a12ac
|
File details
Details for the file hn_query-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hn_query-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
010d117c787d8740f1d6493a3f372eefd19f16a2c2578c91a7deb08d3570944f
|
|
| MD5 |
6f337269b22894ca9d07d0d4b8621ac3
|
|
| BLAKE2b-256 |
162dd246a86dd7e7255949e891554ffcacc692b3e870a80f5e1b46fdbf0a1750
|