# Google Trends for AI Agents — On-demand (`meka.im/google-trends-for-agent`) Actor

Google Trends search interest, comparisons, calibrated estimates and trending searches. Each query runs once and exits; no idle server. Open source (MIT), no Actor fee; platform compute and proxy usage apply.

- **URL**: https://apify.com/meka.im/google-trends-for-agent.md
- **Developed by:** [Meka.im](https://apify.com/meka.im) (community)
- **Categories:** AI, Open source
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 90.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Google Trends for AI Agents — On-demand

Open-source Google Trends search interest, comparisons, calibrated searches/day estimates and trending searches. Each query starts a bounded run and exits when finished. No Actor-owned MCP server or idle service is used. Platform compute, proxy and storage usage apply; there is no Actor fee.

### Quick start

Use the Input tab, then Start:

```json
{
  "tool": "snapshot",
  "terms": ["Sora"],
  "geo": "US",
  "window": "now 7-d",
  "anchor": ""
}
```

#### MCP client

Muse, GrokBot and Dots should use this Actor on demand, either the public version
or a self-deployment. Prefer Apify's managed MCP gateway with client OAuth; use an
authenticated Apify connector/API when native registration is unavailable. See
the [client guide](https://github.com/meka-im/google-trends-for-agent/blob/main/docs/clients.md).

The gateway handles OAuth without starting this Actor just to keep an MCP connection open:

```json
{
  "mcpServers": {
    "google-trends": {
      "url": "https://mcp.apify.com?tools=meka.im/google-trends-for-agent"
    }
  }
}
```

For a self-deployment, replace `meka.im/google-trends-for-agent` in `tools=` with
your own accessible `<username>/<actor-name>`.

The gateway exposes the Actor's input interface plus run, Dataset, key-value-store and abort tools. It does not promise four direct `trends_*` tools. Local MCP and the dsh native plugin provide the four `trends_*` tools. Apify's OAuth scope is account-wide `full_api_access`; authorize through the client's official Apify login. Clients without OAuth can supply a Bearer header from credential storage.

For self-deployment, keep Server / Standby disabled. This Actor runs queries on demand and rejects Standby startup.

### Inputs

- `tool`: `ask`, `snapshot`, `compare`, or `now`.
- `terms`: one or more terms for ask/snapshot, 1–5 distinct terms for compare; ignored by now.
- `geo`: supported country code; `WORLDWIDE` is accepted except for now.
- `window`: a supported Trends time window, default `now 7-d`.
- `anchor`: automatic multi-tier MEKA calibration by query region and window when blank; built-in terms come from the MEKA Google Ads Keyword Planner catalog.
- `timeoutMs`: optional 1000–60000 ms per upstream request.
- `proxyConfiguration`: defaults to the on-platform US residential proxy.

Ordinary input executes one tool, writes Dataset v1 rows and an `OUTPUT` record, then exits. Now writes at most 25 rows. Later ask/snapshot terms are skipped after a block or rate limit. A failed or partial run still has real platform costs.

### Dataset v1

Each flat row contains: `term`, `tool`, `geo`, `window`, `status`, `interestLatest`, `interestSettled`, `interestAverage`, `interestPeak`, `searchesPerDay`, `verdict`, `anchor`, `topRelated`, `topRising`, `chartKey`, `chartUrl`, `error`, `fetchedAt`. Related fields are string arrays, so there is no per-related-query `estDaily` in Dataset v1. Missing values remain null. Charts are stored under `chart-*` in the run's key-value store; read them through the authenticated API.

`OUTPUT` reports completed/partial/failed plus delivered, noData, blocked, skipped, errors and duration. Dataset rows, successful native tool calls and MCP sessions have different denominators: do not divide all Actor costs by Dataset rows to estimate cost per query.

### Native tool request protocol

The dsh plugin submits one complete tool request per run:

```json
{
  "toolRequest": {
    "protocol": 1,
    "name": "trends_snapshot",
    "input": { "term": "ChatGPT", "geo": "US", "time": "now 1-d", "svg": true },
    "settings": { "cache": true, "charts": true }
  }
}
```

`name` accepts the four `trends_*` names. Read `TOOL_RESPONSE` from the run's key-value store: `{ protocol: 1, result, snapshots }`. `result` preserves the full tool envelope, including related-query null fields, calibration warnings and inline SVG. Validated optional history preserves snapshot diffs across runs. The local plugin handles six-hour result reuse and local chart files. Credentials and local filesystem paths are never part of this input. This additive protocol does not change Dataset v1; native requests may have zero Dataset rows.

The dsh connection check uses internal protocol `2` for one comparison of three basic keywords. It returns the same tool envelope, disables upstream retries and exits after the check. Protocol `1` handles ordinary native tool requests.

### Runtime and cost bounds

Default memory is 256 MB and default timeout is 300 seconds. dsh sends these bounds explicitly for every run. The client starts once, polls the run and reads its result. It does not retry an ambiguous start POST. Cancellation attempts to abort the owned run; if the network is unavailable, the platform timeout remains the bound. Local snapshot-cache hits and API metadata checks start no run. Builds have their own platform cost.

Inspect each finished run's `usageTotalUsd` for its measured cost; see [cost details](../docs/reference.md#actor-costs). There is no fixed per-query price.

### Data boundaries

Searches/day are anchor-calibrated estimates, not measured Google volume. Sparse or unavailable calibration returns null with a warning. Snapshot related-query `estDaily` remains null in native envelopes. Built-in baselines cover the US, Canada, UK, Australia, Germany, France, Japan, India and Worldwide. New regional estimates use ±75% assumption bands, not statistical confidence intervals. See [regional values, source periods and validation](https://github.com/meka-im/google-trends-for-agent/blob/main/docs/baselines.md). Other regions still return relative interest without an absolute volume estimate. On `BLOCKED`, stop. On `RATE_LIMITED`, respect the indicated backoff and keep retries bounded. Use this for light interactive research.

The project is unofficial and is not affiliated with Google. [Source and local usage](../README.md), [MCP field guide](../docs/mcp-api.md), [reference](../docs/reference.md).

# Changelog

This Actor's version history is a separate document: https://apify.com/meka.im/google-trends-for-agent/changelog.md

# Actor input Schema

## `tool` (type: `string`):

One tool per run. Example: "ask" checks a single term and returns interest plus related queries.

## `terms` (type: `array`):

One or more search terms. Example: \["Sora"]. Ask and snapshot use one call per term; compare uses one call with 1–5 distinct terms. Ignored by "now".

## `geo` (type: `string`):

Google Trends country. Example: "US". Worldwide is supported for ask/snapshot/compare; "now" needs a country.

## `window` (type: `string`):

Explore time window. Example: "now 7-d". For ask/snapshot/compare it is used unchanged. For now: now 1-H and now 4-H map to 4 hours; now 1-d to 24; now 7-d to 168; today 1-m, today 3-m, today 12-m, today 5-y, and all map to 24 hours. trends_now also accepts hours 48 directly, but no Actor window maps to 48 hours.

## `anchor` (type: `string`):

Anchor used to calibrate searches/day. Example: "sudoku". Leave blank for automatic multi-tier MEKA selection by country and time window. Worldwide has its own estimates; unknown regions return null traffic.

## `timeoutMs` (type: `integer`):

Per-request Google Trends timeout in milliseconds (1000–60000). Example: 20000. Leave blank for the tool default (30000 ms for Explore tools, 15000 ms for Trending Now).

## `proxyConfiguration` (type: `object`):

Egress for Google Trends requests inside the Actor. Example: Apify Residential proxy in the US. Residential traffic is billed per GB from your Apify credits.

## `toolRequest` (type: `object`):

Programmatic clients can submit protocol 1 with name, input and optional settings/history. Leave empty when using the ordinary tool/terms input. Returns the complete envelope in TOOL_RESPONSE.

## Actor input object example

```json
{
  "tool": "snapshot",
  "terms": [
    "Sora"
  ],
  "geo": "US",
  "window": "now 7-d",
  "anchor": "",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items: one row per term or Trending Now item.

## `summary` (type: `string`):

OUTPUT record with status, counters, duration and a message.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "tool": "snapshot",
    "terms": [
        "Sora"
    ],
    "geo": "US",
    "window": "now 7-d",
    "anchor": "",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "US"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("meka.im/google-trends-for-agent").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "tool": "snapshot",
    "terms": ["Sora"],
    "geo": "US",
    "window": "now 7-d",
    "anchor": "",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("meka.im/google-trends-for-agent").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "tool": "snapshot",
  "terms": [
    "Sora"
  ],
  "geo": "US",
  "window": "now 7-d",
  "anchor": "",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}' |
apify call meka.im/google-trends-for-agent --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,meka.im/google-trends-for-agent"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/QUx4aBkz4QCSchDV4/builds/sO6pDVUiyslUFSUS7/openapi.json
