# Google Trends Scraper & API (Reliable) (`cleanrows/google-trends`) Actor

Reliable Google Trends API alternative: interest over time, by country, region, metro and city, and related queries for any keyword. Residential proxies included, one clean row per term, failed terms never charged.

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

## Pricing

from $2.00 / 1,000 search terms

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 Google Trends data for any list of search terms: **interest over time, interest by country / subregion / metro / city, related topics and related queries**. You get one clean row per search term, ready for a spreadsheet, a dashboard or an AI pipeline.

### What it does

For every search term (or Google Trends URL) you give it, the Actor collects everything the Google Trends *Explore* page shows:

| Field | What it is |
|---|---|
| `interestOverTime_timelineData` | The interest-over-time chart, 0-100, one point per hour, day or week depending on the time range |
| `interestOverTime_averages` | Average interest per term (filled for comparisons) |
| `interestBy` | Interest by country (worldwide searches) |
| `interestBySubregion` | Interest by state / region (when you pick a country) |
| `interestByMetro` | Interest by metro area (when you pick a US state) |
| `interestByCity` | Interest by city (when you pick a country or region; only cities with data) |
| `relatedTopics_top`, `relatedTopics_rising` | Related topics. Currently Google returns these empty for automated requests (see FAQ) |
| `relatedQueries_top`, `relatedQueries_rising` | Related search queries, including "Breakout" ones |

### Why it's reliable

- **Residential proxy by default.** Google Trends blocks shared datacenter IPs after a few dozen requests. This Actor uses residential IPs, so it keeps working on large lists.
- **Automatic retries.** If a request fails or gets rate-limited, the term is retried on a fresh IP with a fresh session, up to 4 times, with backoff.
- **No partial rows.** A row is saved only when every request behind it (timeline, regions, related topics and queries) succeeded. If one part fails, the whole term is retried. You never get a row with a silently missing section.
- **You never pay for failures.** A term that still fails after retries, or that Google has no data for, is not saved and **not charged**. It is listed with the reason in the run's `SUMMARY` record (key-value store), so you know exactly what to rerun.
- **Your spending cap is respected.** If you set a maximum cost per run, the Actor stops before going over it.

### Input example

```json
{
  "searchTerms": ["web scraping", "air fryer", "pickleball"],
  "timeRange": "today 12-m",
  "geo": "",
  "maxItems": 0
}
```

| Field | Description |
|---|---|
| `searchTerms` | List of search terms, one row each. Required unless you use `startUrls`. |
| `isMultiple` | If `true`, a comma separates terms that are compared in one chart, e.g. `"pizza, burger"` (up to 5). |
| `timeRange` | `now 1-H`, `now 4-H`, `now 1-d`, `now 7-d`, `today 1-m`, `today 3-m`, `today 12-m` (default), `today 5-y`, `all`. |
| `customTimeRange` | `"YYYY-MM-DD YYYY-MM-DD"`, e.g. `"2024-01-01 2024-12-31"`. Overrides `timeRange`. |
| `geo` | Country or region code in capitals, e.g. `US`, `DE`, `US-CA`. Empty = worldwide. |
| `viewedFrom` | Country code for the proxy exit (e.g. `us`), so results look as they do from that country. |
| `category` | Numeric Google Trends category id (the `cat=` value in a Trends URL). Empty = all categories. |
| `startUrls` | Google Trends explore URLs copied from your browser. Their `q`, `geo`, `date`, `cat` and `gprop` are used as-is. |
| `maxItems` | Maximum number of rows to save. `0` = no limit. |

### Output example

One row per search term (arrays shortened):

```json
{
  "inputUrlOrTerm": "web scraping",
  "searchTerm": "web scraping",
  "geo": "WORLDWIDE",
  "timeRange": "today 12-m",
  "category": 0,
  "interestOverTime_timelineData": [
    { "time": "1793491200", "formattedTime": "Nov 1 – 7, 2026", "formattedAxisTime": "Nov 1, 2026", "value": [31], "hasData": [true], "formattedValue": ["31"] },
    { "time": "1794096000", "formattedTime": "Nov 8 – 14, 2026", "formattedAxisTime": "Nov 8, 2026", "value": [18], "hasData": [true], "formattedValue": ["18"], "isPartial": true }
  ],
  "interestOverTime_averages": [],
  "interestBy": [
    { "geoCode": "SH", "geoName": "St. Helena", "value": [100], "formattedValue": ["100"], "maxValueIndex": 0, "hasData": [true] }
  ],
  "interestBySubregion": [],
  "interestByMetro": [],
  "interestByCity": [],
  "relatedTopics_top": [],
  "relatedTopics_rising": [],
  "relatedQueries_top": [
    { "query": "web data scraping", "value": 100, "formattedValue": "100", "hasData": true, "link": "/trends/explore?q=web+data+scraping&date=today+12-m" }
  ],
  "relatedQueries_rising": [
    { "query": "best vpn 2026", "value": 32900, "formattedValue": "Breakout", "link": "/trends/explore?q=best+vpn+2026&date=today+12-m" }
  ],
  "scrapedAt": "2026-11-13T11:10:02.000Z"
}
```

With a country selected (`"geo": "US"`), `interestBy` stays empty and the breakdown comes by state and city instead (real rows for "bitcoin", US, past 12 months):

```json
{
  "geo": "US",
  "interestBySubregion": [
    { "geoCode": "US-WY", "geoName": "Wyoming", "value": [100], "formattedValue": ["100"], "maxValueIndex": 0, "hasData": [true] }
  ],
  "interestByCity": [
    { "coordinates": { "lat": 39.1156615, "lng": -77.5636015 }, "geoName": "Leesburg", "value": [100], "formattedValue": ["100"], "maxValueIndex": 0, "hasData": [true] }
  ]
}
```

For comparisons (`isMultiple`), each `value` array holds one number per compared term, `comparedTerms` lists the terms, and every related query carries a `searchTerm` field saying which term it belongs to.

### How much does it cost?

You pay **per search term successfully scraped**, at **$2.00 per 1,000 search terms** ($0.002 per term), plus a tiny $0.00005 fee per run. Proxy and platform usage are included in that price, so there are no other costs.

**Worked example:** 1,000 search terms in one run = 1,000 × $0.002 + $0.00005 = **$2.00**. If 12 of those terms fail, you pay for 988 = $1.98.

**Set a budget:** put a limit in *Max cost per run* and the Actor stops before going over it. With a $1 limit you get up to 499 terms.

### FAQ

**Why are some values `0` or `hasData: false`?**
That is what Google Trends itself shows: the term had too little search volume in that place or period.

**A term is missing from my results. Why?**
Either Google Trends has no data for that term and settings, or it still failed after all retries. Look at `failedTerms` in the `SUMMARY` record of the run's key-value store. Missing terms were not charged.

**Why are related topics empty?**
At the moment Google Trends returns an empty related-topics list for automated requests. The fields are kept so your integration doesn't break, and they will fill in if Google starts sending them again. Related *queries* (top and rising) work normally.

**Why do some city lists have only a few entries?**
Google lists cities only where it has enough data for your term and settings. Cities without data are left out, so a list can be short or empty while the state breakdown is complete.

**Why did one term fail every time while the others worked?**
For a few term + country + short time range combinations (for example a past-7-days search in one country), Google refuses the regional breakdown no matter which IP asks. Those terms are reported in `failedTerms` and not charged. You can try a longer time range, or leave the country empty.

**Can I compare several terms in one chart?**
Yes. Turn on `isMultiple` and write the terms separated by commas, e.g. `"iphone, samsung galaxy, pixel"` (up to 5).

**Can I get YouTube, News, Images or Shopping trends?**
Yes. Set the source in Google Trends in your browser, copy the URL (it contains `gprop=youtube` and so on) and paste it into `startUrls`.

**Do the numbers match the Google Trends website?**
Yes. These are the same numbers the website shows. Google scales each chart to 0-100, so values from different requests are only comparable within the same row.

**Can I use my own proxy?**
Yes, in the *Proxy* field under *Advanced*. Residential proxies work best. Datacenter proxies get blocked quickly by Google Trends.

# Actor input Schema

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

One Google Trends search term per line. Each term becomes one result row. Required unless you use Start URLs.

## `isMultiple` (type: `boolean`):

If checked, a comma separates terms that are compared against each other in one chart, e.g. "pizza, burger" (up to 5 terms). The result row then holds one value per compared term. If unchecked, a comma is part of the search term.

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

Predefined time range. Ignored if Custom time range is set.

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

Start and end date as "YYYY-MM-DD YYYY-MM-DD", e.g. "2024-01-01 2024-12-31". Overrides Time range.

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

Two-letter country code in capitals (e.g. US, DE) or a region code (e.g. US-CA). Leave empty for worldwide. Worldwide fills interestBy (by country); a country fills interestBySubregion and interestByCity; a US state fills interestByMetro and interestByCity.

## `viewedFrom` (type: `string`):

Two-letter country code (e.g. us, gb) for the residential proxy exit, so results look as they do from that country. Leave empty to let the proxy choose.

## `category` (type: `string`):

Numeric Google Trends category id, e.g. 71 (Food & Drink) or 7 (Finance). Leave empty for all categories. You can find the id in the cat= part of a Google Trends URL.

## `startUrls` (type: `array`):

Google Trends explore URLs copied from your browser, e.g. https://trends.google.com/trends/explore?q=web%20scraping\&geo=US. Their q, geo, date, cat and gprop settings are used as-is and override the fields above.

## `maxItems` (type: `integer`):

Maximum number of result rows to save. 0 means no limit.

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

Google Trends blocks shared datacenter IPs quickly, so residential proxy is strongly recommended and is the default.

## Actor input object example

```json
{
  "searchTerms": [
    "web scraping",
    "air fryer",
    "pickleball"
  ],
  "isMultiple": false,
  "timeRange": "",
  "geo": "",
  "viewedFrom": "",
  "category": "",
  "maxItems": 0,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (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": [
        "web scraping",
        "air fryer",
        "pickleball"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

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

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

```

## MCP server setup

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