# Google Trends API: pytrends Alternative (JSON) (`alfhar/google-trends-scraper-pro`) Actor

Fetches Google Trends data for a list of keywords. Input: keywords\[], geo, timeRange. Output: one JSON item per keyword with interestOverTime, interestByRegion, relatedQueries. Use for trend research, SEO, dashboards, AI agents. pytrends alternative, $0.003 per keyword.

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

## Pricing

Pay per event

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 API: pytrends alternative that returns clean JSON

**Google Trends scraper for developers.** Send a list of keywords, get one JSON item per keyword: interest over time, interest by region and top/rising related queries. No browser, no cookies to manage, no Python library to keep patched. Call it from the Apify API, from `apify-client` (Python / JavaScript), from the Apify MCP server in an AI agent, or from the Console.

> Built by the author of this Actor. It is a paid Actor (pay per event), see Pricing below.

### What it does (spec)

| | |
|---|---|
| **Does** | Fetches public Google Trends data for N keywords, any country, any timeframe |
| **Input** | `keywords` (array, required), optional `geo`, `timeRange`, `searchType`, `compareKeywords` |
| **Output** | Dataset, one item per keyword: `averageInterest`, `peakDate`, `interestOverTime[]`, `interestByRegion[]`, `relatedQueries.top/rising` |
| **Use when** | You need trend data in a script, dashboard, SEO tool, research pipeline or AI agent |
| **Price** | $0.003 per keyword returned + $0.005 per run start (see the pricing panel for current rates). Failed keywords are not charged |

### Example input and output

| Input | Output (one dataset item) |
|---|---|
| `{"keywords": ["bitcoin"], "geo": "EG", "timeRange": "today 12-m"}` | `keyword: "bitcoin"`, `averageInterest: 32.32`, `peakDate: "2026-05-03"`, `peakValue: 100`, `latestValue: 8`, plus the timeline, regions and related queries |
| `{"keywords": ["iphone", "samsung galaxy"], "compareKeywords": true, "geo": "SA"}` | Two items on one shared 0-100 scale, like the Google Trends compare view |
| `{"keywords": ["اسعار الذهب"], "geo": "EG"}` | Arabic and other non-Latin terms work unchanged |
| `{"keywords": ["ramadan"], "searchType": "youtube", "customTimeRange": "2025-01-01 2025-06-30"}` | YouTube search interest for a custom date range |

Shortened real output for the first row:

```json
{
  "keyword": "bitcoin",
  "geo": "EG",
  "timeRange": "today 12-m",
  "searchType": "web",
  "averageInterest": 32.32,
  "peakDate": "2026-05-03",
  "peakValue": 100,
  "latestValue": 8,
  "interestOverTime": [
    {"date": "2025-10-05", "timestamp": 1759622400, "label": "Oct 5 – 11, 2025", "value": 22, "hasData": true, "isPartial": false}
  ],
  "interestByRegion": [
    {"geoCode": "EG-JS", "geoName": "South Sinai Governorate", "value": 100}
  ],
  "relatedQueries": {
    "top": [{"query": "bitcoin price", "value": 100, "formattedValue": "100"}],
    "rising": [{"query": "bitcoin news today", "value": 484450, "formattedValue": "Breakout", "breakout": true}]
  },
  "exploreUrl": "https://trends.google.com/trends/explore?q=bitcoin&geo=EG&date=today%2012-m",
  "scrapedAt": "2026-10-07T10:45:01Z"
}
```

### Use from Python

```bash
pip install apify-client
```

```python
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("alfhar/google-trends-scraper-pro").call(run_input={
    "keywords": ["iphone", "samsung galaxy"],
    "compareKeywords": True,
    "geo": "SA",
    "timeRange": "today 3-m",
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["keyword"], item["averageInterest"], item["peakDate"])
```

A runnable example with a pandas export lives in the open-source repo: https://github.com/alf7ar/google-trends-api-python (same author as this Actor).

### pytrends alternative

[pytrends](https://github.com/GeneralMills/pytrends) is an unofficial Python wrapper for Google Trends. The repository is **archived on GitHub** (read-only, last push August 2024), so it is unmaintained and open issues will not be fixed. Google also rate limits automated Trends traffic (HTTP 429), which is the usual reason scripts that worked yesterday fail today.

If you are moving off pytrends, this Actor covers the same data:

| pytrends call | This Actor |
|---|---|
| `build_payload(kw_list, geo=, timeframe=)` | `keywords`, `geo`, `timeRange` / `customTimeRange` |
| `interest_over_time()` | `interestOverTime[]` |
| `interest_by_region()` | `interestByRegion[]` (`regionResolution`: COUNTRY, REGION, CITY, DMA) |
| `related_queries()` | `relatedQueries.top` / `relatedQueries.rising` |
| `gprop='youtube'` etc. | `searchType`: web, images, news, youtube, shopping |
| manual `time.sleep` and retry loops | handled in the Actor: direct requests first, proxy retry with a fresh IP if rate limited |

Differences to know: you pay per keyword instead of running your own code for free, results come back as JSON rows (not pandas DataFrames), and `relatedTopics` is best effort (Google often returns none to automated clients). You do not need to manage a proxy or cookie jar.

### Input fields

| Field | Meaning | Example |
|---|---|---|
| `keywords` | Search terms (one result each) | `["bitcoin", "ethereum"]` |
| `compareKeywords` | Compare up to 5 terms on one 0-100 scale | `false` |
| `geo` | Country or region code, empty = worldwide | `"EG"`, `"US-CA"` |
| `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` | `"today 12-m"` |
| `customTimeRange` | Overrides `timeRange`: `YYYY-MM-DD YYYY-MM-DD` | `"2025-01-01 2025-06-30"` |
| `category` | Google Trends category ID, `0` = all | `0` |
| `searchType` | `web`, `images`, `news`, `youtube`, `shopping` | `"web"` |
| `includeInterestOverTime` / `includeInterestByRegion` / `includeRelatedQueries` | Switch sections on or off | `true` |
| `regionResolution` | `AUTO`, `COUNTRY`, `REGION`, `CITY`, `DMA` | `"AUTO"` |
| `includeRelatedTopics` | Best effort, see limitations | `false` |
| `language` | Label language | `"en-US"` |
| `proxyConfiguration` | Used only when Google rate limits direct requests | Apify Proxy |

### Pricing

Pay per event: $0.003 per keyword that returns data and $0.005 when a run starts. Example: 100 keywords is about $0.30 plus the start fee. Set a maximum cost per run and the Actor stops at your limit. The pricing panel on this page is authoritative.

### Limitations

- Google Trends values are **relative** (0-100 within the chosen term, region and timeframe), not absolute search counts. Use compare mode to place terms on one scale.
- Google decides the timeline granularity from the timeframe and may return an empty list for very low-volume terms.
- Related topics are returned by Google only to some clients; related queries are reliable.
- The Actor reads only public Trends data, does not log in, and requests only API paths the Trends robots.txt allows. Google's terms apply to your use of the data.

### Support

Missing a field or hit a problem? Open an issue on the **Issues** tab of this Actor.

# Actor input Schema

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

Search terms or topics to look up. One result item is returned per term. Example: \["bitcoin", "ethereum"].

## `compareKeywords` (type: `boolean`):

If enabled, up to 5 terms are compared on the same 0-100 scale (like the Google Trends compare view). If disabled, every term is scaled on its own so each one peaks at 100.

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

ISO country code such as US, GB, EG, SA, AE, or a region code such as US-CA or GB-ENG. Leave empty for worldwide.

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

How far back to look. Hourly timeframes return minute or hour level points, longer ones daily, weekly or monthly points (chosen by Google).

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

Overrides the timeframe above. Format: YYYY-MM-DD YYYY-MM-DD, for example 2025-01-01 2025-06-30.

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

Google Trends category number. 0 means all categories. Examples: 7 Finance, 5 Computers & Electronics, 71 Food & Drink, 18 Shopping.

## `searchType` (type: `string`):

Which Google property to measure.

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

Include the timeline of relative search interest (0-100).

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

Include relative interest by country, region, city or metro area.

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

Level used for the interest-by-region table. Automatic lets Google choose: countries for worldwide, regions inside a country.

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

Include top and rising related search queries.

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

Try to include top and rising related topics. Google currently returns no topic data to most automated clients, so this list is often empty. Related queries are always available.

## `language` (type: `string`):

Language code used by Google Trends for labels, for example en-US, ar, de.

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

Requests first go out directly. If Google rate-limits them, the Actor retries through this proxy with a fresh IP each time. The default Apify proxy is enough for most runs.

## Actor input object example

```json
{
  "keywords": [
    "bitcoin",
    "ethereum"
  ],
  "compareKeywords": false,
  "geo": "",
  "timeRange": "today 12-m",
  "category": 0,
  "searchType": "web",
  "includeInterestOverTime": true,
  "includeInterestByRegion": true,
  "regionResolution": "AUTO",
  "includeRelatedQueries": true,
  "includeRelatedTopics": false,
  "language": "en-US",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

All scraped items in the default dataset.

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

// Run the Actor and wait for it to finish
const run = await client.actor("alfhar/google-trends-scraper-pro").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",
    ],
    "geo": "",
    "proxyConfiguration": { "useApifyProxy": True },
}

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

```

## MCP server setup

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

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/Vf4k1cexbIxd52WlY/builds/SWceEjCRbXKvNnhtR/openapi.json
