API Documentation

Google Trends API

Query trend interest over time, related topics, and related queries.

Test API

For use cases, result boundaries and an interactive test, see the Google Trends API product page. This reference covers request parameters, response fields and billing.

Google Trends API product page →

Endpoint

GET https://api.goanyapi.com/api/v1/google-trends

The current configured cost is 6 credits per keyword.

Authentication

Authorization: Bearer YOUR_API_KEY

Request parameters

ParameterRequiredDescription
qYesSearch query. TIMESERIES accepts up to five comma-separated queries; the other modes accept one query only. Each query is at most 100 characters.
dateNoOne of now 1-H, now 4-H, now 1-d, now 7-d, today 1-m, today 3-m, today 12-m, today 5-y, or all. Defaults to today 12-m.
geoNoOne region code such as US, shared by all queries.
data_typeNoTIMESERIES, RELATED_TOPICS, or RELATED_QUERIES. Defaults to TIMESERIES.

Examples

Interest over time

curl --get 'https://goanyapi.com/api/v1/google-trends' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data-urlencode 'q=ai video,chatgpt'
curl --get 'https://goanyapi.com/api/v1/google-trends' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data-urlencode 'q=ai video' \
  --data-urlencode 'data_type=RELATED_TOPICS'
curl --get 'https://goanyapi.com/api/v1/google-trends' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data-urlencode 'q=ai video' \
  --data-urlencode 'data_type=RELATED_QUERIES'

Only TIMESERIES supports comma-separated values in q. geo accepts one region code for all queries.

Response

{
  "code": "ok",
  "message": "ok",
  "data": {
    "endpoint": "google-trends",
    "remainingCredits": 96,
    "query": {
      "q": "ai video,chatgpt",
      "date": "today 12-m",
      "data_type": "TIMESERIES"
    },
    "q": "ai video,chatgpt",
    "date": "today 12-m",
    "tz": 420,
    "dataType": "TIMESERIES",
    "interestOverTime": {
      "timeline_data": [],
      "averages": []
    }
  }
}

Response object fields

FieldTypeDescription
codestringPublic response status, normally ok for a successful request.
messagestring or nullPublic response message.
data.endpointstringFixed value google-trends.
data.costCreditsnumberCredits charged for the request, calculated from the number of keywords.
data.remainingCreditsnumberAccount credits remaining after the request.
data.query.qstringNormalized query string.
data.query.datestringNormalized date range.
data.query.geostringOptional normalized region code.
data.query.data_typestringNormalized selected data type.
data.qstringQuery used for the result.
data.datestringDate range used for the result.
data.geostring or nullRegion used for the result.
data.tznumberTime-zone offset returned with the trend data.
data.dataTypestringReturned data type.
data.interestOverTimeobjectPresent for TIMESERIES; fields vary with the returned result.
data.relatedTopicsobjectPresent for RELATED_TOPICS; contains top and rising.
data.relatedQueriesobjectPresent for RELATED_QUERIES; contains top and rising.

For RELATED_TOPICS, the response contains relatedTopics with top and rising arrays. For RELATED_QUERIES, it contains relatedQueries with top and rising arrays. Fields not returned for the selected mode are omitted.

When a query completes with no trend data, the selected mode returns empty arrays with code: "ok". The request still consumes the configured credits and data.costCredits shows the amount charged.

TIMESERIES response fields

All modes return the normalized q, date, optional geo, tz, and dataType fields. TIMESERIES additionally returns:

FieldDescription
data.interestOverTime.timeline_data[]Timeline points.
data.interestOverTime.timeline_data[].dateDisplay date or date range.
data.interestOverTime.timeline_data[].timestampPoint timestamp.
data.interestOverTime.timeline_data[].partial_dataOptional flag for an incomplete point.
data.interestOverTime.timeline_data[].values[]Values for each query.
data.interestOverTime.timeline_data[].values[].queryQuery text.
data.interestOverTime.timeline_data[].values[].query_indexZero-based query index.
data.interestOverTime.timeline_data[].values[].valueDisplay interest value.
data.interestOverTime.timeline_data[].values[].extracted_valueNumeric interest value.
data.interestOverTime.averages[]Average value for each query.
data.interestOverTime.averages[].queryQuery text.
data.interestOverTime.averages[].valueAverage interest value.

averages may be omitted when it is not returned. Available trend points remain unchanged.

FieldDescription
data.relatedTopics.top[]Top related topics.
data.relatedTopics.rising[]Rising related topics.
data.relatedTopics.*[].topic.valueTopic identifier.
data.relatedTopics.*[].topic.titleTopic title.
data.relatedTopics.*[].topic.typeTopic type.
data.relatedTopics.*[].valueDisplay relevance value.
data.relatedTopics.*[].extracted_valueNumeric relevance value.
data.relatedTopics.*[].linkPublic trend link.
FieldDescription
data.relatedQueries.top[]Top related queries.
data.relatedQueries.rising[]Rising related queries.
data.relatedQueries.*[].queryRelated query text.
data.relatedQueries.*[].valueDisplay relevance value.
data.relatedQueries.*[].extracted_valueNumeric relevance value.
data.relatedQueries.*[].linkPublic trend link.

The value fields are the display values, while extracted_value contains the numeric value when available. partial_data is present only for incomplete timeline points.

Billing

Each keyword uses the current configured per-keyword rate shown above. TIMESERIES accepts at most five keywords, so one request charges up to five times that rate. A completed query with no data is a successful response and is charged. Invalid parameters, failed requests, and incomplete responses do not consume credits.