# Google Trends Scraper: Interest, Related & Trending Now (`egra_van/google-trends-reliable`) Actor

Google Trends data without pytrends 429 errors: interest over time for up to 5 terms (or hundreds on one scale via an anchor term), interest by country, region or city, top and rising related queries and topics, and Trending Now searches with traffic and news.

- **URL**: https://apify.com/egra\_van/google-trends-reliable.md
- **Developed by:** [Argentin Vazdautan](https://apify.com/egra_van) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.40 / 1,000 search term trend data

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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: Interest, Related & Trending Now

Get **Google Trends data as clean JSON or spreadsheet rows**, without running pytrends yourself and fighting "429 Too Many Requests":

- **Interest over time** for up to **5 terms compared together** on one 0-100 scale, exactly like trends.google.com
- **Hundreds of terms** in one run: automatic batching into groups of 5, with an optional **anchor term** that puts every group on **one comparable scale**
- **Interest by region**: countries, states/regions, cities (with latitude/longitude) or US metro areas (DMA)
- **Related queries** and **related topics**, top and rising (with "+250%" and "Breakout")
- **Trending Now**: the searches trending today in any country, with approximate search volume and news articles
- Any **location, time range** (past hour to 2004-present, or custom dates), **category** and **Google property** (Web, Images, News, Shopping, YouTube)

Built for SEO and content teams, market researchers, e-commerce and product managers, analysts, and **AI agents** that need search-demand data on demand.

### Why this scraper

- **Made for reliability.** Google Trends rate-limits hard. Every request is paced (1.5 s default), and a refused request (HTTP 429, captcha, network error) is retried with exponential backoff and a **new session: new proxy IP and new Google cookies**. If Google's explore endpoint stays blocked, chart tokens come from Google's **embeddable widget pages** instead, and as a last resort a **real Chrome browser** takes over.
- **You don't pay for failures.** A term is charged only when **all the data you asked for** was collected. Incomplete terms are stored for free with the reason in `errors`.
- **Clean outputs.** One item per term with `timeline`, `averageInterest`, `peakDate`, `latestValue`, `topRegion`, related lists, and a link to the same chart on Google Trends. Or switch on **flat rows** for Excel / Google Sheets / BI tools.
- **Transparent.** Each request is logged with its HTTP status, time, whether a consent or captcha page was detected, and which parser read the data. Unexpected responses are saved to the key-value store (`DEBUG-…`). The run summary (`OUTPUT`) lists every term's status and request statistics.

### Quick start

Compare two terms in the US over the past 12 months, plus today's US Trending Now searches:

```json
{
  "searchTerms": ["coffee", "tea"],
  "geo": "US",
  "timeRange": "today 12-m",
  "trendingNow": true,
  "maxTrendingItems": 10
}
```

All inputs, including related queries, regions and more:

```json
{
  "searchTerms": ["iphone", "samsung galaxy", "google pixel"],
  "geo": "GB",
  "timeRange": "custom",
  "customTimeRange": "2025-01-01 2025-12-31",
  "category": "5",
  "gprop": "",
  "interestOverTime": true,
  "interestByRegion": true,
  "regionResolution": "REGION",
  "relatedQueries": true,
  "relatedTopics": true,
  "maxRelatedItems": 10
}
```

#### Many terms on one scale (anchor term)

Google compares at most 5 terms at a time, and every comparison is scaled to its own top term (= 100). So "40" in one group and "40" in another are not the same thing. With `anchorTerm`, each group is built as **anchor + 4 of your terms**; the Actor uses the anchor to rescale all groups onto one scale and adds `comparableValue` (per point) and `comparableAverage` (per term), where 100 is the highest point of **all** terms.

```json
{
  "searchTerms": ["asana", "trello", "notion", "clickup", "monday.com", "jira", "basecamp", "todoist", "airtable"],
  "anchorTerm": "slack",
  "geo": "US",
  "timeRange": "today 5-y"
}
```

Pick an anchor that is stable and roughly as popular as your terms. If the anchor averages below 10 in a group, the log warns you: Google rounds to whole numbers, so tiny anchors make the rescaling imprecise. Without an anchor, more than 5 terms are simply split into groups of 5 (not comparable between groups), and `comparisonMode: "separate"` gives every term its own 0-100 scale.

### Python: drop-in pytrends replacement

Tired of `429 Too Many Requests` in pytrends? The free, MIT-licensed [pytrends-alternative](https://github.com/Egrarobo/pytrends-alternative) library keeps the pytrends interface (`TrendReq`, `build_payload`, `interest_over_time`, `interest_by_region`, `related_queries`, `trending_searches`) and runs the requests through this Actor:

```python
from gtrends_api import TrendReq   # was: from pytrends.request import TrendReq
pytrends = TrendReq()              # uses your APIFY_TOKEN
pytrends.build_payload(["coffee", "tea"], timeframe="today 12-m", geo="US")
df = pytrends.interest_over_time()
```

### Output

#### One item per term

```json
{
  "type": "term",
  "term": "coffee",
  "isAnchor": false,
  "groupId": 1,
  "comparedWith": ["tea"],
  "geo": "US",
  "timeRange": "today 12-m",
  "timeRangeResolved": "2025-09-27 2026-09-27",
  "resolution": "WEEK",
  "category": 0,
  "categoryName": "All categories",
  "gprop": "web",
  "gpropName": "Web Search",
  "language": "en-US",
  "status": "ok",
  "timeline": [
    { "date": "2025-09-28", "timestamp": 1759017600, "value": 81, "hasData": true, "isPartial": false, "formattedTime": "Sep 28 – Oct 4, 2025" },
    { "date": "2026-09-20", "timestamp": 1789862400, "value": 77, "hasData": true, "isPartial": true, "formattedTime": "Sep 20 – 26, 2026" }
  ],
  "averageInterest": 77.08,
  "peakValue": 100,
  "peakDate": "2025-12-21",
  "latestValue": 77,
  "latestDate": "2026-09-20",
  "googleAverage": 77,
  "timelinePoints": 53,
  "regionResolution": "REGION",
  "regions": [{ "geoCode": "US-CA", "geoName": "California", "value": 100, "formattedValue": "100", "hasData": true }],
  "topRegion": "California",
  "relatedQueriesTop": [{ "rank": 1, "query": "coffee near me", "value": 100, "formattedValue": "100", "link": "https://trends.google.com/trends/explore?q=coffee+near+me&date=today+12-m&geo=US" }],
  "relatedQueriesRising": [{ "rank": 1, "query": "coffee tariffs", "value": 5000, "formattedValue": "Breakout", "isBreakout": true, "link": "https://trends.google.com/trends/explore?q=coffee+tariffs&date=today+12-m&geo=US" }],
  "relatedTopicsTop": [{ "rank": 1, "topicId": "/m/02vqfm", "title": "Coffee", "topicType": "Beverage", "value": 100, "formattedValue": "100", "link": "https://trends.google.com/trends/explore?q=/m/02vqfm&date=today+12-m&geo=US" }],
  "relatedTopicsRising": [],
  "exploreUrl": "https://trends.google.com/trends/explore?date=today+12-m&geo=US&q=coffee%2Ctea&hl=en-US",
  "dataSource": "explore/http",
  "scrapedAt": "2026-09-27T12:00:00.000Z"
}
```

(Values above are illustrative.) Notes:

- **Values are relative (0-100), not search counts.** 100 is the peak of the most popular term in the comparison for the chosen place and time; 0 means too little data. This is how Google Trends works.
- `isPartial: true` marks the last, still-incomplete period. `averageInterest` ignores it.
- Dates are UTC: `YYYY-MM-DD` for daily, weekly and monthly data, full ISO time for hourly and minute data (time ranges up to 7 days).
- `status` is `ok` (everything requested was collected, charged), `partial` or `failed` (stored for free, with `errors`).
- With `anchorTerm`: `comparableValue` in every timeline point and `comparableAverage` per term.
- Fields for data you did not request are omitted; data that failed is `null`.

#### Trending Now items

```json
{
  "type": "trending",
  "rank": 1,
  "title": "world series",
  "approxTraffic": "500K+",
  "approxTrafficMin": 500000,
  "startedAt": "2026-09-27T07:10:00.000Z",
  "newsCount": 3,
  "newsTitle": "Game 7 goes to extra innings",
  "newsUrl": "https://…",
  "newsSource": "ESPN",
  "news": [{ "title": "…", "url": "…", "source": "ESPN", "picture": "…", "snippet": null }],
  "picture": "https://…",
  "pictureSource": "ESPN",
  "geo": "US",
  "source": "rss",
  "exploreUrl": "https://trends.google.com/trends/explore?q=world+series&date=now+1-d&geo=US"
}
```

Two sources:

- **`rss`** (default): Google's official Trending Now RSS feed. Most reliable; the top trending searches with approximate traffic, start time, picture and news.
- **`trendingPage`**: the data behind trends.google.com/trending, for the past 4, 24, 48 hours or 7 days. More searches, plus `increasePercent`, `endedAt`, `isActive`, `categories` and `relatedQueries`. News is added from the RSS feed where the titles match. If this source fails, the Actor falls back to RSS.

Trending Now runs **before** the search terms (it is a single request).

#### Flat rows for spreadsheets

With `"flattenTimeline": true` each term becomes several rows with a `rowType` column:

| rowType | Columns |
|---|---|
| `term` | term, status, averageInterest, comparableAverage, peakDate, topRegion, comparedWith, errors, exploreUrl |
| `timeline` | term, date, value, comparableValue, isPartial, hasData |
| `region` | term, regionCode, regionName, value, lat, lng |
| `relatedQuery` | term, list (top/rising), rank, query, value, formattedValue, isBreakout |
| `relatedTopic` | term, list, rank, topicId, title, topicType, value, formattedValue, isBreakout |

Filter by `rowType` in Excel or Google Sheets, or pivot `timeline` rows (term × date). Price is the same: per term.

#### Dataset views and run summary

The dataset has views **Terms overview**, **Interest over time**, **Interest by region**, **Related queries & topics**, **Trending now** and **Flat rows**. The key-value store record `OUTPUT` holds the run summary: status and errors per term, groups, anchor scale factors, trending status and request statistics (requests, retries, 429s, captcha and consent pages, sessions, browser use).

### Pricing

Pay per event, platform usage included:

| Event | When | Price |
|---|---|---|
| `term-result` | one search term with **all** the data you requested (timeline, regions, related queries/topics) | $0.004 |
| `trending-item` | one Trending Now search stored | $0.001 |

Terms that fail or come back incomplete are not charged. The anchor term is charged once. The Actor checks your **maximum cost per run** before each group and never fetches data it cannot charge for: if the limit allows only 3 more terms, the next comparison contains only 3 terms.

Examples: 5 terms with everything = $0.02. 500 keywords with an anchor = about $2.00. Trending Now top 20 = $0.02.

### Tips for reliable runs

- **Proxy.** The default Apify datacenter proxy works for small runs; every retry uses a new IP. Google Trends limits requests per IP, so for hundreds of terms, daily schedules or many parallel runs use the **RESIDENTIAL** proxy group. Do not use `GOOGLE_SERP`: that proxy only serves Google Search pages.
- **Go slow.** Keep `maxConcurrency` at 1 and `requestDelayMs` at 1500+ unless you use residential proxies. Related queries/topics are the most rate-limited parts: ask for them only when you need them.
- **Related topics** with several terms cost one extra request per term (Google only returns them for single-term charts).
- **Topics instead of words.** A Knowledge Graph topic id such as `/m/0663v` (Pizza, the food) can be used as a search term; it covers all spellings and languages of the topic.
- **Scheduling.** Run it daily with the same input to build your own history; Google Trends data for short ranges changes slightly between requests (sampling).

### For AI agents and developers

Run synchronously and get the items in one HTTP call:

```bash
curl -X POST "https://api.apify.com/v2/acts/<username>~google-trends/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"searchTerms":["claude","chatgpt","gemini"],"geo":"US","timeRange":"today 3-m","relatedQueries":true}'
```

- Input is plain JSON; every field is optional except `searchTerms` or `trendingNow`. `timeRange` also accepts any Google Trends time string directly (`"today 2-y"`, `"now 3-d"`, `"2025-01-01 2025-06-30"`).
- Every item has `type` (`term` or `trending`; `rowType` in flat mode) and `status`, so agents can tell complete, partial and failed data apart without reading logs.
- Values are relative. To answer "which is more popular", compare `averageInterest` within one group, or `comparableAverage` across groups when an anchor is set.
- The Actor can be used as a tool through the Apify MCP server (`mcp.apify.com`).

### Input reference

| Field | Default | Description |
|---|---|---|
| `searchTerms` | – | Terms to compare (up to 5 per group, any number in total) |
| `comparisonMode` | `groups` | `groups` or `separate` |
| `anchorTerm` | – | Common term added to every group to make groups comparable |
| `geo` | worldwide | `US`, `GB`, `US-CA`, … |
| `timeRange` | `today 12-m` | Preset or `custom` |
| `customTimeRange` | – | `2025-01-01 2025-06-30`, `2026-09-20T00 2026-09-26T23`, `today 2-y`, `now 3-d` |
| `category` / `categoryId` | 0 (all) | Google Trends category |
| `gprop` | web | `images`, `news`, `froogle` (Shopping), `youtube` |
| `language` | `en-US` | Interface language (`hl`) |
| `timezoneOffset` | 0 | Google's `tz`, minutes behind UTC |
| `interestOverTime` | true | Timeline |
| `interestByRegion` | false | Regions; `regionResolution`: auto, COUNTRY, REGION, CITY, DMA; `includeLowSearchVolumeRegions` |
| `relatedQueries` / `relatedTopics` | false | Top and rising lists; `maxRelatedItems` (25) |
| `flattenTimeline` | false | Flat rows for spreadsheets |
| `trendingNow` | false | Trending Now searches; `trendingGeo`, `trendingSource` (`rss`/`trendingPage`), `trendingHours`, `maxTrendingItems`, `includeNews` |
| `proxyConfiguration` | Apify Proxy | See tips above |
| `useBrowser` | `fallback` | `fallback`, `always`, `never` |
| `useEmbedFallback` | true | Use embeddable widget pages when explore is rate-limited |
| `maxRetries` | 5 | Retries per request (new session each time) |
| `maxConcurrency` | 1 | Parallel comparison groups |
| `requestDelayMs` | 1500 | Pause between requests |

### Limitations

- Google Trends has no public API for this data (the official Trends API launched in 2025 is an alpha with limited access), so this Actor reads the same internal endpoints the Google Trends website uses. Google can change them without notice; the Actor logs which step failed and saves the response for diagnosis.
- Heavy use from shared datacenter IPs can be rate-limited by Google for a while. Retries with new IPs, the embed and browser fallbacks cover most cases, but very large runs need residential proxies.
- Values are relative and sampled by Google, not absolute search volumes.

### Legal

This Actor collects publicly available, aggregated and anonymized statistics. It does not collect personal data. You are responsible for using the data in line with Google's Terms of Service and the laws that apply to you.

# Actor input Schema

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

Words or phrases to look up, one per line, e.g. "coffee", "iphone 17". Up to 5 terms are compared together on one 0-100 scale, exactly like on trends.google.com. More terms are split automatically into groups of 5 (see "Anchor term" to keep them comparable). A Google Knowledge Graph topic ID such as "/m/0663v" (Pizza, the topic) also works. Leave empty if you only want Trending Now.

## `comparisonMode` (type: `string`):

"groups": terms are compared together in groups of up to 5 (values are relative to the most popular term of the group). "separate": every term is looked up alone and gets its own 0-100 scale (100 = that term's own peak).

## `anchorTerm` (type: `string`):

Optional. When you have more than 5 terms, this term is added to every group of 4 other terms. The Actor then rescales all groups onto one scale and adds "comparableValue" / "comparableAverage" (0-100 across ALL terms). Pick a stable term roughly as popular as your terms, e.g. "weather" or a well-known brand in your market. The anchor is returned (and charged) once as a normal term.

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

Country or region code as used by Google Trends: "US", "GB", "DE", "IN", a US state like "US-CA", or a region like "GB-ENG". Leave empty for worldwide.

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

Period to analyse. Short ranges give hourly or minute points (past hour: 1 minute, past day: 8 minutes, past 7 days: 1 hour); up to 9 months daily; up to 5 years weekly; longer monthly. Choose "Custom" to use "Custom time range".

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

Used when "Time range" is "Custom". Formats: "2025-01-01 2025-06-30" (dates, from 2004-01-01), "2026-09-20T00 2026-09-26T23" (hourly, at most 7 days, UTC), "today 2-y" (last 2 years) or "now 3-d" (last 3 days).

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

Limit the search interest to one Google Trends category, e.g. "jaguar" in Autos & Vehicles vs Pets & Animals. Use "Category ID" for sub-categories.

## `categoryId` (type: `integer`):

Any Google Trends category number, including sub-categories. Overrides "Category". Find it in the "cat=" part of a trends.google.com/trends/explore link after picking the category there.

## `gprop` (type: `string`):

Which Google search to measure: web search (default), image search, news search, Google Shopping or YouTube search.

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

Google Trends interface language (hl), e.g. "en-US", "de", "fr", "pt-BR". Affects names of regions and topics and the Trending Now data, not which searches are counted.

## `timezoneOffset` (type: `integer`):

Google's "tz" parameter: minutes BEHIND UTC, like JavaScript getTimezoneOffset(). 0 = UTC (default), 300 = US Eastern standard time (UTC-5), -120 = UTC+2. Mainly affects hourly data. Dates in the output are always UTC.

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

Timeline of search interest (0-100) for every term: \[{date, value, isPartial}], plus average, peak and latest value.

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

Where each term is most popular (0-100 per country, state, city or US metro area). Adds "regions" and "topRegion" to every term.

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

Level of detail for interest by region. Auto = countries when Location is worldwide, otherwise sub-regions (states/provinces). CITY returns city names with latitude/longitude. DMA (metro areas) exists only for the US.

## `includeLowSearchVolumeRegions` (type: `boolean`):

Also list regions with little search volume (Google's "Include low search volume regions" checkbox).

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

Top and rising searches related to each term (rising ones show growth like "+250%" or "Breakout").

## `relatedTopics` (type: `boolean`):

Top and rising topics (entities such as brands, people, places) related to each term. With several terms this needs one extra request per term.

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

Keep at most this many items in each related queries/topics list (Google returns up to 25). 0 = keep all.

## `flattenTimeline` (type: `boolean`):

Instead of one item per term with nested arrays, store one row per term + date (rowType "timeline"), plus rows for regions ("region"), related queries ("relatedQuery") and topics ("relatedTopic") and one summary row per term ("term"). Best for Excel, Google Sheets and BI tools. Pricing is the same.

## `trendingNow` (type: `boolean`):

Also store the searches that are trending right now in a country (Google Trends "Trending now"), with approximate search volume and news articles. Charged per trending search stored. Works without search terms.

## `trendingGeo` (type: `string`):

Country code for Trending Now, e.g. "US", "GB", "DE", "IN", "BR". Empty = the country of "Location", or US when Location is worldwide.

## `trendingSource` (type: `string`):

"rss": Google's official Trending Now RSS feed (most reliable; top searches with approximate traffic, start time, picture and news articles). "trendingPage": the data behind trends.google.com/trending (more searches, exact start/end time, active flag, growth %, categories, related queries; news added from the RSS feed where available). Falls back to RSS if it fails.

## `trendingHours` (type: `string`):

Only for the "trendingPage" source: searches that started trending in the past 4 hours, 24 hours, 48 hours or 7 days.

## `maxTrendingItems` (type: `integer`):

Store at most this many trending searches (in Google's order).

## `includeNews` (type: `boolean`):

Add the news articles Google links to each trending search (title, URL, source, picture).

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

Google Trends rate-limits IP addresses (HTTP 429). The default Apify datacenter proxy works for small runs; each retry uses a new IP. For large or frequent runs use the RESIDENTIAL group (paid Apify plans). Do not use GOOGLE\_SERP: it only serves Google Search pages.

## `useBrowser` (type: `string`):

"fallback": fast HTTP requests with a Chrome fingerprint first; if Google keeps refusing them, switch to a real Chrome browser for the rest of the run. "always": use the browser from the start (slower, more memory). "never": HTTP only.

## `useEmbedFallback` (type: `boolean`):

If Google's explore endpoint is rate-limited, get the chart tokens from Google Trends' embeddable widget pages instead (one request per chart). Recommended.

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

How many times a rate-limited (429) or failed request is retried, each time after an exponential backoff (about 2, 4, 8, 16, 30 s) and with a new session: new proxy IP and new Google cookies.

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

How many comparison groups are fetched at the same time. Keep 1 unless you use residential proxies: Google Trends punishes parallel requests with 429 errors.

## `requestDelayMs` (type: `integer`):

Minimum pause between two requests to Google (with random jitter). Higher = fewer 429 errors, slower runs.

## `requestTimeoutSecs` (type: `integer`):

Timeout for one request to Google.

## `saveDebugPages` (type: `boolean`):

When Google returns something unexpected (429 page, captcha, consent page, bad data), save up to 5 of those responses to the key-value store (keys DEBUG-...) for inspection.

## `baseUrl` (type: `string`):

For testing only: send all requests to this address instead of https://trends.google.com (e.g. a local mock server). Leave empty.

## Actor input object example

```json
{
  "searchTerms": [
    "coffee",
    "tea"
  ],
  "comparisonMode": "groups",
  "geo": "US",
  "timeRange": "today 12-m",
  "category": "0",
  "gprop": "",
  "language": "en-US",
  "timezoneOffset": 0,
  "interestOverTime": true,
  "interestByRegion": false,
  "regionResolution": "",
  "includeLowSearchVolumeRegions": false,
  "relatedQueries": false,
  "relatedTopics": false,
  "maxRelatedItems": 25,
  "flattenTimeline": false,
  "trendingNow": true,
  "trendingSource": "rss",
  "trendingHours": "24",
  "maxTrendingItems": 10,
  "includeNews": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "useBrowser": "fallback",
  "useEmbedFallback": true,
  "maxRetries": 5,
  "maxConcurrency": 1,
  "requestDelayMs": 1500,
  "requestTimeoutSecs": 30,
  "saveDebugPages": true
}
```

# Actor output Schema

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

All result items of this run.

## `trending` (type: `string`):

Trending Now searches stored in this run (when enabled).

## `summary` (type: `string`):

Summary of the run with per-term status, anchor scaling and request statistics.

# 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": [
        "coffee",
        "tea"
    ],
    "geo": "US",
    "trendingNow": true,
    "maxTrendingItems": 10,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("egra_van/google-trends-reliable").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": [
        "coffee",
        "tea",
    ],
    "geo": "US",
    "trendingNow": True,
    "maxTrendingItems": 10,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("egra_van/google-trends-reliable").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": [
    "coffee",
    "tea"
  ],
  "geo": "US",
  "trendingNow": true,
  "maxTrendingItems": 10,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call egra_van/google-trends-reliable --silent --output-dataset

```

## MCP server setup

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

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/oFvR4a6uCU2XPWD8w/builds/abcbc4HOAhpPbGbaa/openapi.json
