Overview
HackerNewsTools provides access to HackerNews stories, comments, and user data. This tool enables agents to fetch trending tech news, analyze discussions, and track community engagement on HackerNews.
Installation
Basic Usage
from agno.agent import Agent
from agno.tools.hackernews import HackerNewsTools
from agno.models.nebius import Nebius
import os
hackernews_tools = HackerNewsTools()
agent = Agent(
name="Tech News Analyst",
tools=[hackernews_tools],
model=Nebius(
id="Qwen/Qwen3-30B-A3B",
api_key=os.getenv("NEBIUS_API_KEY")
),
markdown=True,
show_tool_calls=True
)
agent.print_response("What are the top stories on HackerNews today?")
API Reference
Provides methods to interact with the HackerNews API.
Creates a new instance of HackerNewsTools. No parameters required.
Available Methods
The tool automatically provides the following capabilities when used with an agent:
- Fetch top stories: Get current top-ranked stories
- Get story details: Retrieve full story information including title, URL, score, and comments
- Read comments: Access comment threads and discussions
- User profiles: Look up HackerNews user information
- Track trends: Identify trending topics and patterns
Agent Configuration
Recommended Instructions
INSTRUCTIONS = """You are an intelligent HackerNews analyst and tech news curator. Your capabilities include:
1. Analyzing HackerNews content:
- Track trending topics and patterns
- Analyze user engagement and comments
- Identify interesting discussions and debates
- Provide insights about tech trends
- Compare stories across different time periods
2. When analyzing stories:
- Look for patterns in user engagement
- Identify common themes and topics
- Highlight particularly insightful comments
- Note any controversial or highly debated points
- Consider the broader tech industry context
3. When providing summaries:
- Be engaging and conversational
- Include relevant context and background
- Highlight the most interesting aspects
- Make connections between related stories
- Suggest why the content matters
"""
agent = Agent(
name="Tech News Analyst",
instructions=[INSTRUCTIONS],
tools=[hackernews_tools],
model=Nebius(id="Qwen/Qwen3-30B-A3B", api_key=os.getenv("NEBIUS_API_KEY")),
markdown=True
)
Example Use Cases
Analyze Trending Topics
response = agent.run("What are the most discussed topics on HackerNews today?")
print(response.content)
Find Popular Stories
response = agent.run("Show me the top 5 stories about AI and machine learning")
print(response.content)
Track User Engagement
response = agent.run("Which stories have the most comments and why?")
print(response.content)
The agent will automatically format responses based on the data retrieved from HackerNews:
- Story titles with links
- Scores and point counts
- Comment counts and engagement metrics
- Authors and submission times
- Discussion summaries and key insights
Best Practices
- Enable markdown: Set
markdown=True for better formatted responses
- Show tool calls: Set
show_tool_calls=True during development to see API interactions
- Use specific queries: More specific questions yield better results
- Consider rate limits: HackerNews API has rate limits, avoid excessive requests
- Cache results: For repeated queries, consider implementing caching
from agno.tools.hackernews import HackerNewsTools
from agno.tools.duckduckgo import DuckDuckGoTools
agent = Agent(
name="Comprehensive Tech Analyst",
tools=[
HackerNewsTools(),
DuckDuckGoTools(search=True, news=True)
],
model=Nebius(id="Qwen/Qwen3-30B-A3B", api_key=os.getenv("NEBIUS_API_KEY"))
)