Skip to content

About

LangChain retrievers for Hacker News: search, front page, and comment threads without API keys.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🚀 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.

About

LangChain retrievers for Hacker News: search, front page, and comment threads without API keys.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages