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

Interest over time, interest by region, and related queries from Google Trends. Cookie-primed sessions and proxy rotation for reliable runs.

- **URL**: https://apify.com/upright\_guardian/google-trends-scraper.md
- **Developed by:** [Cassidy Rice](https://apify.com/upright_guardian) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $120.00 / 1,000 keyword 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 Scraper

Pull Google Trends data as clean, structured rows: **interest over time**, **interest by region**, and **top & rising related queries** — for any keyword, region, and timeframe.

Built for runs that actually finish. Google rate-limits Trends aggressively, and most scrapers hand you an empty dataset when it does. This one primes a real browser session before every request and rotates proxy sessions on a 429, so you get data instead of a failed run.

### What you get

| Output | What it contains |
|---|---|
| Interest over time | Relative search interest (0–100) at each point in your timeframe, with partial-period flagging |
| Interest by region | Interest broken down by country or sub-region (e.g. US states) |
| Related queries | Top and rising related searches, including **Breakout** terms |

### Input

| Field | Description |
|---|---|
| `searchTerms` | Keywords to look up. Up to 100 per run. |
| `geo` | `US`, `GB`, `DE`, or a sub-region like `US-CA`. Empty = worldwide. |
| `timeframe` | Preset range, from the past hour to 2004–present. |
| `customTimeframe` | Exact range as `YYYY-MM-DD YYYY-MM-DD`. Overrides the preset. |
| `keywordType` | `Search term` (literal text) or `Topic` (Google's entity — groups spellings, synonyms and languages). |
| `compareTerms` | Off: each term gets its own 0–100 scale. On: all terms share one scale, like the Trends comparison view (max 5). |
| `category` | Trends category ID. `0` = all. |
| `property` | Web, Images, News, YouTube, or Shopping. |
| `proxyConfiguration` | **Use residential proxies.** This is the single biggest factor in run reliability. |

#### Example input

```json
{
  "searchTerms": ["electric bike", "e-bike"],
  "geo": "US",
  "timeframe": "today 12-m",
  "interestOverTime": true,
  "relatedQueries": true,
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
```

### Output

Every row is flat and CSV-friendly, tagged with a `resultType`.

```json
{
  "resultType": "interest_over_time",
  "searchTerm": "electric bike",
  "geo": "US",
  "timeframe": "today 12-m",
  "date": "Jun 21",
  "timestamp": 1782000000,
  "value": 62,
  "isPartial": false
}
```

```json
{
  "resultType": "related_queries",
  "searchTerm": "electric bike",
  "bucket": "rising",
  "query": "e bike under 1000",
  "value": 5000,
  "formattedValue": "Breakout"
}
```

Export as JSON, CSV, Excel, or pull from the API.

### Understanding the numbers

Google Trends values are **relative, not absolute**. `100` is the peak point in your chosen window, and everything else is scaled against it. Changing the timeframe or region changes every number. Trends never reports raw search volume, so these figures show shape and direction, not counts.

With `compareTerms` off, each term is scaled independently — so a `100` for one term and a `100` for another say nothing about which is bigger. Turn `compareTerms` on when you need terms measured against each other.

### Notes and limits

- **Related topics are not offered.** Google's related-topics endpoint currently returns an empty list for every caller, entity or not. Rather than ship a switch that silently produces nothing, it's left out. If Google restores it, it'll be added.
- **Residential proxies matter.** Datacenter IPs get 429'd constantly. The actor retries and re-primes, but residential proxies are what make long runs dependable.
- Very rare keywords legitimately return no data — Trends suppresses low-volume terms.
- Hourly timeframes (`now 1-H`, `now 4-H`) only support short windows and return finer-grained points.

### Local development

```bash
python3 test_actor.py   # offline checks, no network
apify run               # needs the Apify CLI
```

# Actor input Schema

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

Keywords to look up. Each term is fetched separately unless you turn on 'Compare terms'. Maximum 100 per run.

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

Two-letter country code such as US, GB, DE, or a sub-region such as US-CA. Leave empty for worldwide.

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

A Google Trends range. Use a preset, or a custom range written as 'YYYY-MM-DD YYYY-MM-DD'.

## `customTimeframe` (type: `string`):

Overrides Timeframe when set. Format: 'YYYY-MM-DD YYYY-MM-DD', for example '2024-01-01 2024-06-30'.

## `keywordType` (type: `string`):

Search term matches the literal text people typed. Topic matches Google's entity for the term, which groups spellings, synonyms and languages together - useful for measuring a concept rather than one phrasing.

## `interestOverTime` (type: `boolean`):

Relative search interest (0-100) for each point in the timeframe.

## `interestByRegion` (type: `boolean`):

Relative interest broken down by country or sub-region.

## `relatedQueries` (type: `boolean`):

Top and rising related search queries, including breakout terms.

## `compareTerms` (type: `boolean`):

Off (default): every term is measured on its own 0-100 scale, so terms are independent. On: all terms share one scale, exactly like the Google Trends comparison view. Maximum 5 terms when on.

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

Google Trends category ID. 0 means all categories. For example 7 = Finance, 71 = Food & Drink, 3 = News.

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

Which Google surface to measure.

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

Residential proxies are strongly recommended. Google rate-limits datacenter IP ranges aggressively, which is the most common cause of empty runs.

## Actor input object example

```json
{
  "searchTerms": [
    "electric bike"
  ],
  "geo": "US",
  "timeframe": "today 12-m",
  "customTimeframe": "",
  "keywordType": "query",
  "interestOverTime": true,
  "interestByRegion": false,
  "relatedQueries": false,
  "compareTerms": false,
  "category": 0,
  "property": "",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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": [
        "claude ai",
        "chatgpt"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("upright_guardian/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 = { "searchTerms": [
        "claude ai",
        "chatgpt",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("upright_guardian/google-trends-scraper").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": [
    "claude ai",
    "chatgpt"
  ]
}' |
apify call upright_guardian/google-trends-scraper --silent --output-dataset

```

## MCP server setup

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

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/Oo1sMriA7sxRiwLid/builds/d4WlkOKI6VZtLlKVN/openapi.json
