Skip to main content

🚀 langchain-hackernews

PyPI version Python 3.10+ License: MIT

LangChain retrievers for Hacker News — search stories, fetch the front page, and retrieve full comment threads as LangChain Document objects. No API keys required.

Perfect for building RAG applications that can search tech news, analyze discussions, and stay up to date with Hacker News.

✨ Features

Retriever What it does API Key Required?
HackerNewsSearchRetriever Search HN stories by keyword ❌ No!
HackerNewsFrontPageRetriever Fetch current top/best/new stories ❌ No!
HackerNewsCommentsRetriever Fetch a full discussion thread ❌ No!

📦 Installation

pip install langchain-hackernews

🚀 Quick Start

Search Hacker News Stories

from langchain_hackernews import HackerNewsSearchRetriever

retriever = HackerNewsSearchRetriever(
    max_results=5,
    sort_by="relevance",  # or "date" for newest first
)

docs = retriever.invoke("langchain python")

for doc in docs:
    print(f"📰 {doc.page_content}")
    print(f"   👍 {doc.metadata['points']} points | 💬 {doc.metadata['num_comments']} comments")

Fetch the Front Page

from langchain_hackernews import HackerNewsFrontPageRetriever

retriever = HackerNewsFrontPageRetriever(
    page_type="top",  # "top", "best", "new", "ask", "show", "job"
    max_results=10,
)

# The query is ignored for the front page
docs = retriever.invoke("fetch")

for doc in docs:
    print(f"#{doc.metadata['rank']} — {doc.page_content}")

Fetch a Comment Thread

from langchain_hackernews import HackerNewsCommentsRetriever

retriever = HackerNewsCommentsRetriever(max_results=50)

# Pass the story URL or ID
docs = retriever.invoke("https://news.ycombinator.com/item?id=40243419")

for doc in docs:
    indent = "  " * doc.metadata["depth"]
    print(f"{indent}💬 {doc.metadata['author']}: {doc.page_content[:80]}...")

📄 License

MIT — see LICENSE for details.

Metadata

Release files for langchain-hackernews 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-hackernews 0.1.0
File Size Uploaded
langchain_hackernews-0.1.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-hackernews 0.1.0
File Interpreter ABI Platform
langchain_hackernews-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / langchain_hackernews-0.1.0.tar.gz

Download URL langchain_hackernews-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ce85b328ccb5ab5535abbd61183c525eab7f4f4bf496902dace0b8a0057f2310
BLAKE2b-256 checksum
How to use checksums
ef35ef0b40a4a281320ac1032a8caab5b1668bf6499072cb2dca03c22bd1ff77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / langchain_hackernews-0.1.0-py3-none-any.whl

Download URL langchain_hackernews-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd12e45528df012b0d23c9a5ac054f09cfb6bd96ea1dc2653b9b60d17d8b984e
BLAKE2b-256 checksum
How to use checksums
d86381a665c8249372808c451b45c8e7a0df042f10faab008b540d667c6152ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page