# Google Trends Scraper (Reliable) (`tolerant_stoat/google-trends-reliable-scraper`) Actor

Interest over time, interest by region, related queries & topics, and daily trending searches from Google Trends. Session rotation keeps runs from dying on 429s, and you're never charged for terms that fail.

- **URL**: https://apify.com/tolerant_stoat/google-trends-reliable-scraper.md
- **Developed by:** [Nick Fisher](https://apify.com/tolerant_stoat) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 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 (Reliable)

Get **interest over time**, **interest by region** (country, state, city or US metro/DMA),
**related queries** (top and rising, including Breakout), and **today's trending
searches** with traffic estimates and news links, for any keyword, country and time range.

Built to keep going when Google pushes back: every worker runs its own session
(own proxy IP plus its own Google cookie), sessions rotate automatically on `429`/captcha,
and a term that still fails gets one more try at the end of the run.
**You are never charged for terms that fail.** They're listed in the `RUN_SUMMARY` record instead.

### What you can extract

| Data | Notes |
|---|---|
| Interest over time | 0–100 index, hourly to monthly points depending on range; `isPartial` flags the latest incomplete bucket |
| Interest by region | Auto, `COUNTRY`, `REGION`, `CITY` (with coordinates) or `DMA` (US metros) |
| Related queries | Top (0–100) and rising (`+250%` or `Breakout`), with Trends links |
| Related topics | Included when Google returns them. Google currently serves empty topic lists to API traffic |
| Trending now | Per country: rank, search, approx. traffic (`5000+`), start time, image, news articles |
| Search types | Web, Images, News, Google Shopping, YouTube |
| Comparisons | Up to 5 terms on the same 0–100 scale (`compareTerms: true`; more terms are batched in 5s) |

### Example input

```json
{
  "searchTerms": ["iphone", "pixel", "galaxy"],
  "compareTerms": true,
  "geo": "US",
  "timeRange": "today 12-m",
  "regionResolution": "DMA",
  "trendingNowGeos": ["US", "GB"],
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
```

`timeRange` accepts `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 `YYYY-MM-DD YYYY-MM-DD`.

### Example output (one item per term or comparison group)

```json
{
  "searchTerms": ["iphone", "pixel", "galaxy"],
  "geo": "US",
  "timeRange": "today 12-m",
  "property": "web",
  "trendsUrl": "https://trends.google.com/trends/explore?date=today+12-m&q=iphone%2Cpixel%2Cgalaxy&geo=US",
  "interestOverTime": [
    { "date": "2025-10-19T00:00:00.000Z", "values": { "iphone": 54, "pixel": 6, "galaxy": 19 }, "isPartial": false }
  ],
  "interestByRegion": [
    { "geoCode": "US-LA", "geoName": "Louisiana", "values": { "iphone": 83, "pixel": 3, "galaxy": 14 } }
  ],
  "regionResolution": "REGION",
  "relatedQueries": {
    "iphone": { "top": [{ "query": "iphone 17", "value": 100, "formattedValue": "100", "isBreakout": false, "link": "..." }], "rising": [] }
  },
  "scrapedAt": "2026-10-18T22:10:00.000Z"
}
```

Trending-now rows have `type: "trendingNow"` and appear in the **Trending now** dataset view.

### Tips

- **Proxies:** Google throttles per IP. Small runs work on default Apify Proxy. For hundreds of terms, use `RESIDENTIAL`.
- **Concurrency:** 2–3 is the sweet spot. Higher gets you rate-limited faster, not results faster.
- Values are relative (0–100), not absolute search volumes. Comparisons only share a scale inside one group of up to 5 terms.

### Development

```
npm install
npm test                      # parser tests against saved Google responses
node src/main.js              # local run; input in storage/key_value_stores/default/INPUT.json
apify push                    # deploy (needs `npm i -g apify-cli` and `apify login`)
```

# Actor input Schema

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

Keywords to look up. Each term becomes one result, unless 'Compare terms' is on.

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

Group terms in batches of up to 5 so their values are on the same 0-100 scale (like adding terms in the Trends UI). Off = each term is scaled independently.

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

ISO country or region code, e.g. US, GB, US-CA, DE. Empty = worldwide.

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

A 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 a custom range 'YYYY-MM-DD YYYY-MM-DD'.

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

Google Trends category ID (0 = all categories). E.g. 31 = Programming, 7 = Finance.

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

Which Google property to measure.

## `includeInterestOverTime` (type: `boolean`):

0-100 search interest for each point in the time range.

## `includeInterestByRegion` (type: `boolean`):

0-100 search interest per country, region, city or metro area.

## `regionResolution` (type: `string`):

Granularity for interest by region. Leave on Auto unless you need cities or DMAs (US only).

## `includeLowVolumeRegions` (type: `boolean`):

Also return regions where Google has too little data to rank them reliably.

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

Top and rising searches related to each term, including 'Breakout' queries.

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

Top and rising related topics. Google currently returns these empty for API traffic.

## `trendingNowGeos` (type: `array`):

Also fetch today's trending searches (with traffic estimates and news links) for these country codes, e.g. US, GB, IN. One result per trending search.

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

Google rate-limits per IP. Residential proxies give the best success rate on large runs.

## `maxConcurrency` (type: `integer`):

Parallel sessions. Higher is faster but more likely to hit rate limits.

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

How many times one request is retried (each on a fresh session) before the term is requeued or reported as failed.

## `failThreshold` (type: `number`):

Mark the run as failed when this share of tasks fails (0-1). 1 = only when every task fails. Failed tasks are never charged either way.

## Actor input object example

```json
{
  "searchTerms": [
    "python",
    "rust"
  ],
  "compareTerms": false,
  "geo": "",
  "timeRange": "today 12-m",
  "category": 0,
  "property": "",
  "includeInterestOverTime": true,
  "includeInterestByRegion": true,
  "regionResolution": "",
  "includeLowVolumeRegions": false,
  "includeRelatedQueries": true,
  "includeRelatedTopics": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "maxConcurrency": 2,
  "maxRetries": 8,
  "failThreshold": 1
}
```

# Actor output Schema

## `keywordResults` (type: `string`):

One item per search term or comparison group: interest over time, interest by region, related queries and topics.

## `trendingNow` (type: `string`):

One item per trending search per country, with approximate traffic and news links.

## `runSummary` (type: `string`):

Items pushed, terms that failed and why, and request/retry/session stats.

# 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": [
        "python",
        "rust"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("tolerant_stoat/google-trends-reliable-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": [
        "python",
        "rust",
    ],
    "proxyConfiguration": { "useApifyProxy": True },
}

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tolerant_stoat/google-trends-reliable-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/0oM0xe1JQnyFizFq1/builds/geDrBWw4kxkNKyRsC/openapi.json
