# Google Trends Scraper: Timeline, Regions & Queries (`rar_888/google-trends`) Actor

Collect interest over time, regional breakdowns, and related topics or queries from Google Trends. Compare up to five terms per chart. Requests run sequentially and stop if Google rate-limits them.

- **URL**: https://apify.com/rar_888/google-trends.md
- **Developed by:** [Rardiel Andrés Ceballo Salas](https://apify.com/rar_888) (community)
- **Categories:** SEO tools, AI, Marketing
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 google trends keyword or comparison results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## 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 Explorer: Timeline, Regions & Queries

Explore interest over time, regional breakdowns, related queries and related topics from Google Trends.

> **Attribution Notice:** All data extracted by this Actor comes from Google Trends. When reusing or publishing these datasets, please include the attribution required by Google:\
> **`Data source: Google Trends (https://www.google.com/trends)`** (automatically included in every output item under `source` and `attribution`).

***

### Why Use This Google Trends Actor?

The Actor retrieves the public Google Trends widgets sequentially. Each item includes its source. You pay for each item saved to the dataset.

1. **Direct Widget Endpoint Integration (`httpx`):** Queries `/trends/api/explore`, `/trends/api/widgetdata/multiline`, `/trends/api/widgetdata/comparedgeo`, and `/trends/api/widgetdata/relatedsearches` (permitted by `trends.google.com/robots.txt`), strips the `)]}'` XSSI prefix, and normalizes timestamps to UTC ISO-8601.
2. **Request pacing and rate limits.**
   - The Actor makes one request at a time and keeps its cookies for the duration of the run.
   - A refusal from the configured proxy stops the run.
   - A Google HTTP 429 stops all remaining requests. The failure record includes a valid Retry-After header when supplied.
3. **Billing.** Completed items stay in the dataset. The failures record lists refused and deferred terms.
4. **Single-Term or 5-Term Comparison Mode (`compare`):** Query keywords individually (`compare: false`) or batch them into comparative groups of up to 5 keywords (`compare: true`) on a shared `0–100` scale.

***

### Input Parameters

| Field | Type | Default | Description |
|---|---|---|---|
| `keywords` | `array<string>` | *(required)* | List of search terms to query. Deduplicated automatically. |
| `compare` | `boolean` | `false` | `false`: 1 item per keyword. `true`: groups keywords in batches of up to 5 into a single comparative query. |
| `geo` | `string` | `"US"` | ISO country/region code (`"US"`, `"GB"`, `"ES"`, `"US-CA"`) or `""` for Worldwide. |
| `timeRange` | `string` | `"today 3-m"` | Preset (`"now 1-H"`, `"now 4-H"`, `"now 1-d"`, `"now 7-d"`, `"today 1-m"`, `"today 3-m"`, `"today 12-m"`, `"today 5-y"`, `"all"`) or custom `"YYYY-MM-DD YYYY-MM-DD"`. |
| `category` | `integer` | `0` | Google Trends numeric category ID (`0` = All categories). |
| `property` | `string` | `""` | Search surface: `""` (Web), `"images"`, `"news"`, `"youtube"`, or `"froogle"` (Shopping). |
| `includeTimeline` | `boolean` | `true` | Include Interest Over Time (`timeline`). |
| `includeRegions` | `boolean` | `false` | Include Interest by Subregion/Country (`regions`). |
| `includeRelated` | `boolean` | `false` | Include Related Queries and Related Topics (`top` and `rising`). |
| `hl` | `string` | `"en-US"` | Language code for region/topic labels (e.g., `"en-US"`, `"es-ES"`). |
| `maxItems` | `integer` | `100` | Maximum number of successful items (terms or comparison groups) to output. |
| `proxyGroup` | `string` | `"DATACENTER"` | Select the Apify Proxy group for the run. |
| `proxyConfiguration` | `object` | `{"useApifyProxy": true}` | Standard Apify Proxy configuration (falls back to direct connection locally). |

#### Example Input

```json
{
  "keywords": ["python", "rust", "typescript"],
  "compare": false,
  "geo": "US",
  "timeRange": "today 3-m",
  "category": 0,
  "property": "",
  "includeTimeline": true,
  "includeRegions": true,
  "includeRelated": true,
  "hl": "en-US",
  "maxItems": 20,
  "proxyGroup": "DATACENTER",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

***

### Output Schema

Each dataset item represents one keyword (when `compare: false`) or one group of up to 5 keywords (when `compare: true`):

```json
{
  "keywords": ["python"],
  "geo": "US",
  "timeRange": "today 3-m",
  "category": 0,
  "property": "",
  "timeline": [
    {
      "date": "2026-07-19T00:00:00Z",
      "value": 95,
      "isPartial": false
    },
    {
      "date": "2026-07-20T00:00:00Z",
      "value": 100,
      "isPartial": false
    }
  ],
  "regions": [
    {
      "geoCode": "US-CA",
      "geoName": "California",
      "value": 100
    }
  ],
  "relatedQueries": {
    "top": [
      {
        "query": "what is python",
        "value": 100,
        "formattedValue": "100",
        "link": "https://trends.google.com/trends/explore?q=what+is+python&date=today+3-m&geo=US"
      }
    ],
    "rising": [
      {
        "query": "python 3.13",
        "value": 450,
        "formattedValue": "+450%",
        "link": "https://trends.google.com/trends/explore?q=python+3.13&date=today+3-m&geo=US"
      }
    ]
  },
  "relatedTopics": {
    "top": [
      {
        "title": "Python",
        "type": "Programming language",
        "mid": "/m/05z1_",
        "value": 100,
        "formattedValue": "100",
        "link": "https://trends.google.com/trends/explore?q=/m/05z1_&date=today+3-m&geo=US"
      }
    ],
    "rising": []
  },
  "exploreUrl": "https://trends.google.com/trends/explore?q=python&date=today+3-m&geo=US&hl=en-US",
  "fetchedAt": "2026-10-19T16:55:00Z",
  "source": "Google Trends",
  "attribution": "Data source: Google Trends (https://www.google.com/trends)"
}
```

***

### Pricing (Pay-Per-Event)

You only pay for **successfully extracted dataset items** (`apify-default-dataset-item`). Startup (`apify-actor-start`) and failed terms cost **`$0.00`**:

- **Price per item (`apify-default-dataset-item`):** **`$0.005` USD per item** (`$5.00` per `1,000` keywords or comparison groups), all-inclusive of platform compute (`256 MB`) and proxy usage.
- **Spending Cap Enforcement:** Checks `is_event_charge_limit_reached("apify-default-dataset-item")` before emitting each item and halts cleanly when your budget limit is reached.

| Scenario | Items (`maxItems`) | Total User Cost (`$0.005/item`) |
|---|---:|---:|
| Single AI agent lookup | 1 | **$0.005** |
| Quick keyword batch | 10 | **$0.05** |
| Standard SEO keyword batch | 100 | **$0.50** |
| Large research dataset | 1,000 | **$5.00** |

***

### Limits, Rate Limiting & Terms Compliance

- **Respects `robots.txt`:** Accesses only `/trends/` and `/trends/api/*` endpoints permitted by `https://trends.google.com/robots.txt`. Never requests disallowed `/explore?` or `/trends/explore?` HTML pages.
- **Anonymous Public Access Only:** Uses only the standard anonymous `NID` cookie issued by `trends.google.com`. Never uses logged-in accounts or CAPTCHA bypass services.
- **Required Attribution:** Per [Google Trends Help](https://support.google.com/trends/answer/4365538?hl=en), cite `"Data source: Google Trends (https://www.google.com/trends)"` when publishing or redistributing data.

***

### Frequently Asked Questions (FAQ)

#### 1. What does this Actor cost?

This Actor uses Apify's **Pay-Per-Event (PPE)** model at **`$0.005` USD per successful dataset item** (`$5.00` per `1,000` keywords or comparison groups), with a **`$0.00` startup fee**. Platform compute and proxy costs are included in the per-item price.

#### 2. Why does this Actor charge per item instead of a startup fee or monthly rental?

Each saved dataset item costs $0.005. A failed or skipped keyword incurs zero event charges.

#### 3. What data fields does each output item return?

Each dataset item returns `keywords`, `geo`, `timeRange`, `category`, `property`, `timeline` (UTC ISO-8601 dates and `0–100` normalized interest scores), `regions` (when `includeRegions: true`), `relatedQueries` and `relatedTopics` with `top` and `rising` lists (when `includeRelated: true`), a human-verifiable `exploreUrl`, `fetchedAt` timestamp, `source`, and Google's required `attribution` string.

#### 4. Do I need a Google API key or logged-in Google account?

No. The Actor connects anonymously to Google Trends' public widget endpoints, acquires a standard anonymous `NID` session cookie automatically, and requires zero external API keys or Google account credentials.

#### 5. What are the rate limits, proxy options, and safety controls?

The Actor makes one request at a time with a default interval of at least 1.5 seconds. If Google limits requests, check the failures record for the suggested time to try again.

#### 6. How can I use this Actor in practical workflows or AI agent pipelines?

- **SEO & Content Research:** Run 20–100 seed keywords with `includeRelated: true` to discover breakout (`rising`) queries and topics.
- **Brand Share-of-Search Benchmarking:** Set `compare: true` with up to 5 competitor brand names (`["openai", "anthropic", "gemini"]`) and `includeRegions: true` to compare relative interest across countries or US states.
- **AI Agent / MCP Tool Calls:** Trigger single-term or 5-term runs on demand with `maxItems: 5` for `$0.025` total cost and zero fixed overhead.

# Actor input Schema

## `keywords` (type: `array`):

List of search terms to query on Google Trends (required). When 'compare' is false, each keyword is queried individually; when 'compare' is true, keywords are grouped into batches of up to 5.

## `compare` (type: `boolean`):

When true, groups keywords into batches of up to 5 in a single comparative query. When false (default), queries each keyword individually.

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

Two-letter ISO country code (e.g., 'US', 'GB', 'ES', 'DE') or sub-region code (e.g., 'US-CA'). Leave empty ('') for Worldwide.

## `timeRange` (type: `string`):

Predefined window ('now 1-H', 'now 4-H', 'now 1-d', 'now 7-d', 'today 1-m', 'today 3-m', 'today 12-m', 'today 5-y', 'all') or a custom UTC date range 'YYYY-MM-DD YYYY-MM-DD'.

## `category` (type: `integer`):

Google Trends numeric category ID (0 = All categories, 3 = Arts & Entertainment, 5 = Computers & Electronics, 7 = Finance, 16 = News, etc.).

## `property` (type: `string`):

Google search surface: '' (Web Search), 'images' (Image Search), 'news' (News Search), 'youtube' (YouTube Search), or 'froogle' (Google Shopping).

## `includeTimeline` (type: `boolean`):

Fetch the Interest Over Time series (/trends/api/widgetdata/multiline).

## `includeRegions` (type: `boolean`):

Fetch the geographic breakdown (/trends/api/widgetdata/comparedgeo).

## `includeRelated` (type: `boolean`):

Fetch both Related Queries and Related Topics (top and rising lists) via /trends/api/widgetdata/relatedsearches.

## `hl` (type: `string`):

BCP-47 language tag for labels and related topics (e.g., 'en-US', 'es-ES', 'pt-BR').

## `maxItems` (type: `integer`):

Maximum number of successful dataset items (terms or comparison groups) to output.

## `proxyGroup` (type: `string`):

Apify Proxy group to route requests through when proxy is enabled: 'DATACENTER' (default, fast and cost-effective) or 'RESIDENTIAL' (recommended if Google rate-limits datacenter IPs).

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

Apify Proxy or custom proxy configuration. Uses datacenter/standard proxy by default on Apify; works directly without proxy in local environments.

## Actor input object example

```json
{
  "keywords": [
    "artificial intelligence",
    "machine learning",
    "python"
  ],
  "compare": false,
  "geo": "US",
  "timeRange": "today 3-m",
  "category": 0,
  "property": "",
  "includeTimeline": true,
  "includeRegions": false,
  "includeRelated": false,
  "hl": "en-US",
  "maxItems": 20,
  "proxyGroup": "DATACENTER",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

No description

# 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 = {
    "keywords": [
        "artificial intelligence",
        "machine learning",
        "python"
    ],
    "compare": false,
    "geo": "US",
    "timeRange": "today 3-m",
    "category": 0,
    "property": "",
    "includeTimeline": true,
    "includeRegions": false,
    "includeRelated": false,
    "hl": "en-US",
    "maxItems": 20,
    "proxyGroup": "DATACENTER",
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("rar_888/google-trends").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 = {
    "keywords": [
        "artificial intelligence",
        "machine learning",
        "python",
    ],
    "compare": False,
    "geo": "US",
    "timeRange": "today 3-m",
    "category": 0,
    "property": "",
    "includeTimeline": True,
    "includeRegions": False,
    "includeRelated": False,
    "hl": "en-US",
    "maxItems": 20,
    "proxyGroup": "DATACENTER",
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("rar_888/google-trends").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 '{
  "keywords": [
    "artificial intelligence",
    "machine learning",
    "python"
  ],
  "compare": false,
  "geo": "US",
  "timeRange": "today 3-m",
  "category": 0,
  "property": "",
  "includeTimeline": true,
  "includeRegions": false,
  "includeRelated": false,
  "hl": "en-US",
  "maxItems": 20,
  "proxyGroup": "DATACENTER",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call rar_888/google-trends --silent --output-dataset

```

## MCP server setup

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

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/LwNEcjkgCj1e3ma2Y/builds/aEx6cn4hnyhHhDyoE/openapi.json
