Skip to content

YouTube Search API & Scraper - Videos, Shorts & Channels

Rocketyard’s YouTube Search API & Scraper returns the results of YouTube searches and returns one clean record per search result: position, query, search url, shelf, video id, playlist id and more. It runs on the Apify platform, so you can start it from the Apify Console, the REST API, an AI agent or a no-code tool.

  • YouTube SEO specialists and agencies tracking rankings
  • Marketers and brands researching topics and competitors on YouTube
  • Influencer marketers finding creators by keyword
  • Developers and analysts feeding YouTube results into apps, dashboards and AI agents
  • Get the top 100 or 1,000 results for a list of keywords, with ranks, views and channels
  • Track a video’s rank for a keyword every day
  • Collect every new video on a topic from the last hour or day
  • Find channels for a niche, with subscriber counts

A YouTube search page loads its results from YouTube’s search endpoint as JSON, 20 or so at a time, and asks for the next ones with a continuation token as you scroll. The Actor sends the same logged-out requests over plain HTTP, with no browser, login or cookies: your query with the params value YouTube’s own filter menu builds for the type, upload date, length and sort you pick, then the continuation token of each answer, with a random pause of 300 to 800 ms between requests. The web client version the endpoint expects is read once per run from a 3 KB answer YouTube serves to every logged-out visitor, and checked before use. Each result becomes one typed record: its type and rank, the video, Short, channel or playlist ID and URL, the title, the channel with its handle and verified badge, the view count as a number and as shown, the age, the length in seconds, live and Shorts flags, the thumbnail, the description snippet and the badges. A result listed twice, on two pages or in a shelf, is stored and charged once. It does not check robots.txt, and YouTube’s robots.txt disallows the /results and /youtubei/ paths of the search page and its endpoint.

A real record from a test run on youtube.com on 2026-11-12. Fields the page didn’t publish are left out here; the Actor returns them as null.

{
"url": "https://www.youtube.com/watch?v=CLeZyIID9Bo",
"type": "video",
"position": 6,
"query": "lofi hip hop",
"searchUrl": "https://www.youtube.com/results?search_query=lofi+hip+hop&sp=EgIQAQ%253D%253D",
"videoId": "CLeZyIID9Bo",
"title": "Chill Lofi Mix [chill lo-fi hip hop beats]",
"channelId": "UCkKT4qf-TcPFOmpqhTawrGA",
"channelName": "Settle",
"channelHandle": "@settlefm",
"channelUrl": "https://www.youtube.com/@settlefm",
"channelVerified": false,
"viewCount": 35278018,
"viewCountText": "35,278,018 views",
"publishedText": "4 years ago",
"durationSeconds": 6292,
"durationText": "1:44:52",
"isShort": false,
"isLive": false,
"isUpcoming": false,
"thumbnailUrl": "https://i.ytimg.com/vi/CLeZyIID9Bo/hq720.jpg?sqp=-oaymwExCNAFEJQDSFryq4qpAyMIARUAAIhCGAHwAQH4Af4JgALQBYoCDAgAEAEYQyBkKGUwDw==&rs=AOn4CLAX5tHBXfw7XY8bX2GjPk4Jw9lIEg",
"descriptionSnippet": "YouTube Playlists: http://listen.settle.fm/youtube Listen on Spotify, Apple Music & more: https://listen.settle.fm/playlists Tracklist ...",
"badges": [
"4K"
],
"scrapedAt": "2026-11-12T07:02:36.153Z"
}
Field Description Filled in latest test
position Rank in the search, from 1, in the order YouTube lists the results (each result once) 100%
query The search query 100%
searchUrl The YouTube search page with the same query and filters 100%
shelf Shelf the result is listed in (“Shorts”, “Latest from BBC News”); null for the main list 0%
videoId 11-character video ID of a video or Short 100%
playlistId Playlist ID of a playlist or course 0%
title Title of the video, Short or playlist, or the channel name 100%
channelId Channel ID (UC…) of the channel, or of the channel that published the video or playlist 98%
channelName Channel name 100%
channelHandle Channel handle (@name), when YouTube shows it 80%
channelUrl Channel URL 98%
channelVerified true when the channel has a verified or official artist badge 100%
viewCount Views as a number: exact for videos, rounded for Shorts 93%
viewCountText Views as YouTube shows them (“58,674,451 views”, “846K views”) 100%
watchingCount People watching a stream that is live now (instead of views) 8%
publishedText Age as YouTube shows it (“4 years ago”, “Streamed 2 years ago”) 93%
durationSeconds Length in seconds 93%
durationText Length as YouTube shows it (“6:10:58”) 93%
isShort true for Shorts 100%
isLive true for a stream that is live now 100%
isUpcoming true for a scheduled premiere or stream 100%
scheduledStartTime Start of a scheduled premiere or stream (ISO 8601) 0%
thumbnailUrl Largest thumbnail (the avatar for a channel) 100%
descriptionSnippet Start of the description, as the search shows it 100%
badges Badges YouTube shows on the result (“New”, “4K”, “CC”, “LIVE”; “Course” or “Playlist” on playlists) 48%
subscriberCount Channel results: subscribers as a number, from the rounded count YouTube shows 0%
subscriberCountText Channel results: subscribers as YouTube shows them (“12.5M subscribers”) 0%
videoCount Playlists, and channels when YouTube shows it: the number of videos (or lessons, episodes) 0%
videoCountText The same as YouTube shows it (“54 videos”, “124 lessons”) 0%
url the page the record came from 100%
scrapedAt ISO timestamp of the extraction 100%

A field is filled when the source publishes it. The Actor never guesses a value: a missing field comes back as null. “Filled in latest test” is the share of records from the latest test run (youtube.com) that had the field; other sources publish more or less.

You pay $1.00 per 1,000 results, plus a start fee of $0.00005 per run. Searches without results produce an error item, which is not charged, and a result listed twice is charged once.

Results Cost
1,000 $1.00
10,000 $10.00
100,000 $100.00

Set maxItems or the run’s Maximum cost per run in Apify to cap spending.

Every Apify Actor is also a REST endpoint, so YouTube Search API & Scraper works as a YouTube Search API, a YouTube search results API or a YouTube keyword search API. Call it from any language with the Apify REST API, or with Apify’s JavaScript and Python clients. You need an Apify API token.

Terminal window
curl -s -X POST "https://api.apify.com/v2/acts/rocketyard~youtube-search-scraper/run-sync-get-dataset-items" \
-H "Authorization: Bearer $APIFY_TOKEN" \
-H 'content-type: application/json' \
-d '{"queries":["lofi hip hop","how to cook rice"],"type":"video","uploadDate":"year","sortBy":"relevance","maxResultsPerQuery":300}'
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('rocketyard/youtube-search-scraper').call({"queries":["lofi hip hop","how to cook rice"],"type":"video","uploadDate":"year","sortBy":"relevance","maxResultsPerQuery":300});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
from apify_client import ApifyClient
client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("rocketyard/youtube-search-scraper").call(run_input={"queries":["lofi hip hop","how to cook rice"],"type":"video","uploadDate":"year","sortBy":"relevance","maxResultsPerQuery":300})
items = client.dataset(run["defaultDatasetId"]).list_items().items

The synchronous endpoint returns the records directly. For long crawls, start the run asynchronously and read the dataset when it finishes.

Apify’s MCP server exposes this Actor as a tool to Claude, Cursor and other MCP clients. Open this Actor’s MCP setup page for setup steps per client, or connect it with this URL:

https://mcp.apify.com?tools=rocketyard/youtube-search-scraper

Claude Code:

Terminal window
claude mcp add --transport http apify "https://mcp.apify.com?tools=rocketyard/youtube-search-scraper"

Cursor (.cursor/mcp.json) and other clients that read an mcpServers config:

{
"mcpServers": {
"apify": { "url": "https://mcp.apify.com?tools=rocketyard/youtube-search-scraper" }
}
}

On first use your browser opens so you can sign in to Apify. Then ask the agent, for example: “Get the top 100 or 1,000 results for a list of keywords, with ranks, views and channels”. The tool returns JSON records, and the runs are billed to that Apify account at $1.00 per 1,000 results.

n8n, Make and Zapier all connect to Apify. Each example below uses Actor rocketyard/youtube-search-scraper with this input:

{
"queries": [
"lofi hip hop",
"how to cook rice"
],
"type": "video",
"uploadDate": "year",
"sortBy": "relevance",
"maxResultsPerQuery": 300
}

Copy this workflow and paste it onto an n8n canvas. It runs the Actor every morning through an HTTP Request node and returns the records as n8n items.

{
"name": "YouTube Search API & Scraper daily",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "days",
"daysInterval": 1,
"triggerAtHour": 7
}
]
}
},
"id": "c1f6a2d0-4a57-4b5e-9d7a-0a1b2c3d4e01",
"name": "Every day at 07:00",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
0,
0
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.apify.com/v2/acts/rocketyard~youtube-search-scraper/run-sync-get-dataset-items",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"queries\": [\n \"lofi hip hop\",\n \"how to cook rice\"\n ],\n \"type\": \"video\",\n \"uploadDate\": \"year\",\n \"sortBy\": \"relevance\",\n \"maxResultsPerQuery\": 300\n}",
"options": {
"timeout": 300000
}
},
"id": "c1f6a2d0-4a57-4b5e-9d7a-0a1b2c3d4e02",
"name": "Run YouTube Search API & Scraper",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
260,
0
],
"credentials": {
"httpBearerAuth": {
"name": "Apify API token"
}
}
}
],
"connections": {
"Every day at 07:00": {
"main": [
[
{
"node": "Run YouTube Search API & Scraper",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {}
}

Then open the HTTP Request node and create an HTTP Bearer Auth credential named Apify API token, with your token from Apify Console as the bearer token. The token stays in n8n’s credential store; the workflow only names the credential. Change the input in the node’s JSON body to your own.

The node waits up to 300 seconds, which is also the limit of Apify’s synchronous endpoint. An input that yields nothing comes back as an item with an error field, which you can drop with a Filter node. Apify also publishes a community node, @apify/n8n-nodes-apify, with a Run an Actor and get dataset operation.

  1. Add Apify’s Run an Actor module and connect your Apify account.
  2. Choose rocketyard/youtube-search-scraper, paste the input above and set Run synchronously to Yes. Make limits how long a synchronous run can take, depending on your plan. For longer runs, start the scenario from Watch Actor Runs instead.
  3. Add Get Dataset Items with the run’s default dataset ID.
  4. Send the items wherever you need them, for example with Google Sheets Add a Row, mapping position, query, searchUrl and shelf.
  1. Add Apify’s Run Actor action, connect your Apify account, choose rocketyard/youtube-search-scraper and paste the input above.
  2. Zapier stops synchronous runs after 30 seconds. For anything larger than a small run, let the run continue in the background and start a second Zap from the Finished Actor run trigger.
  3. Add Fetch dataset items with the run’s dataset ID, then map position, query, searchUrl and shelf into your app.
  4. Test with a small input and check that the Zap handles every record before you turn it on.
  • YouTube decides how deep a search goes: about 20 results per page, until it answers “No more results”. In our test on 2026-11-12, a video search for “lofi hip hop” ended after 474 results, a Shorts search for “minecraft” after about 100, and “how to cook rice” uploaded this year after 17. A search that ends before Max results per search stops at its last page, and you pay for the results it had.
  • Shorts in a Shorts search or a Shorts shelf come with their title, views and thumbnail only: YouTube lists them without their channel and length, so those fields are empty on them. Other searches often list Shorts as videos, with their channel and length.
  • View counts are exact for videos and rounded for Shorts (846K), as YouTube shows them. A stream that is live now has watchingCount instead, the people watching it. Channel subscriber counts are rounded (12.5M), and empty for channels that hide them and for Topic channels (40% of 300 channels for “cooking” on 2026-11-12).
  • Ages are what YouTube shows (“4 years ago”), not dates: the search lists no upload date. For exact dates and likes, give the video IDs to a YouTube video scraper.
  • YouTube ranks results partly by where a request comes from (its IP address), so the same search through a proxy in another country can return other results.
  • YouTube no longer sorts search results by upload date or rating, so neither is offered. Its filter menu no longer shows Last hour either, but YouTube still honours it (tested 2026-11-12).
  • YouTube may answer an IP address with a bot check or a consent page, or refuse it with HTTP 401, 403 or 429. The Actor then stores one free BLOCKED error item and stops the run, keeping the results stored so far. It never tries to get past a block. Run it again later.

$1.00 per 1,000 results plus $0.00005 per run, billed by Apify. 10,000 results cost $10.00. There is no subscription, and you can cap any run with Maximum cost per run.

One request starts a run and returns its results, using your Apify API token:

Terminal window
curl -X POST "https://api.apify.com/v2/acts/rocketyard~youtube-search-scraper/run-sync-get-dataset-items" -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" -d '{"queries":["lofi hip hop","how to cook rice"],"type":"video","uploadDate":"year","sortBy":"relevance","maxResultsPerQuery":300}'

The dataset gets one free error item for it, with a code and the reason, and the other inputs in the run carry on. Error codes explains each code, whether a retry helps and what to do.

Any YouTube search a logged-out visitor can run, by keyword, with YouTube’s own filters: type, upload date, length and popularity. Search URLs copied from youtube.com work too, with the filters picked there.

The field comes back as null. The Actor reports what the source publishes and never fills in guesses.

The Actor reads the search results YouTube shows any logged-out visitor, without logging in, without cookies and without bypassing consent or bot checks. It does not check robots.txt, and YouTube’s robots.txt disallows the /results and /youtubei/ paths of the search page and its endpoint. It returns no comments and no data about commenters or viewers. You are responsible for how you use the data under YouTube’s terms and the law (for example copyright and GDPR).

Yes. Connect Apify’s MCP server as shown in MCP, and the agent can call the Actor as a tool.

See how it compares with other youtube search result scrapers on price, users and run success, from Apify Store data. Need a field or site behaviour that isn’t covered? Open an issue on the Actor page.