Support needed? Reach out! 📧

How to Scrape Youtube Keyword Search Results

This tutorial shows how to use Youtube Keyword Search Results API to scrape and crawl structured Youtube data in real-time.
Query YouTube's full content index by keyword through our API and retrieve ranked videos, channel results, and topic clusters to support SEO analysis and content research.

Access Youtube Data in 3 Steps

Start crawling Youtube keyword search data. Follow these steps to extract social media data in minutes.

1

Create Your Account

Go to our registration page and make an account. It's free, no credit card, and you get credits right away to play around with.

2

Verify Your Email Address

You'll get a verification email, click the link in it. Once that's done, you can grab your API token from the dashboard.

3

Make Your First API Call

Copy the code snippet below, swap in your API key, and run it. You'll get Youtube data back as JSON within a few seconds.

Code Sample

Here's a JavaScript example to get you going. Swap out the token and you're good, works the same way in any language that can make HTTP requests. Start collecting keyword search data via our REST API!

javascript-logo JavaScript
Youtube Keyword Search
1 const root = 'https://ensembledata.com/apis'
2 const endpoint = '/youtube/search'
3 const params = {
4   "keyword""magic",
5   "depth"1,
6   "start_cursor""",
7   "period""overall",
8   "sorting""relevance",
9   "get_additional_info": false,
10   "token""YOUR-TOKEN-HERE"
11 }
12  
13 const queryString = new URLSearchParams(params).toString();
14 const url = `${root}${endpoint}?${queryString}`;
15  
16 await fetch(url)
17   .then(response => response.json())
18   .then(data => console.log(data))
19   .catch(error => console.error(error));
20  

Parameters

keyword (string) The keyword to base the search on. REQUIRED
depth (integer) Abstraction of the API pagination. Depth 1 returns X results, depth N returns N * X results. Note that the exact number of results per depth (X) may differ per endpoint. Please refer to the specific endpoint description for more information. REQUIRED
start_cursor (string) If no `start cursor` is specified, it fetches the results from the 'All' category on the Youtube search. Other cursors can be fetched by first sending a request to our `Featured Categories Search` endpoint.
period Time filter to return only videos from a certain time period (overall, this hour, today, this week, this month, This year).
sorting Sort results based on a parameter (relevance, upload time, view count, rating).
get_additional_info (boolean) Fetch additional info for the video (number of subscribers, likes and comments) and channel owner. 1 extra unit is charged per video.
token (string) Private token assigned to each client to access the APIs. REQUIRED

Example Response

Explore the fields returned by this endpoint. Click a row to expand nested objects and arrays, hover a value to copy it, or use "Expand all" to see everything at once.

JSON
Youtube Keyword Search
dataobject1 field
postsarray1 item · schema from #0 1 item
videoRendererobject21 fields
videoIdstring"YtNhGdkMyCU"
thumbnailobject1 field
thumbnailsarray2 items · schema from #0 2 items
urlstring"https://i.ytimg.com/vi/YtNhGdkMyCU/hq720.jpg?sqp=-oaymwEcCOgCEMoBSFXyq…"
widthnumber360
heightnumber202
titleobject2 fields
runsarray1 item · schema from #0 1 item
textstring"TIMBERWOLVES at MAGIC | NBA FULL GAME HIGHLIGHTS | November 16, 2022"
accessibilityobject1 field
accessibilityDataobject1 field
labelstring"TIMBERWOLVES at MAGIC | NBA FULL GAME HIGHLIGHTS | November 16, 2022 b…"
longBylineTextobject1 field
runsarray1 item · schema from #0 1 item
textstring"NBA"
navigationEndpointobject3 fields
clickTrackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALE="
commandMetadataobject1 field
webCommandMetadataobject4 fields
urlstring"/@NBA"
webPageTypestring"WEB_PAGE_TYPE_CHANNEL"
rootVenumber3611
apiUrlstring"/youtubei/v1/browse"
browseEndpointobject2 fields
browseIdstring"UCWJ2lWNubArHWmf3FIHbfcQ"
canonicalBaseUrlstring"/@NBA"
publishedTimeTextobject1 field
simpleTextstring"1 day ago"
lengthTextobject2 fields
accessibilityobject1 field
accessibilityDataobject1 field
labelstring"9 minutes, 34 seconds"
simpleTextstring"9:34"
viewCountTextobject1 field
simpleTextstring"133,744 views"
navigationEndpointobject3 fields
clickTrackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALEyBnNlYXJjaFIFbWFnaWOaAQMQ9CQ="
commandMetadataobject1 field
webCommandMetadataobject3 fields
urlstring"/watch?v=YtNhGdkMyCU"
webPageTypestring"WEB_PAGE_TYPE_WATCH"
rootVenumber3832
watchEndpointobject3 fields
videoIdstring"YtNhGdkMyCU"
paramsstring"qgMFbWFnaWO6AwsImKH4hdTbwLGzAboDCgi_z-DjlYTDwDa6AwsI2ayV1b2UxMbsAboDCw…"
watchEndpointSupportedOnesieConfigobject1 field
html5PlaybackOnesieConfigobject1 field
commonConfigobject1 field
urlstring"https://rr4---sn-a5mekndz.googlevideo.com/initplayback?source=youtube&…"
badgesarray1 item · schema from #0 1 item
metadataBadgeRendererobject3 fields
stylestring"BADGE_STYLE_TYPE_SIMPLE"
labelstring"New"
trackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALE="
ownerBadgesarray1 item · schema from #0 1 item
metadataBadgeRendererobject5 fields
iconobject1 field
iconTypestring"CHECK_CIRCLE_THICK"
stylestring"BADGE_STYLE_TYPE_VERIFIED"
tooltipstring"Verified"
trackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALE="
accessibilityDataobject1 field
labelstring"Verified"
ownerTextobject1 field
runsarray1 item · schema from #0 1 item
textstring"NBA"
navigationEndpointobject3 fields
clickTrackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALE="
commandMetadataobject1 field
webCommandMetadataobject4 fields
urlstring"/@NBA"
webPageTypestring"WEB_PAGE_TYPE_CHANNEL"
rootVenumber3611
apiUrlstring"/youtubei/v1/browse"
browseEndpointobject2 fields
browseIdstring"UCWJ2lWNubArHWmf3FIHbfcQ"
canonicalBaseUrlstring"/@NBA"
shortBylineTextobject1 field
runsarray1 item · schema from #0 1 item
textstring"NBA"
navigationEndpointobject3 fields
clickTrackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALE="
commandMetadataobject1 field
webCommandMetadataobject4 fields
urlstring"/@NBA"
webPageTypestring"WEB_PAGE_TYPE_CHANNEL"
rootVenumber3611
apiUrlstring"/youtubei/v1/browse"
browseEndpointobject2 fields
browseIdstring"UCWJ2lWNubArHWmf3FIHbfcQ"
canonicalBaseUrlstring"/@NBA"
trackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALFApZCzyJ2j2Oli"
showActionMenubooleanfalse
shortViewCountTextobject2 fields
accessibilityobject1 field
accessibilityDataobject1 field
labelstring"133K views"
simpleTextstring"133K views"
menuobject1 field
menuRendererobject3 fields
itemsarray1 item · schema from #0 1 item
menuServiceItemRendererobject4 fields
textobject1 field
runsarray1 item · schema from #0 1 item
textstring"Add to queue"
iconobject1 field
iconTypestring"ADD_TO_QUEUE_TAIL"
serviceEndpointobject3 fields
clickTrackingParamsstring"CLEDEP6YBBgMIhMIyZblttK3-wIVRtHECh3DDwCx"
commandMetadataobject1 field
webCommandMetadataobject1 field
sendPostbooleantrue
signalServiceEndpointobject2 fields
signalstring"CLIENT_SIGNAL"
actionsarray1 item · schema from #0 1 item
clickTrackingParamsstring"CLEDEP6YBBgMIhMIyZblttK3-wIVRtHECh3DDwCx"
addToPlaylistCommandobject5 fields
openMiniplayerbooleantrue
videoIdstring"YtNhGdkMyCU"
listTypestring"PLAYLIST_EDIT_LIST_TYPE_QUEUE"
onCreateListCommandobject3 fields
clickTrackingParamsstring"CLEDEP6YBBgMIhMIyZblttK3-wIVRtHECh3DDwCx"
commandMetadataobject1 field
webCommandMetadataobject2 fields
sendPostbooleantrue
apiUrlstring"/youtubei/v1/playlist/create"
createPlaylistServiceEndpointobject2 fields
videoIdsarray1 item · schema from #0 1 item
0string"Y"
1string"t"
2string"N"
3string"h"
4string"G"
5string"d"
6string"k"
7string"M"
8string"y"
9string"C"
10string"U"
paramsstring"CAQ%3D"
videoIdsarray1 item · schema from #0 1 item
0string"Y"
1string"t"
2string"N"
3string"h"
4string"G"
5string"d"
6string"k"
7string"M"
8string"y"
9string"C"
10string"U"
trackingParamsstring"CLEDEP6YBBgMIhMIyZblttK3-wIVRtHECh3DDwCx"
trackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALE="
accessibilityobject1 field
accessibilityDataobject1 field
labelstring"Action menu"
channelThumbnailSupportedRenderersobject1 field
channelThumbnailWithLinkRendererobject3 fields
thumbnailobject1 field
thumbnailsarray1 item · schema from #0 1 item
urlstring"https://yt3.ggpht.com/g083wpJ8yJ9YaYDmI-xK_xPiMtQKVssUzS9MkPasj7hp4KvA…"
widthnumber68
heightnumber68
navigationEndpointobject3 fields
clickTrackingParamsstring"CK4DENwwGAAiEwjJluW20rf7AhVG0cQKHcMPALE="
commandMetadataobject1 field
webCommandMetadataobject4 fields
urlstring"/@NBA"
webPageTypestring"WEB_PAGE_TYPE_CHANNEL"
rootVenumber3611
apiUrlstring"/youtubei/v1/browse"
browseEndpointobject2 fields
browseIdstring"UCWJ2lWNubArHWmf3FIHbfcQ"
canonicalBaseUrlstring"/@NBA"
accessibilityobject1 field
accessibilityDataobject1 field
labelstring"Go to channel"
thumbnailOverlaysarray4 items · schema from #0 4 items
thumbnailOverlayTimeStatusRendererobject2 fields
textobject2 fields
accessibilityobject1 field
accessibilityDataobject1 field
labelstring"9 minutes, 34 seconds"
simpleTextstring"9:34"
stylestring"DEFAULT"
richThumbnailobject1 field
movingThumbnailRendererobject3 fields
movingThumbnailDetailsobject2 fields
thumbnailsarray1 item · schema from #0 1 item
urlstring"https://i.ytimg.com/an_webp/YtNhGdkMyCU/mqdefault_6s.webp?du=3000&sqp=…"
widthnumber320
heightnumber180
logAsMovingThumbnailbooleantrue
enableHoveredLoggingbooleantrue
enableOverlaybooleantrue
detailedMetadataSnippetsarray1 item · schema from #0 1 item
snippetTextobject1 field
runsarray1 item · schema from #0 1 item
textstring"Never miss a moment with the latest news, trending stories and highlig…"
snippetHoverTextobject1 field
runsarray1 item · schema from #0 1 item
textstring"From the video description"
maxOneLinebooleanfalse
searchVideoResultEntityKeystring"EgtZdE5oR2RrTXlDVSDnAigB"

Response Codes

Status codes this endpoint can return, so you can handle errors before they surprise you in production.

200SuccessSuccessful Response
422Client ErrorValidation Error
491Client ErrorToken not found
492Client ErrorEmail not verified
493Client ErrorSubscription expired
495Client ErrorAll daily units used
500Server ErrorSomething went wrong

API Pricing

depth units Cost per successful call to this endpoint.
Example Cases
1
Depth 1 Result: 20 videos
1 unit
2
Depth 5 Result: 100 videos
5 units
3
Depth 100 but keyword only has 100 videos Result: 100 videos
5 units
4
Depth 100 Result: 2000 videos
100 units

Fetch Youtube Data at Scale

Scrape YouTube search results at scale and analyze which topics, formats, and creators are performing best for your target keywords.

deco-icon

Ranked Results

Get ranked videos and channels for any YouTube search term.

deco-icon

SEO Rankings

See which videos currently rank to inform your video SEO.

deco-icon

Topic Clusters

Surface topic clusters your target audience is searching for.