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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_hackernews-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_hackernews-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file langchain_hackernews-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_hackernews-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for langchain_hackernews-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ce85b328ccb5ab5535abbd61183c525eab7f4f4bf496902dace0b8a0057f2310
MD5 5fe05925a139e308172445b23ad86335
BLAKE2b-256 ef35ef0b40a4a281320ac1032a8caab5b1668bf6499072cb2dca03c22bd1ff77

See more details on using hashes here.

File details

Details for the file langchain_hackernews-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_hackernews-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd12e45528df012b0d23c9a5ac054f09cfb6bd96ea1dc2653b9b60d17d8b984e
MD5 88b1211c3266226f12481e7744cc7630
BLAKE2b-256 d86381a665c8249372808c451b45c8e7a0df042f10faab008b540d667c6152ad

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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