> **Building with AI coding agents?** Install the authstack plugin with one command. This equips your agent with accurate Scalekit implementation patterns.
>
> **Recommended** (the `-y` flags skip prompts, so the command runs without an interactive terminal):
> ```bash
> npx -y @scalekit-inc/cli setup -y
> ```
>
> Global:
> ```bash
> npm install -g @scalekit-inc/cli
> scalekit setup -y
> ```
>
> Supports Claude Code, Cursor, GitHub Copilot, Codex + skills for other Agent Skills-compatible agents in `~/.agents/skills`.
> Skills: integrate-agentkit, implement-saaskit, add-mcp-oauth, implement-sso, implement-scim.
> [Full setup guide](https://docs.scalekit.com/dev-kit/build-with-ai/)

---

# Connect AI agents to Google Trends

The Google Trends connector lets your AI agent act in each user's Google Trends account. Each user signs in to Google Trends once, and Scalekit stores and refreshes their tokens, so your agent never handles credentials. It comes with 2 tools.

**Authentication:** OAuth 2.0
**Categories:** Search, Analytics
**Tools:** 2: 1 read, 1 write, 0 destructive
**Users sign in with:** OAuth
**OAuth app:** Your own Google app
**Built by:** Scalekit connector
**Try it:** [Playground in the Scalekit dashboard](https://app.scalekit.com/ws/signup?sk_intent=playground&provider=GOOGLETRENDS)

## Setup

1. ### Install the SDK

   **Node.js**

   ```bash
   npm install @scalekit-sdk/node dotenv
   ```

   **Python**

   ```bash
   pip install scalekit-sdk-python python-dotenv
   ```

2. ### Set your credentials

   Add your Scalekit credentials to your `.env` file. Find values in **[app.scalekit.com](https://app.scalekit.com)** > **Developers** > **API Credentials**.

   ```sh title=".env"
   SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
   SCALEKIT_CLIENT_ID=<your-client-id>
   SCALEKIT_CLIENT_SECRET=<your-client-secret>
   ```

3. ### Create the Google Trends connection

   In **AgentKit > Connections**, create a Google Trends connection and copy its redirect URI. The name you give it is the `connection_name` your code passes. See [Configure connections](/agentkit/connections/).

4. ### Register a Google OAuth app

   Google Trends connections use your own OAuth app. Register one with Google and add the redirect URI you copied.

   Then enter the app's Client ID and Client Secret on the Google Trends connection.

5. ### Authorize a user and make your first call

   **Node.js** (`quickstart.mts`)

   ```typescript
   import { ScalekitClient } from '@scalekit-sdk/node'
   import 'dotenv/config'
   import { createInterface } from 'node:readline/promises'

   const scalekit = new ScalekitClient(
     process.env.SCALEKIT_ENVIRONMENT_URL,
     process.env.SCALEKIT_CLIENT_ID,
     process.env.SCALEKIT_CLIENT_SECRET,
   )
   const actions = scalekit.actions

   const connector = 'googletrends'
   const identifier = 'user_123'

   // Generate an authorization link for the user
   const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
   console.log('Authorize Google Trends:', link)
   const rl = createInterface({ input: process.stdin, output: process.stdout })
   await rl.question('Press Enter after authorizing...')
   rl.close()

   // Make your first call
   const result = await actions.executeTool({
     connector,
     identifier,
     toolName: 'googletrends_get_operation',
     toolInput: { name: 'v1alpha.d3f3ded6-6fbe-4625-9bf1-d71d6312c9c9' },
   })
   console.log(result)
   ```

   ```bash
   npx tsx quickstart.mts
   ```

   **Python** (`quickstart.py`)

   ```python
   import os
   from scalekit import ScalekitClient
   from dotenv import load_dotenv
   load_dotenv()

   scalekit_client = ScalekitClient(
       env_url=os.getenv("SCALEKIT_ENVIRONMENT_URL"),
       client_id=os.getenv("SCALEKIT_CLIENT_ID"),
       client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),
   )
   actions = scalekit_client.actions

   connection_name = "googletrends"
   identifier = "user_123"

   # Generate an authorization link for the user
   link_response = actions.get_authorization_link(
       connection_name=connection_name,
       identifier=identifier,
   )
   print("Authorize Google Trends:", link_response.link)
   input("Press Enter after authorizing...")

   # Make your first call
   result = actions.execute_tool(
       tool_input={"name":"v1alpha.d3f3ded6-6fbe-4625-9bf1-d71d6312c9c9"},
       tool_name="googletrends_get_operation",
       connection_name=connection_name,
       identifier=identifier,
   )
   print(result)
   ```

   ```bash
   python quickstart.py
   ```

   Each user signs in once. See [Authorize a user](/agentkit/tools/authorize/) for the full flow and statuses.

## Tools

Pass the exact name to `execute_tool`, with an input like each tool's example. To ask for a tool that's missing, use the [request form](https://scalekitsupport.portal.usepylon.com/forms/request-a-connector-tool).

**Node.js**

```typescript
const result = await actions.executeTool({
  toolName: 'googletrends_get_operation',
  toolInput: {
    name: 'v1alpha.d3f3ded6-6fbe-4625-9bf1-d71d6312c9c9',
  },
  connector: 'googletrends',
  identifier: 'user_123',
})
```

**Python**

```python
result = actions.execute_tool(
    tool_name="googletrends_get_operation",
    tool_input={
        "name": "v1alpha.d3f3ded6-6fbe-4625-9bf1-d71d6312c9c9",
    },
    connection_name="googletrends",
    identifier="user_123",
)
```

`result.data` is the app's response as JSON, and `result.execution_id` (`executionId` in Node.js) is the ID of the call.

### `googletrends_get_operation`

Get Operation · Read-only

Get the current status and result of a Google Trends API (alpha) long-running operation by its name.
Returns an Operation object with name and a done boolean; once done, the response includes a time series with per-point searchInterest (raw) and scaledSearchInterest (0-100 scaled, matching the Trends website) — the exact envelope beyond these fields is not fully confirmed from available sources, so treat any other fields as undocumented.
Use this to poll a job after starting it with fetch_time_series; call it repeatedly until done is true.
Requires an operation name returned by fetch_time_series.

Read only: yes. Destructive: no. Idempotent (safe to retry): yes.

Inputs:

- `name` (`string`, required): Operation name to poll, copied verbatim from the "name" field returned by the fetch_time_series call that started this job (e.g. "v1alpha.d3f3ded6-6fbe-4625-9bf1-d71d6312c9c9"). Use it exactly as returned — do not strip, add, or reconstruct any prefix.
- `project_id` (`string`, optional): Optional Google Cloud project ID to bill this call's quota against, sent as the x-goog-user-project header. If omitted, Google uses the project already tied to the connected OAuth credentials (confirmed by live testing) — match whatever value, if any, was used for the fetch_time_series call that started this operation.

Example input: `{"name":"v1alpha.d3f3ded6-6fbe-4625-9bf1-d71d6312c9c9"}`

### `googletrends_fetch_time_series`

Fetch Time Series · Write

Start an asynchronous search-interest time-series query in Google Trends for one or more terms, scoped to a country or region, date range, and interval.
Returns a long-running Operation envelope immediately, e.g. {"name": "v1alpha.d3f3ded6-6fbe-4625-9bf1-d71d6312c9c9", "done": false} — not the time series data itself.
Use this to start a query; call googletrends_get_operation next with the returned name to poll until done and retrieve the actual search-interest results.
Requires a Google Cloud project accepted into the Google Trends API alpha program, with the Search Trends API enabled.

Read only: no. Destructive: no. Idempotent (safe to retry): no.

Inputs:

- `end_time_seconds` (`integer`, required): End of the time range to query, as Unix epoch seconds (UTC).
- `geo_code` (`string`, required): ISO country code identifying the country or region to fetch search interest for, e.g. "US" or "CH".
- `start_time_seconds` (`integer`, required): Start of the time range to query, as Unix epoch seconds (UTC). The API covers a rolling 5-year window; convert your desired start date to epoch seconds before calling this tool.
- `terms` (`array`, required): Array of search terms to compare, each an object with a value (the search phrase) and a type. The only confirmed type value in this alpha is "BROAD"; no other type is documented. Example: [{"value": "gold", "type": "BROAD"}]. Multiple terms can be passed in one call to compare them on a consistent scale, unlike the Trends website's 8-term UI limit.
- `geo_type` (`string`, optional): How geo_code should be interpreted. The only confirmed value is "GEO_TYPE_COUNTRY_OR_REGION" (geo_code is treated as a country/region code); this is also the default, so most callers can leave it unset. Default: `GEO_TYPE_COUNTRY_OR_REGION`.
- `project_id` (`string`, optional): Optional Google Cloud project ID to bill this call's quota against, sent as the x-goog-user-project header. If omitted, Google uses the project already tied to the connected OAuth credentials — confirmed by live testing (an omitted/empty value falls back to the OAuth grant's own project rather than being rejected). Only set this to point the call at a different project you have serviceusage.services.use permission on; that project must also have the Search Trends API enabled.
- `time_resolution` (`string`, optional): Interval at which the time series is aggregated. Confirmed values are DAY, WEEK, MONTH, and YEAR; HOUR is not yet supported in this alpha. Defaults to DAY. One of: `DAY`, `WEEK`, `MONTH`, `YEAR`. Default: `DAY`.

Example input: `{"end_time_seconds":1,"geo_code":"US","start_time_seconds":1,"terms":[{"value":"gold","type":"BROAD"}]}`

## Related

Other Search connectors ([all 35](/agentkit/connectors/?category=search)):

- [Supadata](/agentkit/connectors/supadata/): Scalekit connector, API key, 21 tools
- [Exa](/agentkit/connectors/exa/): Scalekit connector, API key, 21 tools
- [Brave Search](/agentkit/connectors/brave/): Scalekit connector, API key, 18 tools


---

## More Scalekit documentation

| Resource | What it contains | When to use it |
|----------|-----------------|----------------|
| [/llms.txt](/llms.txt) | Structured index with routing hints per product area | Start here — find which documentation set covers your topic before loading full content |
| [/llms-full.txt](/llms-full.txt) | Complete documentation for all Scalekit products in one file | Use when you need exhaustive context across multiple products or when the topic spans several areas |
| [sitemap-0.xml](https://docs.scalekit.com/sitemap-0.xml) | Full URL list of every documentation page | Use to discover specific page URLs you can fetch for targeted, page-level answers |
