Google Trends Tool
Guide for using the Google Trends tool with PraisonAI agents.
The Google Trends tool lets an agent pull trending-topic data through the SerpAPI Google Trends endpoint.
Overview
The Google Trends tool is a tool that allows you to search the web using the Google Trends API.
pip install langchain-community google-search-resultsexport SERPAPI_API_KEY="${SERPAPI_API_KEY:?Set SERPAPI_API_KEY in your shell}"from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper
from praisonaiagents import Agent, AgentTeam
research_agent = Agent(
instructions="Research trending topics related to AI",
tools=[GoogleTrendsAPIWrapper]
)
summarise_agent = Agent(
instructions="Summarise findings from the research agent",
)
agents = AgentTeam(agents=[research_agent, summarise_agent])
agents.start()How It Works
Getting Started
- Simple Usage
- Install dependencies (see Overview above)
- Set required API keys in your environment
- Run the agent example in Overview
- With Configuration
Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.
Best Practices
Keep SERPAPI_API_KEY in the environment
Google Trends here runs through SerpAPI, so set SERPAPI_API_KEY in your shell or .env. Never hard-code the key.
Query specific terms
Trends data is per keyword. Feed the agent concrete terms rather than broad phrases so the returned interest data is meaningful.
Handle quota errors
SerpAPI enforces a monthly search quota. Wrap the call in try/except so the agent can report a clean message when the quota is hit.