YouTube Typeahead Search
youtube.search.typeahead
Get the search suggestions YouTube offers for the start of a query, in the language you choose.
At a glance
- Endpoint ID
youtube.search.typeahead- Price
- 1 credit per call; failed calls are free
- Runs for up to
- 30 seconds
Request
Send the endpoint ID as capability and its fields as input. Set UPSCRAPE_API_KEY to your key first.
curl --request POST \ --url https://data.upscrape.com/execute \ --header "Authorization: Bearer $UPSCRAPE_API_KEY" \ --header "Content-Type: application/json" \ --header "Prefer: wait=30" \ --data '{ "capability": "youtube.search.typeahead", "input": { "query": "golang" }}'
import jsonimport osimport requestspayload = json.loads(r'''{ "capability": "youtube.search.typeahead", "input": { "query": "golang" }}''')response = requests.post( "https://data.upscrape.com/execute", headers={ "Authorization": f"Bearer {os.environ['UPSCRAPE_API_KEY']}", "Content-Type": "application/json", "Prefer": "wait=30", }, json=payload,)response.raise_for_status()print(json.dumps(response.json(), indent=2))
const response = await fetch("https://data.upscrape.com/execute", { method: "POST", headers: { "Authorization": `Bearer ${process.env.UPSCRAPE_API_KEY}`, "Content-Type": "application/json", "Prefer": "wait=30", }, body: JSON.stringify({ "capability": "youtube.search.typeahead", "input": { "query": "golang" }}),});if (!response.ok) { throw new Error(`Upscrape request failed: ${response.status}`);}console.log(JSON.stringify(await response.json(), null, 2));
Input
| Field | Type | Required | What it does | Example |
|---|---|---|---|---|
query |
string | yes | Partial search query | golang |
language |
string | no |
Response
A finished call answers with HTTP 200; the data is in results[0].data, and billing.credits_charged is what it cost. A call still running after the wait answers 202: see jobs and results.
This is results[0].data from a real run:
{ "count": 10, "suggestions": [ "golang", "golang tutorial" ]}
Fields
| Field | Type | What it is | Example |
|---|---|---|---|
count |
integer | How many suggestions this answer holds. | 10 |
suggestions |
array | Search suggestions YouTube offers for the text. | golang, golang tutorial, golang tutorial deutsch |
If a call fails
A failed call costs nothing. The response carries an error.code you can branch on; Errors and retries lists every code and which ones to retry.
Other YouTube endpoints
youtube.channel-community.listChannel communityyoutube.channel-live.listChannel live streamsyoutube.channel-playlists.listChannel playlistsyoutube.channel-shorts.listChannel Shortsyoutube.channel-videos.listChannel videosyoutube.channel.getChannelyoutube.comments.listCommentsyoutube.feed.trendingTrending shortsyoutube.hashtag.listHashtag videosyoutube.playlist.getPlaylistyoutube.post.getCommunity postyoutube.search.querySearchyoutube.video.getVideo
Something missing or unclear? Ask the team that builds the YouTube endpoints.