> ## Documentation Index
> Fetch the complete documentation index at: https://nvd-54.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google trends 集成

> 使用 LangChain JavaScript 集成 Google trends tool。

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 the [Google Trends API documentation](https://serpapi.com/google-trends-api)

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 in the SerpApi playground](https://serpapi.com/playground?engine=google_trends\&q=monster\&data_type=RELATED_QUERIES).

## 设置

To use this tool, you will need to configure access to the Google Trends API from SerpApi.

Get an API key from [SerpApi](https://serpapi.com/users/sign_in)

Then, set your API key as `process.env.SERPAPI_API_KEY` or pass it in as an `apiKey` constructor argument.

## 用法

<Tip>
  请参阅[此部分了解安装 LangChain 包的通用说明](/oss/javascript/langchain/install)。
</Tip>

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/openai @langchain/community @langchain/core
```

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
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);
}
```

## 相关内容

* Tool [conceptual guide](/oss/javascript/langchain/tools)
* Tool [how-to guides](/oss/javascript/langchain/tools)

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档连接到](/use-these-docs) Claude、VSCode 等工具，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/tools/google_trends.mdx) 或 [提交 issue](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
