跳到主要内容
Google Trends 工具允许您的代理利用 SerpApi 的 Google Trends API 来检索和分析搜索兴趣数据。这对于了解热门话题、区域搜索兴趣以及搜索词的历史受欢迎程度非常有用。 有关 API 详情,请参见此处 SerpApi 会缓存查询,因此第一次查询会比较慢,而后续相同的查询会很快。偶尔,相关查询可能无法正常工作,而按时间变化的兴趣则会正常。您可以在此处检查您的查询。

设置

要使用此工具,您需要配置 SerpApi 的 Google Trends API 访问权限。 SerpApi获取 API 密钥 然后,将您的 API 密钥设置为process.env.SERPAPI_API_KEY或将其作为apiKey构造函数参数传入。

用法

有关安装 LangChain 软件包的一般说明,请参阅此部分
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);
}

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.