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| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | yes | Partial search query |
| region | string | no | ISO 3166-1 alpha-2 country codedefaults to US |
| language | string | no | Interface 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
| Field | Type | Present | Description |
|---|---|---|---|
| query | string | always | The query as asked, echoed back |
| suggestions | string[] | always | Deduplicated, in YouTube’s own ranking order |
Cost and behaviour
| Credits | 1 per live request, 0 on a cache hit |
| Cacheable | yes: cache_max_age accepts a cached copy |
| Batchable | yes: usable as a target in POST /v1/jobs/batch |
| Subscribable | no |
Other YouTube endpoints
- /v1/youtube/channel Channel details
- /v1/youtube/channel-videos Channel videos
- /v1/youtube/channel/community-posts Channel community posts
- /v1/youtube/channel/lives Channel live streams
- /v1/youtube/channel/playlists Channel playlists
- /v1/youtube/channel/shorts Channel shorts
- /v1/youtube/community-post Community post details
- /v1/youtube/playlist Playlist contents