{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Trends Scraper — cached, no timeouts",
    "description": "Interest over time, by region, related queries and Trending now. Built for the one thing that breaks Trends scrapers: rate limits. Caches every result, paces itself, and rotates IP instead of sleeping — so runs finish.",
    "version": "0.1",
    "x-build-id": "faL3G62lAbCMTiFgL"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/leonguyen2808~google-trends-cached/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-leonguyen2808-google-trends-cached",
        "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"
          }
        }
      }
    },
    "/acts/leonguyen2808~google-trends-cached/runs": {
      "post": {
        "operationId": "runs-sync-leonguyen2808-google-trends-cached",
        "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"
                }
              }
            }
          }
        }
      }
    },
    "/acts/leonguyen2808~google-trends-cached/run-sync": {
      "post": {
        "operationId": "run-sync-leonguyen2808-google-trends-cached",
        "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": {
          "keywords": {
            "title": "Search terms",
            "type": "array",
            "description": "Terms to look up INDEPENDENTLY, one per line. Values are scaled 0-100 within each term's own request, so they are NOT comparable across terms — use `compareKeywords` for that.",
            "items": {
              "type": "string"
            }
          },
          "compareKeywords": {
            "title": "Compare terms (one request, comparable values)",
            "type": "array",
            "description": "Up to 5 terms fetched in ONE request. Google scales 0-100 within a single request, so these values ARE directly comparable to each other — unlike terms in `keywords`, which are fetched separately and are not. Also cheaper: 3 terms cost 2 requests instead of 6.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "geo": {
            "title": "Location",
            "type": "string",
            "description": "Two-letter country code (US, VN, GB) or a sub-region like US-CA. Leave empty for worldwide.",
            "default": ""
          },
          "timeframe": {
            "title": "Time range",
            "type": "string",
            "description": "Google Trends range string. 'today 12-m' = last 12 months (weekly points), 'today 5-y', 'now 7-d' (hourly), 'all' since 2004, or an explicit '2025-01-01 2025-12-31'.",
            "default": "today 12-m"
          },
          "dataTypes": {
            "title": "Data to fetch",
            "type": "array",
            "description": "Each selected type is one extra request to Google per keyword, and one billed result.",
            "items": {
              "type": "string",
              "enum": [
                "interestOverTime",
                "interestByRegion",
                "relatedTopics",
                "relatedQueries"
              ],
              "enumTitles": [
                "Interest over time",
                "Interest by region",
                "Related topics",
                "Related queries"
              ]
            },
            "default": [
              "interestOverTime"
            ]
          },
          "category": {
            "title": "Category ID",
            "type": "integer",
            "description": "Google Trends category id. 0 = all categories.",
            "default": 0
          },
          "includeTrendingNow": {
            "title": "Also fetch 'Trending now'",
            "type": "boolean",
            "description": "Currently trending searches for the location, with search volume. This uses Google's current endpoint — the older daily/realtime trends APIs were retired and now return 404.",
            "default": false
          },
          "trendingGeo": {
            "title": "Location for 'Trending now'",
            "type": "string",
            "description": "Defaults to the Location above, or US.",
            "default": "US"
          },
          "cacheMaxAgeMinutes": {
            "title": "Accept cached results up to (minutes)",
            "minimum": 0,
            "type": "integer",
            "description": "Google Trends is weekly-resolution for most ranges, so a recent cached answer is identical to a fresh one — and serving it means no request to Google, which is why this Actor rarely fails. Set 0 to force a live fetch.",
            "default": 360
          },
          "minRequestGapSeconds": {
            "title": "Minimum gap between requests to Google (seconds)",
            "type": "string",
            "description": "Default 1.2s. Measured: a burst faster than ~6.6 req/s is rate-limited for about a minute. Lower this only if you know what you are doing.",
            "default": "1.2"
          },
          "useApifyProxy": {
            "title": "Use Apify Proxy (recommended)",
            "type": "boolean",
            "description": "Strongly recommended. Google budgets requests per IP over hours, not seconds: a single IP was measured going permanently rate-limited after ~130 paced requests. Without a proxy, larger jobs will return errors for the later keywords.",
            "default": true
          },
          "apifyProxyGroups": {
            "title": "Proxy groups",
            "type": "array",
            "description": "Leave empty for datacenter proxies (cheapest). Use RESIDENTIAL only if datacenter IPs get blocked — it costs far more per GB.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "apifyProxyCountry": {
            "title": "Proxy country",
            "type": "string",
            "description": "Optional two-letter code. Trends results do not depend on the requesting IP's country (the `geo` input controls that), so leave empty unless a specific country's IPs are less blocked for you.",
            "default": ""
          },
          "rotateAfterKeywords": {
            "title": "Rotate IP after N keywords",
            "minimum": 1,
            "type": "integer",
            "description": "A new proxy session (new IP + new cookie) every N keywords. Lower spreads the per-IP budget wider; higher reuses a warmed session.",
            "default": 5
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}