The Google Trends Tool allows your agent to utilize the Google Trends API from SerpApi to retrieve and analyze search interest data. This can be useful for understanding trending topics, regional search interest, and historical popularity of search terms. For API details see here SerpApi caches queries, so the first query will be slower while subsequent identical queries will be fast. Occasionally, related queries will not work while interest over time will be fine. You can check your query here.

Setup

To use this tool, you will need to configure access to the Google Trends API from SerpApi. Get an API key from SerpApi Then, set your API key as process.env.SERPAPI_API_KEY or pass it in as an apiKey constructor argument.

Usage

npm
npm install @langchain/openai @langchain/community @langchain/core
import { SERPGoogleTrendsTool } from "@langchain/community/tools/google_trends";

export async function run() {
  const tool = new SERPGoogleTrendsTool();

  const res = await tool.invoke("Monster");

  console.log(res);
}