YouTubeAnswer

YouTube autocomplete API: search suggestions as JSON

The YouTube Data API has no search-suggestions method. Our API returns YouTube's autocomplete list as JSON, 14 suggestions a call, by country and language.

4 min read

Short answer

  • The YouTube Data API has no method for the suggestions YouTube shows as you type. The endpoint the site itself calls is undocumented and returns JavaScript, not JSON.
  • Suggestions change with country and language, so a keyword list built from one location misses what people type elsewhere.
  • Our YouTube API returns 14 suggestions a call as JSON at 1 credit, with region_code and language_code, and a seed plus a to z gives about 350.
On this page

The YouTube Data API has no autocomplete method. Its reference covers videos, channels, playlists, comments and search results, not the suggestions under the search box. Our YouTube API returns that list as JSON, about 14 suggestions a call, for the country and language you set.

What the YouTube Data API is for

The YouTube Data API has resources for videos, channels, playlists, comments, captions, subscriptions and search, and none for suggestions. The search box on youtube.com calls a suggest endpoint that has no documentation page. It answers with a JavaScript callback around a nested array, and with no language set it follows the caller's location: from our server in Germany, "python tutorial" came back with German suggestions first. Setting a country and language on it means guessing at undocumented parameters.

Search suggestions with ToolzerHub

We make ToolzerHub. Our YouTube API returns public YouTube channels, videos, search results and suggestions as JSON with one API key and no Google project. /v2/youtube/suggestions takes search_term, region_code and language_code, and costs 1 credit a call.

bash
export TOOLZERHUB_API_KEY=your_key
curl -H "x-api-key: $TOOLZERHUB_API_KEY" \
  "https://api.toolzerhub.com/v2/youtube/suggestions?search_term=python%20tutorial&region_code=US&language_code=en"

data, trimmed to the first six of 14:

json
{
  "search_term": "python tutorial",
  "suggestions": [
    "python tutorial",
    "python tutorial for beginners",
    "python tutorial 2025",
    "python tutorial for experienced programmers",
    "python tutorial bro code",
    "python tutorial 2026"
  ]
}

The list is in YouTube's order. language_code changes it as much as the country does: with de, the same search starts with "python tutorial deutsch", and with fr, with "python tutorial français".

Build a keyword list for a topic

The script sends each seed term, then the seed followed by each letter from a to z, and keeps every suggestion once per country. It writes one row per suggestion with the prefix that produced it and its position, and prints the count for each seed and country. Install requests (pip install requests) and save it as youtube_autocomplete.py.

python
import csv
import os
import string
import sys
import time

import requests

URL = "https://api.toolzerhub.com/v2/youtube/suggestions"
HEADERS = {"x-api-key": os.environ.get("TOOLZERHUB_API_KEY", "")}
FIELDS = ["seed", "region", "language", "prefix", "position", "suggestion"]


def suggest(term, region, language, tries=3):
    # Retry rate limits, server errors and dropped connections.
    for attempt in range(tries):
        last = attempt == tries - 1
        try:
            r = requests.get(URL, headers=HEADERS, params={"search_term": term, "region_code": region, "language_code": language}, timeout=120)
        except requests.RequestException:
            if last:
                raise
            time.sleep(5 * (attempt + 1))
            continue
        if r.status_code in (429, 500, 502, 503, 504) and not last:
            time.sleep(5 * (attempt + 1))
            continue
        r.raise_for_status()
        return r.json()["data"]["suggestions"]


def main(seeds, regions="US", language="en", out="youtube_autocomplete.csv"):
    with open(out, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDS)
        writer.writeheader()
        for seed in filter(None, (s.strip() for s in seeds.split(","))):
            for region in filter(None, (r.strip().upper() for r in regions.split(","))):
                seen = set()
                # The seed alone, then the seed followed by each letter, the way people type.
                for prefix in [seed] + [f"{seed} {c}" for c in string.ascii_lowercase]:
                    for position, s in enumerate(suggest(prefix, region, language), 1):
                        if s not in seen:
                            seen.add(s)
                            writer.writerow({"seed": seed, "region": region, "language": language, "prefix": prefix,
                                             "position": position, "suggestion": s})
                print(f"{seed} ({region}): {len(seen)} unique suggestions from 27 calls")


if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.exit('usage: python youtube_autocomplete.py "python tutorial,meal prep" [US,GB] [en] [out.csv]')
    if not HEADERS["x-api-key"]:
        sys.exit("set TOOLZERHUB_API_KEY first")
    main(*sys.argv[1:])

What two topics in three countries showed

python youtube_autocomplete.py "python tutorial,meal prep" "US,GB,IN" made 162 calls in 107 seconds and saved 2,092 suggestions, 341 to 357 for each topic and country.

Topic US UK India In all three Only in India
python tutorial 341 341 344 262 of 433 45
meal prep 357 354 355 158 of 618 140

Most "python tutorial" suggestions repeat across countries: 262 of the 433 distinct ones appeared in all three. For "meal prep" it was 158 of 618. In India, 51 of the 355 meal prep suggestions contain "indian" or an Indian language name, such as "meal prep for the week malayalam", against 7 in the US list. 140 appeared in neither the US nor the UK list.

What it costs

A seed in one country is 27 credits with the a to z pass, or 1 credit for the seed alone. The 100 free credits a month cover three full passes; $19 buys 10,000 credits that never expire, and plans for higher volume cover keyword lists across many topics and countries. Set your key and the first topic is a CSV in under a minute.

For the videos behind each suggestion, see the YouTube search API quota. For what YouTube recommends next to a video, see related videos.

We are not affiliated with YouTube or Google.

Get this data from your own code

The YouTube API returns it as JSON with one x-api-key header. 100 free credits monthly.