API Documentation

Google Trends API

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

Test API

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.
geoNoRegion code such as US. TIMESERIES may provide comma-separated regions matching the query count.
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. The same mode is the only mode that supports multiple comma-separated geo values, and their count must match the query count.

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(s).
data.query.data_typestringNormalized selected data type.
data.qstringQuery returned by the trend data service.
data.datestringDate range returned by the trend data service.
data.geostring or nullRegion returned by the trend data service.
data.tznumberTime-zone offset returned with the trend data.
data.dataTypestringReturned data type.
data.interestOverTimeobjectPresent for TIMESERIES; contains timeline_data and averages.
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.

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.
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. Credits are deducted only after a valid response is returned. Invalid parameters, failed requests, and incomplete responses do not consume credits.