# Google Trends Scraper (`hexagonal_larder/google-trends`) Actor

Interest over time, interest by region and related queries from Google Trends for a list of keywords.

- **URL**: https://apify.com/hexagonal_larder/google-trends.md
- **Developed by:** [kaeru333 kaeru333](https://apify.com/hexagonal_larder) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 result items

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 Scraper

Get **interest over time**, **interest by region** and **related queries** (top and rising) from Google Trends for any list of keywords. One clean JSON item per keyword, ready to export to CSV, Excel, Google Sheets or your own pipeline through the Apify API.

**Built for reliability.** Google rate-limits Trends aggressively (HTTP 429). This Actor detects rate limits, switches to a fresh proxy IP, keeps the cookie Google hands out instead of throwing it away, and retries failed keywords once more at the end of the run. **You only pay for keywords that were actually delivered.**

### What can it do?

- Interest over time (0–100) for any period from the past hour to 2004–present, or a custom date range
- Interest by region (countries, or sub-regions when you pick a country)
- Top and rising related queries, including "Breakout" terms
- Any Google Trends location (`US`, `JP`, `GB`, `US-CA`, …) or worldwide
- Run statistics (requests, rate limits, traffic, duration) saved with every run

### How to use it

1. Click **Try for free**.
2. Enter one or more keywords in **Search terms**.
3. Optionally pick a **Location** and **Time range**.
4. Click **Start** and download the results in JSON, CSV, Excel or HTML.

A single keyword usually finishes in **about 20–30 seconds**; each additional keyword adds roughly 10 seconds.

### Input example

```json
{
  "searchTerms": ["bitcoin", "ethereum", "solana"],
  "geo": "US",
  "timeRange": "today 12-m",
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
```

| Field | Description | Default |
|---|---|---|
| `searchTerms` | Keywords to look up. Each keyword becomes one result. | required |
| `geo` | Google Trends geo code (`US`, `JP`, `US-CA`, …). Empty = worldwide. | worldwide |
| `timeRange` | `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` | `today 12-m` |
| `customTimeRange` | `YYYY-MM-DD YYYY-MM-DD`; overrides `timeRange`. | empty |
| `proxyConfiguration` | Apify Proxy settings. Residential proxy is strongly recommended: in our tests Google blocked datacenter IPs after sustained use. | Apify residential proxy |
| `cookieMode` | `never` (recommended), `onRateLimit` or `always`. Controls whether the ~130 KB Trends home page is loaded to get cookies. | `never` |
| `stopAfterConsecutiveFailures` | Stop early if this many keywords fail in a row (Google is blocking), instead of burning time. `0` = never. | `5` |
| `retryFailedKeywords` | Retry failed keywords once more on a fresh IP at the end of the run. | `true` |
| `maxRetries` | Retries per request after HTTP 429/5xx; each retry uses a new proxy IP. | `3` |
| `delayBetweenKeywordsSecs` | Pause between keywords. | `3` |

### Output example

```json
{
  "searchTerm": "bitcoin",
  "geo": "WORLDWIDE",
  "timeRange": "today 12-m",
  "interestOverTime": [
    { "date": "Oct 12 – 18, 2025", "timestamp": 1760227200, "value": 60, "isPartial": false }
  ],
  "interestByRegion": [
    { "geoCode": "CH", "geoName": "Switzerland", "value": 100 }
  ],
  "relatedQueriesTop": [
    { "query": "bitcoin price", "value": 100, "formattedValue": "100" }
  ],
  "relatedQueriesRising": [
    { "query": "bitcoin etf", "value": 27050, "formattedValue": "Breakout" }
  ]
}
```

| Field | Description |
|---|---|
| `searchTerm` | The keyword you asked for |
| `geo` | Geo code, or `WORLDWIDE` |
| `timeRange` | Google Trends time range used |
| `interestOverTime` | `{date, timestamp, value, isPartial}`; `value` is 0–100 |
| `interestByRegion` | `{geoCode, geoName, value}` sorted by value |
| `relatedQueriesTop` | `{query, value, formattedValue}` |
| `relatedQueriesRising` | `{query, value, formattedValue}`; `formattedValue` can be `Breakout` |

Run statistics (HTTP statuses, proxy sessions used, traffic, duration) are stored in the run's key-value store under `RUN_STATS`.

### How much does it cost?

This Actor uses **pay per result**: you are charged one event for every keyword delivered to the dataset. Keywords that fail are **not** charged. Platform usage (compute, proxy) is included in the price.

**$2.50 per 1,000 results** ($0.0025 per keyword).

| Keywords | Cost |
|---|---|
| 100 | $0.25 |
| 1,000 | $2.50 |
| 10,000 | $25.00 |

You can set a maximum total charge for a run; the Actor stops cleanly when the limit is reached.

### Limitations

- Values are scaled 0–100 **per keyword** (each keyword is fetched separately), so they are not directly comparable across keywords the way Google's multi-keyword compare view is.
- Keywords are processed one after another to stay under Google's rate limits. Very large lists (thousands of keywords) are better split into several runs.
- Google Trends occasionally rate-limits even fresh IPs. The Actor retries automatically; with the default settings it delivered 90 out of 90 keywords in our test runs (October 2026); anything still failing is listed in `RUN_STATS.keywordResults` and is not charged.
- Categories, Google Shopping / YouTube / News search types and "trending now" are not supported yet.

### FAQ

**Can I use it through the API or with integrations?**
Yes. Like every Apify Actor, you can start it through the Apify API, schedule it, and connect it to Make, Zapier, Google Sheets, Slack and more.

**Why did a keyword fail?**
Usually because Google kept rate-limiting it. Run it again later; failed keywords cost nothing.

**Is scraping Google Trends legal?**
This Actor only reads publicly visible, aggregated data through the same endpoints the Google Trends website uses. It does not collect personal data. You are responsible for making sure your use complies with Google's terms and applicable law.

### Disclaimer

This Actor is not affiliated with, endorsed by, or sponsored by Google.

# Actor input Schema

## `searchTerms` (type: `array`):

Keywords to look up. Each keyword is fetched separately and produces one result item.

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

Google Trends geo code, e.g. US, JP, GB, US-CA. Leave empty for worldwide.

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

Predefined Google Trends time range. Ignored when Custom time range is set.

## `customTimeRange` (type: `string`):

Optional custom range in the form "YYYY-MM-DD YYYY-MM-DD". Overrides Time range.

## `maxRetries` (type: `integer`):

How many times to retry a request after HTTP 429 or 5xx. With a proxy, each retry uses a new proxy session (new IP).

## `delayBetweenKeywordsSecs` (type: `integer`):

Pause between keywords to reduce rate limiting.

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

Proxy to use. Residential proxy is recommended: in our tests datacenter IPs got blocked by Google after sustained use. On HTTP 429 the Actor switches to a new proxy session (new IP).

## `cookieMode` (type: `string`):

How to get Google cookies. 'never' (recommended): skip the ~130 KB Trends home page; Google hands out the cookie with its first response and the Actor retries once on the same IP to use it. 'always': load the home page on every proxy session. 'onRateLimit': load it only on sessions opened after a rate limit.

## `retryFailedKeywords` (type: `boolean`):

After all keywords are processed, try the failed ones once more on a fresh proxy session. Failed keywords are never charged.

## `stopAfterConsecutiveFailures` (type: `integer`):

If this many keywords fail in a row, Google is most likely blocking the proxy pool; skip the rest instead of wasting time. 0 = never stop.

## Actor input object example

```json
{
  "searchTerms": [
    "bitcoin"
  ],
  "geo": "",
  "timeRange": "today 12-m",
  "customTimeRange": "",
  "maxRetries": 3,
  "delayBetweenKeywordsSecs": 3,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  },
  "cookieMode": "never",
  "retryFailedKeywords": true,
  "stopAfterConsecutiveFailures": 5
}
```

# 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 = {
    "searchTerms": [
        "bitcoin"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("hexagonal_larder/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 = {
    "searchTerms": ["bitcoin"],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("hexagonal_larder/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 '{
  "searchTerms": [
    "bitcoin"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call hexagonal_larder/google-trends --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hexagonal_larder/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/RENXKmXpH0En53O0y/builds/pNrKwLqH0CCJRpbKD/openapi.json
