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

Reliable Google Trends data — interest over time and related queries — for any keywords, geo and timeframe. Proxy-rotating with backoff so it does not 429 like the rest.

- **URL**: https://apify.com/scrapeharbor/google-trends-scraper.md
- **Developed by:** [Scrape Harbor](https://apify.com/scrapeharbor) (community)
- **Categories:** SEO tools, Marketing
- **Stats:** 2 total users, 1 monthly users, 100.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/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Google Trends Scraper

Reliable Google Trends data — **interest over time** and **related queries** —
for any keywords, geo, and timeframe. Returns clean JSON.

The public store's incumbent Trends actors are unreliable (the official one sits
at ~3.1★ with ~1-in-5 runs failing) because Google rate-limits the Trends
endpoints hard. This actor is built around that: the real widget-token dance,
correct headers, exponential backoff, and **per-request proxy rotation**, so runs
don't 429 out.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `keywords` | string\[] | — (required) | Terms to pull. One result row per term. |
| `geo` | string | `US` | Country code (`US`, `GB`, …), sub-region (`US-CA`), or `""` for Worldwide. |
| `timeframe` | string | `today 12-m` | Trends window token (`now 7-d`, `today 3-m`, `today 5-y`, `all`, …). |
| `dataTypes` | string\[] | both | Any of `timeseries`, `related_queries`. |
| `proxyConfiguration` | object | Apify Proxy on | Strongly recommended — single-IP runs get throttled fast. |

### Output (one dataset item per keyword)

```json
{
  "keyword": "bitcoin",
  "geo": "US",
  "timeframe": "today 12-m",
  "interest_over_time": [{ "time": "Jul 20 - 26, 2025", "value": 20 }, ...],
  "related_queries": [{ "query": "bitcoin price", "value": 100, "link": "..." }, ...]
}
```

A keyword that fails after retries yields `{ "keyword": ..., "error": ... }`
instead of aborting the whole run.

### Local development

```bash
python3 tests/test_parsers.py          # network-independent parser tests
python3 -c 'import sys; sys.path.insert(0,"src"); from trends_core import TrendsClient; \
  print(TrendsClient().fetch("bitcoin", timeframe="today 3-m", want=("timeseries",)))'
```

> Note: a single residential IP gets throttled on the `relatedsearches` endpoint
> after a handful of calls. That's the exact problem the actor solves in
> production via Apify Proxy rotation; expect local bare-IP testing to 429.

### Publishing

```bash
npm i -g apify-cli && apify login   # free account
apify push                          # builds on Apify, lands in your store profile
```

# Actor input Schema

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

One or more terms to pull Google Trends data for.

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

Two-letter country code (US, GB, ...) or empty for Worldwide. Sub-regions like US-CA are supported.

## `timeframe` (type: `string`):

Google Trends time window token.

## `dataTypes` (type: `array`):

Which widgets to fetch per keyword.

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

Apify Proxy is strongly recommended — Google Trends rate-limits single IPs aggressively.

## Actor input object example

```json
{
  "keywords": [
    "ozempic",
    "wegovy"
  ],
  "geo": "US",
  "timeframe": "today 12-m",
  "dataTypes": [
    "timeseries",
    "related_queries"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# 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": [
        "bitcoin",
        "ethereum"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapeharbor/google-trends-scraper").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": [
        "bitcoin",
        "ethereum",
    ] }

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

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": [
    "bitcoin",
    "ethereum"
  ]
}' |
apify call scrapeharbor/google-trends-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scrapeharbor/google-trends-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/4dOg5sGNr2AG1Jydj/builds/yvwDe4rHB32hdabxL/openapi.json
