Skip to content

YouTube Search Typeahead API

YouTube's own search suggestions for a partial query, the autocomplete list the search box shows. Useful as a keyword-research signal: these are ranked by what people actually search for. Calls cost 1 credit each. A cache hit is free, and a failed or empty response is never charged.

Try it

Prefilled with the request that produced the example below. No key yet? Get a free key.

Request

GET/v1/youtube/search/typeahead
ParameterTypeRequiredDescription
querystringyesPartial search query
regionstringnoISO 3166-1 alpha-2 country codedefaults to US
languagestringnoInterface languagedefaults to en

Also accepts cache_max_age (a hit costs 0 credits) and include_raw (returns the untouched upstream payload under raw).

curl
curl "$API/v1/youtube/search/typeahead?query=nasa&cache_max_age=7d" \
  -H "x-api-key: $KEY"
JavaScript
const query = new URLSearchParams({
  query: 'nasa',
  cache_max_age: '7d',
});

const response = await fetch(`${API}/v1/youtube/search/typeahead?${query}`, {
  headers: { 'x-api-key': KEY },
});

const body = await response.json();
if (!body.success) throw new Error(body.error.code);

// 1 credit, 0 on a cache hit
console.log(body.data, body.meta.creditsCharged);
Python
import os, httpx

r = httpx.get(
    f"{os.environ['API']}/v1/youtube/search/typeahead",
    params={
        "query": "nasa",
        "cache_max_age": "7d",
    },
    headers={"x-api-key": os.environ["KEY"]},
    timeout=30,
)

body = r.json()
if not body["success"]:
    raise RuntimeError(body["error"]["code"])

print(body["data"], body["meta"]["creditsCharged"])

Example response

Captured on , with raw removed and lists cut to two items. A live call returns current data.

response
{
  "success": true,
  "data": {
    "query": "nasa",
    "suggestions": [
      "nasa",
      "nasa spa"
    ]
  },
  "meta": {
    "platform": "youtube",
    "endpoint": "youtube.searchTypeahead",
    "creditsCharged": 1,
    "cached": false,
    "cacheAgeSeconds": null,
    "durationMs": 73,
    "requestId": "req_iny3dt3j0lbx5yvv9245"
  }
}

Returns

Returns an object with query, suggestions.

Fields
FieldTypePresentDescription
querystringalwaysThe query as asked, echoed back
suggestionsstring[]alwaysDeduplicated, in YouTube’s own ranking order

Cost and behaviour

Credits1 per live request, 0 on a cache hit
Cacheableyes: cache_max_age accepts a cached copy
Batchableyes: usable as a target in POST /v1/jobs/batch
Subscribableno

Other YouTube endpoints