Hacker News

Fetch top Hacker News stories and user details with HackerNewsTools' get_top_hackernews_stories and get_user_details functions.

HackerNewsTools enable an Agent to get top stories and user details from Hacker News.

Prerequisites

The following example requires the anthropic library.

uv pip install -U agno anthropic

Set the agent model's API key in the same terminal:

export ANTHROPIC_API_KEY="your-api-key"

Example

The following agent will write a report on trending startups and products from Hacker News.

cookbook/91_tools/hackernews_tools.py
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.hackernews import HackerNewsTools

agent = Agent(
    model=Claude(id="claude-sonnet-4-5"),
    tools=[HackerNewsTools()],
    markdown=True,
)

agent.print_response(
    "Write a report on trending startups and products.", stream=True
)

Toolkit Params

ParameterTypeDefaultDescription
enable_get_top_storiesboolTrueEnables fetching top stories.
enable_get_user_detailsboolTrueEnables fetching user details.
allboolFalseEnables all functionality.
timeoutint30Per-request HTTP timeout in seconds.

Toolkit Functions

FunctionDescription
get_top_hackernews_storiesRetrieves the top stories from Hacker News. Parameters include num_stories to specify the number of stories to return (default is 10). Returns the top stories in JSON format.
get_user_detailsRetrieves the details of a Hacker News user by their username. Parameters include username to specify the user. Returns the user details in JSON format.

Developer Resources