HackerNews Tools

Pull top HackerNews stories with HackerNewsTools and stream a report on trending startups.

hackernews_tools.py
"""
Hackernews Tools
=============================

Demonstrates hackernews tools.
"""

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.hackernews import HackerNewsTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


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

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response(
        "Write a report on trending startups and products.", stream=True
    )

The toolkit retrieves top-story records and user profiles from Hacker News; it does not fetch the full articles linked by those stories. The model's report is grounded in the returned records, normally the first ten stories per call, rather than a comprehensive startup-trend search.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno anthropic

Export your Anthropic API key

export ANTHROPIC_API_KEY="your_anthropic_api_key_here"

Run the example

Save the code above as hackernews_tools.py, then run:

python hackernews_tools.py

Full source: cookbook/91_tools/hackernews_tools.py