# Google Trends Scraper (Keyless) (`subimpact/google-trends-scraper-keyless`) Actor

Scrape Google Trends interest-over-time, related queries/topics, and per-region interest for keywords. No API key, no browser, no captcha. Up to 5 keywords compared per call. $0.02 per keyword bundle, charged only for delivered keywords.

- **URL**: https://apify.com/subimpact/google-trends-scraper-keyless.md
- **Developed by:** [subimpact](https://apify.com/subimpact) (community)
- **Categories:** SEO tools, Developer tools
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 keyword trends bundles

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 (Keyless)

Apify Actor that pulls **Google Trends** data with **no API key, no browser, and no captcha solving** — plain HTTP against Google's internal `trends/api` endpoints using the NID-cookie warm-up trick.

### What it extracts

Per keyword batch (up to 5 keywords compared in one call):

| Widget | Output rows | Toggle (default) |
|---|---|---|
| Interest over time | `type: "timeline"` — one row per period, 0-100 interest | `includeTimeseries` (on) |
| Related queries | `type: "relatedQuery"` — TOP + RISING lists with rank | `includeRelatedQueries` (off) |
| Related topics | `type: "relatedTopic"` — TOP + RISING lists | `includeRelatedTopics` (off) |
| Interest by region | `type: "geo"` — region code/name + 0-100 value | `includeGeoMap` (off) |

Failed batches emit `type: "error"` rows with the reason instead of silently disappearing.

### Input

```json
{
  "keywords": ["coffee", "iced coffee"],
  "geo": "US",
  "timeRange": "today 12-m",
  "includeTimeseries": true,
  "includeRelatedQueries": true
}
```

- `keywords` (required): array of strings (max 5 per comparison batch; more are split into batches)
- `geo`: 2-letter country code (`US`, `MY`, …) or `""` / omit = 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`, or `"YYYY-MM-DD YYYY-MM-DD"`
- `category`: Google Trends category id (default 0 = all)
- `property`: `""` web search, `images`, `news`, `youtube`, `froogle`
- `tzOffset`: timezone offset in minutes (default 0; e.g. -480 for UTC+8)
- `maxRelatedItems`: cap per TOP/RISING list (default 25)
- `delaySeconds`: politeness delay between requests (default 1.5)
- `proxyConfiguration`: Apify proxy config — pass `{"useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"]}` if datacenter IPs get throttled

### Pricing

Pay-per-event: **$0.02 per keyword bundle** (charged only for keywords whose data was actually delivered; failed batches are not charged). One bundle = interest-over-time + related queries/topics + interest-by-region for one keyword.

### How the keyless trick works

1. `GET https://trends.google.com/trends/` with a browser UA → harvest the `NID` cookie.
2. `GET /trends/api/explore?hl=en-US&tz=<tz>&req=<urlencoded compact JSON>` → XSSI-prefix-stripped JSON → pick widgets by id (`TIMESERIES`, `RELATED_QUERIES`, `RELATED_TOPICS`, `GEO_MAP`) — each carries a token.
3. `GET /trends/api/widgetdata/multiline|relatedsearches|comparedgeo` with the widget's own `request` object (sent verbatim) + token.

429s trigger warm-up + retry (5s / 10s); persistent 429 means the egress IP is throttled — add a proxy or back off.

Gotchas baked in (all verified against the live API 2026-09-25):

- The XSSI prefix is `)]}'` **followed by a newline** in current responses — naive `)]}',` startswith checks fail.
- Send the widget `request` verbatim with `%20`-encoded spaces. Do **not** do the extension-style `space → +` substitution before strict encoding: that produces `%2B`, which Google rejects with 400.
- `GEO_MAP` uses the `/widgetdata/comparedgeo` endpoint (not `multiline`).
- Timeline rows are dicts in the current format (`value: [n]` arrays, not arrays of arrays).
- Related `rankedList[0]` = TOP, `[1]` = RISING (`listName` field is absent).
- `RELATED_TOPICS` may come back empty from some egress IPs — treated as no-data, not an error.

### Run locally

```bash
apify run --purge
```

### Deploy

```bash
apify push
```

# Actor input Schema

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

Keywords to track. Up to 5 are compared in one Trends call; more are split into batches.

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

Two-letter country code (US, MY, GB...). Leave empty for worldwide.

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

Trends time range. For a custom range, run via API with 'YYYY-MM-DD YYYY-MM-DD'.

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

Google Trends category id (0 = all categories).

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

Web search (''), images, news, youtube, or froogle (Google Shopping).

## `includeTimeseries` (type: `boolean`):

Emit timeline rows (0-100 interest per period).

## `includeRelatedQueries` (type: `boolean`):

Emit TOP + RISING related queries per keyword.

## `includeRelatedTopics` (type: `boolean`):

Emit related topics (may be empty on some egress IPs).

## `includeGeoMap` (type: `boolean`):

Emit per-region interest rows (states/provinces of the target geo).

## `maxRelatedItems` (type: `integer`):

Cap per TOP/RISING list (Google returns ~25).

## `tzOffset` (type: `integer`):

e.g. -480 for UTC+8. Affects hourly/daily bucketing.

## `delaySeconds` (type: `number`):

Politeness delay. Raise if you see 429 warnings.

## `batchSize` (type: `integer`):

Max keywords compared per Trends call (Google allows up to 5).

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

Optional. Add RESIDENTIAL proxy if datacenter IPs get throttled (HTTP 429).

## Actor input object example

```json
{
  "keywords": [
    "coffee",
    "iced coffee"
  ],
  "geo": "US",
  "timeRange": "today 12-m",
  "includeTimeseries": true,
  "maxRelatedItems": 25,
  "delaySeconds": 1.5,
  "batchSize": 5
}
```

# Actor output Schema

## `recordType` (type: `string`):

timeline | relatedQuery | relatedTopic | geo | error

## `keyword` (type: `string`):

Primary keyword for this record

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

Two-letter country code or empty (worldwide)

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

e.g. 'today 12-m'

## `date` (type: `string`):

Formatted period (timeline rows)

## `timestamp` (type: `string`):

Period start unix seconds (timeline)

## `value` (type: `string`):

Interest 0-100, or RISING %

## `formattedValue` (type: `string`):

'65', '98%', 'Breakout', '+1,050%'

## `listType` (type: `string`):

top | rising (related records)

## `rank` (type: `string`):

Position in TOP/RISING list

## `query` (type: `string`):

Related query or topic string

## `regionCode` (type: `string`):

e.g. 'US-WY' (geo records)

## `regionName` (type: `string`):

e.g. 'Wyoming' (geo records)

## `error` (type: `string`):

Error message for failed batches

## `scrapedAt` (type: `string`):

ISO timestamp

# 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": [
        "coffee",
        "iced coffee"
    ],
    "geo": "US",
    "timeRange": "today 12-m",
    "category": 0,
    "property": "",
    "includeTimeseries": true,
    "includeRelatedQueries": false,
    "includeRelatedTopics": false,
    "includeGeoMap": false,
    "maxRelatedItems": 25,
    "tzOffset": 0,
    "delaySeconds": 1.5,
    "batchSize": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("subimpact/google-trends-scraper-keyless").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": [
        "coffee",
        "iced coffee",
    ],
    "geo": "US",
    "timeRange": "today 12-m",
    "category": 0,
    "property": "",
    "includeTimeseries": True,
    "includeRelatedQueries": False,
    "includeRelatedTopics": False,
    "includeGeoMap": False,
    "maxRelatedItems": 25,
    "tzOffset": 0,
    "delaySeconds": 1.5,
    "batchSize": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("subimpact/google-trends-scraper-keyless").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": [
    "coffee",
    "iced coffee"
  ],
  "geo": "US",
  "timeRange": "today 12-m",
  "category": 0,
  "property": "",
  "includeTimeseries": true,
  "includeRelatedQueries": false,
  "includeRelatedTopics": false,
  "includeGeoMap": false,
  "maxRelatedItems": 25,
  "tzOffset": 0,
  "delaySeconds": 1.5,
  "batchSize": 5
}' |
apify call subimpact/google-trends-scraper-keyless --silent --output-dataset

```

## MCP server setup

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

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/nIYMk0vVi6edNLRId/builds/6wNceAjYHmS9WA7ct/openapi.json
