### MCP Server Setup for Google Trends Scraper Source: https://apify.com/apify/google-trends-scraper/index This JSON configuration outlines the setup for an MCP (Microservice Communication Protocol) server to interact with the 'apify/google-trends-scraper' actor. It specifies the command to run ('npx'), the remote server URL, and includes a placeholder for your API token in the Authorization header. ```json { "mcpServers": { "apify": { "command": "npx", "args": [ "mcp-remote", "https://mcp.apify.com/?tools=apify/google-trends-scraper", "--header", "Authorization: Bearer " ] } } } ``` -------------------------------- ### Install and Login to Apify CLI Source: https://apify.com/apify/google-trends-scraper/api/cli These commands install the Apify CLI globally using npm and then log in to your Apify account. You need an Apify account and API token to use the CLI for running scrapers. ```bash $npm i -g apify-cli $apify login ``` -------------------------------- ### Run Google Trends Scraper Synchronously (Get Run Information) Source: https://apify.com/apify/google-trends-scraper/index This endpoint initiates the Google Trends Scraper Actor and returns information about the created run without waiting for its completion. It requires an Apify token and accepts input parameters for scraping configuration. ```JSON { "openapi": "3.0.1", "info": { "title": "Google Trends Scraper", "description": "Scrape data from Google Trends by search terms or URLs. Specify locations, define time ranges, select categories to get interest by subregion and over time, related queries and topics, and more. Export scraped data, run the scraper via API, schedule and monitor runs, or integrate with other tools.", "version": "0.0", "x-build-id": "6DCg4iXmIzeasMXKV" }, "servers": [ { "url": "https://api.apify.com/v2" } ], "paths": { "/acts/apify~google-trends-scraper/runs": { "post": { "operationId": "runs-sync-apify-google-trends-scraper", "x-openai-isConsequential": false, "summary": "Executes an Actor and returns information about the initiated run in response.", "tags": [ "Run Actor" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/inputSchema" } } } }, "parameters": [ { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Enter your Apify token here" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/runsResponseSchema" } } } } } } } }, "components": { "schemas": { "inputSchema": { "type": "object", "properties": { "searchTerms": { "type": "array", "items": { "type": "string" }, "description": "List of search terms to scrape." }, "geo": { "type": "string", "description": "Geographic location for the search (e.g., 'US', 'GB', 'WORLD')." }, "time": { "type": "string", "description": "Time range for the search (e.g., 'today 5-y', 'today 12-m')." } } }, "runsResponseSchema": { "type": "object", "properties": { "runId": { "type": "string" }, "status": { "type": "string" } } } } } } ``` -------------------------------- ### Install Apify Client for JavaScript Source: https://apify.com/apify/google-trends-scraper/api/client/nodejs This command installs the 'apify-client' npm package, which is necessary for interacting with the Apify API in JavaScript or TypeScript projects. This client library provides convenience functions for running actors, managing datasets, and other Apify platform functionalities. ```bash $npm install apify-client ``` -------------------------------- ### Run Google Trends Scraper with API Source: https://apify.com/apify/google-trends-scraper/index This section details how to execute the Google Trends Scraper Actor using the Apify API. It includes examples for JavaScript, Python, and the command-line interface (CLI). ```APIDOC ## Run Google Trends Scraper Programmatically This section outlines how to interact with the Google Trends Scraper Actor via the Apify API. ### Method POST ### Endpoint `/v2/acts/apify/google-trends-scraper/run` ### Parameters #### Request Body - **searchTerms** (array of strings) - Required - The search terms to use for Google Trends. - **isMultiple** (boolean) - Optional - Whether to search for multiple terms (defaults to `false`). - **timeRange** (string) - Optional - The time range for the search (e.g., 'today', '7-d', '30-d'). Defaults to empty string (all time). - **geo** (string) - Optional - The geographic region for the search. Defaults to empty string (all regions). - **skipDebugScreen** (boolean) - Optional - Whether to skip the debug screen. Defaults to `false`. - **category** (string) - Optional - Filter results by category. Defaults to 'All categories'. - **maxItems** (integer) - Optional - Maximum number of items to scrape. `0` means no limit. Defaults to `0`. - **customTimeRange** (string) - Optional - A custom time range in `YYYY-MM-DD YYYY-MM-DD` format. Takes precedence over `timeRange`. - **maxConcurrency** (integer) - Optional - Maximum number of pages to open in parallel. Defaults to `10`. - **maxRequestRetries** (integer) - Optional - Maximum number of retries for failed requests. Defaults to `7`. - **pageLoadTimeoutSecs** (integer) - Optional - Timeout in seconds for page loading. Defaults to `180`. ### Request Example (JavaScript) ```javascript import { ApifyClient } from 'apify-client'; const client = new ApifyClient({ token: '' }); const input = { "searchTerms": ["webscraping"], "timeRange": "", "viewedFrom": "" }; const run = await client.actor("apify/google-trends-scraper").call(input); console.log(`Results dataset ID: ${run.defaultDatasetId}`); ``` ### Request Example (Python) ```python from apify_client import ApifyClient client = ApifyClient("") run_input = { "searchTerms": ["webscraping"], "timeRange": "", "viewedFrom": "", } run = client.actor("apify/google-trends-scraper").call(run_input=run_input) print(f"Results dataset ID: {run['defaultDatasetId']}") ``` ### Request Example (CLI) ```bash echo '{ "searchTerms": ["webscraping"], "timeRange": "", "viewedFrom": "" }' | apify call apify/google-trends-scraper --silent --output-dataset ``` ### Response #### Success Response (200) Upon successful execution, the API returns an object containing details of the Actor run, including the `defaultDatasetId` which can be used to fetch the results. - **status** (string) - The status of the run (e.g., 'SUCCEEDED'). - **defaultDatasetId** (string) - The ID of the dataset containing the scraped results. - **id** (string) - The ID of the Actor run. #### Response Example ```json { "id": "run_xxxxxxxxx", "status": "SUCCEEDED", "defaultDatasetId": "dataset_yyyyyyyyy" } ``` ### Error Handling Errors during execution will typically result in a non-200 status code and an error message in the response body. Common errors include invalid input parameters or authentication failures. ``` -------------------------------- ### Run Google Trends Scraper Actor with JavaScript API Source: https://apify.com/apify/google-trends-scraper/index This example demonstrates how to initialize the ApifyClient, prepare actor input, and run the 'apify/google-trends-scraper' actor. It then fetches and prints the results from the actor's dataset. Ensure you replace '' with your actual Apify API token. ```javascript import { ApifyClient } from 'apify-client'; // Initialize the ApifyClient with your Apify API token // Replace the '' with your token const client = new ApifyClient({ token: '', }); // Prepare Actor input const input = { "searchTerms": [ "webscraping" ], "timeRange": "", "viewedFrom": "" }; // Run the Actor and wait for it to finish const run = await client.actor("apify/google-trends-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 ``` -------------------------------- ### Install Apify Client for Python Source: https://apify.com/apify/google-trends-scraper/api/python This command installs the official Apify API client library for Python, which is necessary for programmatically interacting with Apify actors, including the Google Trends Scraper. Use this command in your Python environment to add the library. ```bash pip install apify-client ``` -------------------------------- ### Execute Google Trends Scraper and Get Dataset Items (CLI) Source: https://apify.com/apify/google-trends-scraper/api/openapi This command-line interface (CLI) example demonstrates how to run the Google Trends Scraper Actor synchronously and retrieve its dataset items directly. It uses the `apify run-sync-get-dataset-items` command, specifying the actor ID and providing the input configuration as a JSON string. ```bash apify run-sync-get-dataset-items apify~google-trends-scraper --input '{ "searchTerms": ["bitcoin", "ethereum"], "timeRange": "" , "geo": "" }' ``` -------------------------------- ### Install Apify Client for JavaScript Source: https://apify.com/apify/google-trends-scraper/api/javascript This command installs the official Apify API client library for JavaScript or TypeScript. This library provides convenient functions for interacting with Apify actors and services, including automatic retries on errors. ```bash npm install apify-client ``` -------------------------------- ### Google Trends Scraper API in Python Source: https://apify.com/apify/google-trends-scraper/api/client/python This section details how to use the Google Trends Scraper API with the official Python client. It includes installation instructions and a code example for running the scraper and processing its results. ```APIDOC ## Google Trends Scraper API in Python This API client for Python allows you to use the Google Trends Scraper programmatically. ### Installation ```bash pip install apify-client ``` ### Usage Example ```python from apify_client import ApifyClient # Initialize the ApifyClient with your Apify API token # Replace '' with your token. client = ApifyClient("") # Prepare the Actor input run_input = { "searchTerms": ["webscraping"], "timeRange": "", "viewedFrom": "", } # Run the Actor and wait for it to finish run = client.actor("apify/google-trends-scraper").call(run_input=run_input) # Fetch and print Actor results from the run's dataset (if there are any) print("πŸ’Ύ Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"]) for item in client.dataset(run["defaultDatasetId"]).iterate_items(): print(item) ``` ### Other API Access Methods * Google Trends Scraper API in JavaScript * Google Trends Scraper API through CLI * Google Trends Scraper OpenAPI definition ``` -------------------------------- ### Run Google Trends Scraper Synchronously (Get Key-value Store Output) Source: https://apify.com/apify/google-trends-scraper/index This endpoint runs the Google Trends Scraper Actor, waits for its completion, and then returns the output stored in the Key-value store. It requires an Apify token for authentication and accepts input parameters for scraping configuration. ```JSON { "openapi": "3.0.1", "info": { "title": "Google Trends Scraper", "description": "Scrape data from Google Trends by search terms or URLs. Specify locations, define time ranges, select categories to get interest by subregion and over time, related queries and topics, and more. Export scraped data, run the scraper via API, schedule and monitor runs, or integrate with other tools.", "version": "0.0", "x-build-id": "6DCg4iXmIzeasMXKV" }, "servers": [ { "url": "https://api.apify.com/v2" } ], "paths": { "/acts/apify~google-trends-scraper/run-sync": { "post": { "operationId": "run-sync-apify-google-trends-scraper", "x-openai-isConsequential": false, "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.", "tags": [ "Run Actor" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/inputSchema" } } } }, "parameters": [ { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Enter your Apify token here" } ], "responses": { "200": { "description": "OK" } } } } }, "components": { "schemas": { "inputSchema": { "type": "object", "properties": { "searchTerms": { "type": "array", "items": { "type": "string" }, "description": "List of search terms to scrape." }, "geo": { "type": "string", "description": "Geographic location for the search (e.g., 'US', 'GB', 'WORLD')." }, "time": { "type": "string", "description": "Time range for the search (e.g., 'today 5-y', 'today 12-m')." } } } } } } ``` -------------------------------- ### Run Google Trends Scraper Actor with Python API Source: https://apify.com/apify/google-trends-scraper/index This Python example shows how to initialize the ApifyClient, define actor input, and execute the 'apify/google-trends-scraper' actor. It retrieves and prints the results from the dataset associated with the run. Remember to replace '' with your valid Apify API token. ```python from apify_client import ApifyClient # Initialize the ApifyClient with your Apify API token # Replace '' with your token. client = ApifyClient("") # Prepare the Actor input run_input = { "searchTerms": ["webscraping"], "timeRange": "", "viewedFrom": "", } # Run the Actor and wait for it to finish run = client.actor("apify/google-trends-scraper").call(run_input=run_input) # Fetch and print Actor results from the run's dataset (if there are any) print("πŸ’Ύ Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"]) for item in client.dataset(run["defaultDatasetId"]).iterate_items(): print(item) # πŸ“š Want to learn more πŸ“–? Go to β†’ https://docs.apify.com/api/client/python/docs/quick-start ``` -------------------------------- ### Execute Google Trends Scraper and Get Dataset Items (CLI) Source: https://apify.com/apify/google-trends-scraper/api/openapi This command-line interface (CLI) example shows how to run the Google Trends Scraper Actor and retrieve its dataset items. It uses the `apify run` command, specifying the actor ID and providing the input as a JSON string. The `--wait-for-finish` flag ensures the command waits for the actor to complete before proceeding. ```bash apify run apify~google-trends-scraper --wait-for-finish --input '{ "searchTerms": ["apple", "banana"], "timeRange": "today 12-m", "geo": "GB" }' ``` -------------------------------- ### Google Trends Scraper Configuration Source: https://apify.com/apify/google-trends-scraper/index This section details the parameters available for configuring the Google Trends Scraper. ```APIDOC ## Google Trends Scraper API Configuration ### Description Configure the Google Trends Scraper to define input sources, filtering, and scraping behavior. ### Method POST ### Endpoint /websites/apify_apify_google-trends-scraper ### Parameters #### Request Body - **startUrls** (array) - Required - An array of Google Trends URLs to scrape. - **url** (string) - Required - The URL of a Google Trends page. - **spreadsheetId** (string) - Optional - The ID of a Google Sheet to load search terms from. The sheet must be publicly accessible and have a single column; the first row is treated as a header. - **category** (string) - Optional - Filters trends by a specific category. Defaults to 'All categories'. - Allowed values: "", "3", "47", "44", "22", "12", "5", "7", "71", "8", "45", "65", "11", "13", "958", "19", "16", "299", "14", "66", "29", "533", "174", "18", "20", "67" - **maxItems** (integer) - Optional - The maximum number of items to scrape. A value of 0 means no limit. Defaults to 0. - **customTimeRange** (string) - Optional - A custom time range for the trends in `YYYY-MM-DD YYYY-MM-DD` format. Overrides the default time range. - **maxConcurrency** (integer) - Optional - The maximum number of pages to open concurrently. Defaults to 10. - **maxRequestRetries** (integer) - Optional - The maximum number of retries for a failed request. Defaults to 7. - **pageLoadTimeoutSecs** (integer) - Optional - The timeout in seconds for page loading before retrying. Defaults to 180. ### Request Example ```json { "startUrls": [ { "url": "https://trends.google.com/trends/explore?date=today%203-m&geo=US&hl=en-US" } ], "category": "44", "customTimeRange": "2023-01-01 2023-12-31", "maxItems": 100, "maxConcurrency": 5 } ``` ### Response #### Success Response (200) - **data** (object) - Contains details of the scraping run. - **id** (string) - The unique identifier for the run. - **actId** (string) - The actor ID associated with the run. - **userId** (string) - The user ID who initiated the run. - **startedAt** (string) - The timestamp when the run started. #### Response Example ```json { "data": { "id": "run_123abc", "actId": "actor_456def", "userId": "user_789ghi", "startedAt": "2024-01-01T10:00:00Z" } } ``` ``` -------------------------------- ### Google Trends Scraper API - JavaScript Client Source: https://apify.com/apify/google-trends-scraper/api/javascript This section details how to use the Apify API client for JavaScript to interact with the Google Trends Scraper. It includes installation instructions and a code example for running the scraper. ```APIDOC ## Google Trends Scraper API - JavaScript ### Description This section details how to use the Apify API client for JavaScript to interact with the Google Trends Scraper. It includes installation instructions and a code example for running the scraper. ### Installation ```bash $ npm install apify-client ``` ### Request Example ```javascript import { ApifyClient } from 'apify-client'; // Initialize the ApifyClient with your Apify API token // Replace the '' with your token const client = new ApifyClient({ token: '', }); // Prepare Actor input const input = { "searchTerms": [ "webscraping" ], "timeRange": "", "viewedFrom": "" }; // Run the Actor and wait for it to finish const run = await client.actor("apify/google-trends-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); }); ``` ### Response Example ```json { "example": "// Output will depend on the actual scraped data from Google Trends" } ``` ``` -------------------------------- ### Google Trends Scraper API - JavaScript Client Source: https://apify.com/apify/google-trends-scraper/api/client/nodejs This section details how to use the Apify API client for JavaScript to scrape data from Google Trends. It includes installation instructions and a code example for running the scraper. ```APIDOC ## Google Trends Scraper API - JavaScript Client ### Description The Apify API client for JavaScript allows you to programmatically interact with the Google Trends Scraper. It provides convenience functions and handles retries. ### Installation ```bash npm install apify-client ``` ### Request Example ```javascript import { ApifyClient } from 'apify-client'; // Initialize the ApifyClient with your Apify API token // Replace the '' with your token const client = new ApifyClient({ token: '', }); // Prepare Actor input const input = { "searchTerms": [ "webscraping" ], "timeRange": "", "viewedFrom": "" }; // Run the Actor and wait for it to finish const run = await client.actor("apify/google-trends-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); }); ``` ### Response #### Success Response (200) - **run** (object) - Information about the initiated actor run. - **items** (array) - An array of objects, where each object represents a data record scraped from Google Trends. ``` -------------------------------- ### Run Google Trends Scraper Synchronously (Get Dataset Items) Source: https://apify.com/apify/google-trends-scraper/index This endpoint executes the Google Trends Scraper Actor, waits for its completion, and returns the scraped dataset items directly in the response. It requires an Apify token for authentication and accepts input parameters for scraping configuration. ```JSON { "openapi": "3.0.1", "info": { "title": "Google Trends Scraper", "description": "Scrape data from Google Trends by search terms or URLs. Specify locations, define time ranges, select categories to get interest by subregion and over time, related queries and topics, and more. Export scraped data, run the scraper via API, schedule and monitor runs, or integrate with other tools.", "version": "0.0", "x-build-id": "6DCg4iXmIzeasMXKV" }, "servers": [ { "url": "https://api.apify.com/v2" } ], "paths": { "/acts/apify~google-trends-scraper/run-sync-get-dataset-items": { "post": { "operationId": "run-sync-get-dataset-items-apify-google-trends-scraper", "x-openai-isConsequential": false, "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.", "tags": [ "Run Actor" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/inputSchema" } } } }, "parameters": [ { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Enter your Apify token here" } ], "responses": { "200": { "description": "OK" } } } } }, "components": { "schemas": { "inputSchema": { "type": "object", "properties": { "searchTerms": { "type": "array", "items": { "type": "string" }, "description": "List of search terms to scrape." }, "geo": { "type": "string", "description": "Geographic location for the search (e.g., 'US', 'GB', 'WORLD')." }, "time": { "type": "string", "description": "Time range for the search (e.g., 'today 5-y', 'today 12-m')." } } } } } } ``` -------------------------------- ### JavaScript Google Trends Data Extraction Example Source: https://apify.com/apify/google-trends-scraper/index Shows how to use JavaScript, likely within a Node.js environment or a browser extension, to interact with the Google Trends Scraper. This involves setting up the client and specifying the desired search parameters. ```javascript const { ApifyClient } = require('apify-client'); // Initialize the ApifyClient const client = new ApifyClient({ token: 'YOUR_APIFY_API_TOKEN', }); async function runScraper() { const runInput = { query: 'web scrape', timeRange: 'today 12-m' }; // Run the Actor and wait for it to finish const run = await client.actor('apify/google-trends-scraper').call(runInput); // Fetch and print the results from the Actor's default dataset const datasetItems = await client.dataset(run.defaultDatasetId).getItems(); console.log(datasetItems); } ``` -------------------------------- ### Google Trends Scraper Configuration Source: https://apify.com/apify/google-trends-scraper/index This section details the parameters available for configuring the Google Trends scraper, including country selection and debug screen options. ```APIDOC ## Google Trends Scraper Configuration ### Description Configuration options for the Google Trends scraper. ### Parameters #### Request Body - **countries** (array of strings) - Required - A list of country codes for which to fetch Google Trends data. Example: `["us", "gb", "fr"] - **skipDebugScreen** (boolean) - Optional - If true, the scraper will not save a snapshot of each visited Google Trends page. Defaults to `false`. ``` -------------------------------- ### Run Google Trends Scraper Actor with CLI Source: https://apify.com/apify/google-trends-scraper/index This command-line interface example shows how to run the 'apify/google-trends-scraper' actor using the 'apify call' command. It pipes a JSON input object containing search terms, time range, and viewedFrom parameters to the actor. The '--silent' flag suppresses output, and '--output-dataset' saves results to a dataset. ```bash echo '{ "searchTerms": [ "webscraping" ], "timeRange": "", "viewedFrom": "" }' | apify call apify/google-trends-scraper --silent --output-dataset ``` -------------------------------- ### Google Trends Scraper API - Python Client Source: https://apify.com/apify/google-trends-scraper/api/python This section details how to use the Google Trends Scraper programmatically using the official Apify API client for Python. It includes installation instructions and a code example for running the scraper. ```APIDOC ## Google Trends Scraper API in Python The Apify API client for Python is the official library that allows you to use Google Trends Scraper API in Python, providing convenience functions and automatic retries on errors. ### Installation ```bash pip install apify-client ``` ### Request Example ```python from apify_client import ApifyClient # Initialize the ApifyClient with your Apify API token # Replace '' with your token. client = ApifyClient("") # Prepare the Actor input run_input = { "searchTerms": ["webscraping"], "timeRange": "", "viewedFrom": "", } # Run the Actor and wait for it to finish run = client.actor("apify/google-trends-scraper").call(run_input=run_input) # Fetch and print Actor results from the run's dataset (if there are any) print("πŸ’Ύ Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"]) for item in client.dataset(run["defaultDatasetId"]).iterate_items(): print(item) ``` ### Response Example (The response will contain the data scraped from Google Trends, typically in JSON format. The exact structure depends on the scraper's output.) ```json { "example": "response body" } ``` ``` -------------------------------- ### Python Google Trends Data Extraction Example Source: https://apify.com/apify/google-trends-scraper/index Demonstrates how to use a Python library or tool to fetch Google Trends data. This snippet would typically involve defining search queries and date ranges as inputs and processing the returned data. ```python from apify_client import ApifyClient # Initialize the ApifyClient client = ApifyClient("YOUR_APIFY_API_TOKEN") # Prepare the Actor input run_input = { "query": "python selenium web scraping", "timeRange": "today 12-m" } # Run the Actor and wait for it to finish run = client.actor("apify/google-trends-scraper").call(run_input=run_input) # Fetch and print the results from the Actor's default dataset for item in client.dataset(run["defaultDatasetId"]).iterate_items(): print(item) ``` -------------------------------- ### Accessing Apify API with Node.js Client Source: https://apify.com/apify/google-trends-scraper/index This code snippet demonstrates how to use the `apify-client` NPM package to interact with the Apify API, allowing programmatic access to manage and run Actors like the Google Trends Scraper. ```javascript const { ApifyClient } = require('apify-client'); async function runScraper() { const client = new ApifyClient({ token: 'YOUR_APIFY_API_TOKEN', }); const run = await client.actor('apify/google-trends-scraper').call({ searchTerms: ['apple', 'banana'], timeRange: '6 months ago', }); console.log('Actor run started:', run.id); // You can then fetch the results using client.dataset(run.defaultDatasetId).get(); } ``` -------------------------------- ### POST /acts/apify~google-trends-scraper/runs Source: https://apify.com/apify/google-trends-scraper/index Initiates an execution of the Google Trends Scraper Actor and returns information about the newly created run. This endpoint is suitable for asynchronous operations or when you need to manage runs independently. ```APIDOC ## POST /acts/apify~google-trends-scraper/runs ### Description Executes an Actor and returns information about the initiated run in response. ### Method POST ### Endpoint https://api.apify.com/v2/acts/apify~google-trends-scraper/runs ### Parameters #### Query Parameters - **token** (string) - Required - Enter your Apify token here #### Request Body - **(schema: #/components/schemas/inputSchema)** - Required - The input schema for the Google Trends Scraper. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **(schema: #/components/schemas/runsResponseSchema)** - OK #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Google Trends Scraper Parameters Source: https://apify.com/apify/google-trends-scraper/index This section details the parameters available for configuring the Google Trends scraper, including geographic area and viewing country. ```APIDOC ## GET / Or POST / (Conceptual Endpoint for Scraping) ### Description This conceptual endpoint represents the functionality to scrape Google Trends data. It allows for detailed configuration of the scraping process, particularly focusing on geographical relevance and the origin country for trend analysis. ### Method GET or POST (depending on implementation, often POST for complex configurations) ### Endpoint `/search` or a similar endpoint for data retrieval ### Parameters #### Query Parameters (for GET) or Request Body Fields (for POST) - **geo** (string) - Optional - Specifies the geographic area to retrieve results from. Defaults to 'Worldwide'. This parameter influences the type of regional interest data returned (e.g., 'interestByCity', 'interestBySubregion'). If a Google Trends URL is provided, the 'geo' parameter from the URL takes precedence. 'Worldwide' returns 'interestBy' data. - **viewedFrom** (string) - Optional - Specifies the country from which to view the trends. This parameter accepts ISO 3166-1 alpha-2 country codes. Defaults to an empty string or 'Worldwide' depending on the implementation. ### Request Example ```json { "geo": "US", "viewedFrom": "US" } ``` ### Response #### Success Response (200) - **interestByCity** (object) - Data for interest by city within the specified geo area. - **interestBySubregion** (object) - Data for interest by subregion within the specified geo area. - **interestBy** (object) - Data for overall interest by area when 'geo' is 'Worldwide'. #### Response Example ```json { "interestByCity": { "New York": 85, "Los Angeles": 70 }, "interestBySubregion": { "California": 90, "Texas": 65 } } ``` ``` -------------------------------- ### Google Trends Scraper Input Example Source: https://apify.com/apify/google-trends-scraper/issues/error--no-value-c9EiccgktHRwdHf3E This is an example of the input format for the Google Trends Scraper. It shows how to specify a search term and the expected structure of the output for 'interestOverTime_timelineData', 'interestOverTime_averages', 'interestBySubregion', and 'interestByCity'. An empty array indicates no data was retrieved for that specific metric. ```json [{ "inputUrlOrTerm": "fenetre", "searchTerm": "fenetre", "interestOverTime_timelineData": [], "interestOverTime_averages": [], "interestBySubregion": [], "interestByCity": [] }] ``` -------------------------------- ### Accessing Apify API with Python Client Source: https://apify.com/apify/google-trends-scraper/index This code snippet shows how to utilize the `apify-client` PyPI package in Python to programmatically access the Apify API, enabling control over Actors and data retrieval. ```python from apify_client import ApifyClient def run_scraper(): client = ApifyClient("YOUR_APIFY_API_TOKEN") run = client.actor("apify/google-trends-scraper").call( { "searchTerms": ["orange", "grape"], "timeRange": "12 months ago", } ) print(f"Actor run started: {run['id']}") # You can then fetch the results using client.dataset(run['defaultDatasetId']).get() ``` -------------------------------- ### POST /acts/apify~google-trends-scraper/run-sync Source: https://apify.com/apify/google-trends-scraper/index Executes the Google Trends Scraper Actor, waits for its completion, and returns the output stored in the Key-value store. This is useful when the scraper's output is expected to be in a structured format within the key-value store. ```APIDOC ## POST /acts/apify~google-trends-scraper/run-sync ### Description Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response. ### Method POST ### Endpoint https://api.apify.com/v2/acts/apify~google-trends-scraper/run-sync ### Parameters #### Query Parameters - **token** (string) - Required - Enter your Apify token here #### Request Body - **(schema: #/components/schemas/inputSchema)** - Required - The input schema for the Google Trends Scraper. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **(description: OK)** #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Google Trends Data Output Example (JSON) Source: https://apify.com/apify/google-trends-scraper/index This snippet shows the structure of the Google Trends data scraped by the Apify tool, presented in JSON format. It includes fields like search terms, interest over time with timestamps and values, and related topics with their scores and links. The data is organized to provide insights into search trends. ```json { "inputUrlOrTerm": "web scraping", "searchTerm": "web scraping", "interestOverTime_timelineData": [ { "time": "1673136000", "formattedTime": "Jan 8 – 14, 2023", "formattedAxisTime": "Jan 8, 2023", "value": [ 99 ], "hasData": [ true ], "formattedValue": [ "99" ] }, { "time": "1673740800", "formattedTime": "Jan 15 – 21, 2023", "formattedAxisTime": "Jan 15, 2023", "value": [ 96 ], "hasData": [ true ], "formattedValue": [ "96" ] }, { "time": "1674345600", "formattedTime": "Jan 22 – 28, 2023", "formattedAxisTime": "Jan 22, 2023", "value": [ 99 ], "hasData": [ true ], "formattedValue": [ "99" ] }, { "time": "1674950400", "formattedTime": "Jan 29 – Feb 4, 2023", "formattedAxisTime": "Jan 29, 2023", "value": [ 98 ], "hasData": [ true ], "formattedValue": [ "98" ] }, { "time": "1675555200", "formattedTime": "Feb 5 – 11, 2023", "formattedAxisTime": "Feb 5, 2023", "value": [ 100 ], "hasData": [ true ], "formattedValue": [ "100" ] }, { "time": "1676160000", "formattedTime": "Feb 12 – 18, 2023", "formattedAxisTime": "Feb 12, 2023", "value": [ 91 ], "hasData": [ true ], "formattedValue": [ "91" ] }, { "time": "1676764800", "formattedTime": "Feb 19 – 25, 2023", "formattedAxisTime": "Feb 19, 2023", "value": [ 98 ], "hasData": [ true ], "formattedValue": [ "98" ] }, { "time": "1703376000", "formattedTime": "Dec 24 – 30, 2023", "formattedAxisTime": "Dec 24, 2023", "value": [ 80 ], "hasData": [ true ], "formattedValue": [ "80" ] }, { "time": "1703980800", "formattedTime": "Dec 31, 2023 – Jan 6, 2024", "formattedAxisTime": "Dec 31, 2023", "value": [ 81 ], "hasData": [ true ], "formattedValue": [ "81" ] }, { "time": "1704585600", "formattedTime": "Jan 7 – 13, 2024", "formattedAxisTime": "Jan 7, 2024", "value": [ 91 ], "hasData": [ true ], "formattedValue": [ "91" ], "isPartial": true } ], "interestOverTime_averages": [], "interestBySubregion": [], "interestByCity": [], "relatedTopics_top": [ { "topic": { "mid": "/m/07ykbs", "title": "Web scraping", "type": "Topic" }, "value": 100, "formattedValue": "100", "hasData": true, "link": "/trends/explore?q=/m/07ykbs&date=today+12-m" }, { "topic": { "mid": "/m/0828v", "title": "World Wide Web", "type": "Topic" }, "value": 97, "formattedValue": "97", "hasData": true, "link": "/trends/explore?q=/m/0828v&date=today+12-m" }, { "topic": { "mid": "/m/05z1_", "title": "Python", "type": "Programming language" }, "value": 29, "formattedValue": "29", "hasData": true, "link": "/trends/explore?q=/m/05z1_&date=today+12-m" }, { "topic": { "mid": "/m/026sq", "title": "Data", "type": "Topic" }, "value": 14, "formattedValue": "14", "hasData": true, "link": "/trends/explore?q=/m/026sq&date=today+12-m" }, { "topic": { "mid": "/m/085n4", "title": "Website", "type": "Topic" }, "value": 9, "formattedValue": "9", "hasData": true, "link": "/trends/explore?q=/m/085n4&date=today+12-m" }, { "topic": { "mid": "/m/0c828v", "title": "Selenium", "type": "Software" }, "value": 5, "formattedValue": "5", "hasData": true, "link": "/trends/explore?q=/m/0c828v&date=today+12-m" }, { "topic": { "mid": "/m/0z5n", "title": "Application programming interface", "type": "Type of software" }, "value": 5 } ] } ```