YouTube

How to Search Within a YouTube Channel via API

Search the videos of one YouTube channel from code: the Data API search.list with channelId and its limits, a full title search, and search inside transcripts.

By FetchTranscript teamPublished 5 min read

To search inside one YouTube channel through an API, you have two honest options. The official YouTube Data API does it in one request: search.list with channelId and q, at 100 quota units per page and at most 500 results per channel. Or you list the channel's videos (with FetchTranscript, GET /v1/channels/{channel}/videos, 1 credit per 100 videos) and search them yourself: titles exhaustively, and, through the transcripts, everything that was said in the videos, down to the second. This guide shows both with working code, explains which one fits which job, and covers the related question of finding channels by keyword.

Option 1: the YouTube Data API search.list

If you have a Google Cloud project and an API key, this is the most direct route, and for a handful of searches a day it is the right one:

Shell
curl "https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCBJycsmduvYEL83R_U4JriQ&q=iphone&type=video&order=date&maxResults=50&key=YOUR_GOOGLE_API_KEY"

Each item has id.videoId and a snippet with the title, description, publication date and channel. You can sort with order (relevance, date, viewCount, rating, title), filter by date with publishedAfter and publishedBefore, and page with pageToken.

The limits are the ones to plan around:

  • 100 units per page. The default budget is 10,000 units a day, so about 100 channel searches a day for the whole project.
  • At most 500 results. Google's documentation states that a search restricted to a channel with type=video returns at most 500 videos. On a channel with 3,000 uploads, a broad query cannot reach them all.
  • Metadata only. The search matches titles, descriptions and tags as YouTube indexes them, not what is said in the videos.
  • No durations or views in search results: those need a videos.list call per page.

How the quota works and what extensions involve is explained in YouTube search API without quota limits.

Our GET /v1/search searches YouTube as a whole, like the search box: it takes q and limit (1 to 50) and returns videos, each with its channel_id. There is no channel_id parameter, and we would rather say so than suggest a workaround that half works. Adding the channel name to the query and keeping the results whose channel_id matches does find some videos, but it is best-effort: you get the channel's videos that rank in the top 50 for that query, not a search of the channel.

For a real search inside a channel, list the channel and search the list. It sounds heavier than it is: a channel of 1,000 videos is 10 calls, and once you have the list you can run as many queries as you like on it, for free, with your own matching rules.

Option 2: list the channel, then search the titles

The channel list gives every video's video_id, title, duration and view_count, newest first, Shorts optional. Fetch it once, keep it, and search it locally:

Python
import requests

API = "https://api.fetchtranscript.com/v1"
HEADERS = {"X-API-Key": "yt_your_api_key"}


def channel_videos(channel: str, include_shorts: bool = False):
    params = {"limit": 100, "include_shorts": str(include_shorts).lower()}
    while True:
        r = requests.get(f"{API}/channels/{channel}/videos", headers=HEADERS, params=params, timeout=60)
        r.raise_for_status()
        page = r.json()
        yield from page["videos"]
        if not page["has_more"] or not page["next_cursor"]:
            return
        params["cursor"] = page["next_cursor"]


def search_titles(videos: list[dict], *words: str) -> list[dict]:
    words = [w.lower() for w in words]
    return [v for v in videos if all(w in v["title"].lower() for w in words)]


videos = list(channel_videos("@mkbhd"))  # 1 credit per 100 videos
for v in search_titles(videos, "iphone", "review"):
    print(f'{v["view_count"] or 0:>12,}  https://www.youtube.com/watch?v={v["video_id"]}  {v["title"]}')

Unlike search.list, this reaches every video of the channel, however large, and you decide what a match is: all words, any word, a regular expression, or a fuzzy match with a library such as rapidfuzz. You can also sort by views or filter by duration in the same pass, which the Data API search cannot do without extra calls. Channel lists carry no descriptions and no dates; when you need them for the videos you keep, GET /v1/videos/{video_id} returns both (see YouTube video metadata).

The same in JavaScript

JavaScript
// Node 18+ as an ES module (a .mjs file, or "type": "module"), for the top-level await
const API = 'https://api.fetchtranscript.com/v1';
const headers = { 'X-API-Key': 'yt_your_api_key' };

async function channelVideos(channel) {
  const videos = [];
  let cursor = null;
  do {
    const params = new URLSearchParams({ limit: '100' });
    if (cursor) params.set('cursor', cursor);
    const res = await fetch(`${API}/channels/${encodeURIComponent(channel)}/videos?${params}`, { headers });
    if (!res.ok) throw new Error(`HTTP ${res.status}: ${(await res.json()).detail.error}`);
    const page = await res.json();
    videos.push(...page.videos);
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);
  return videos;
}

const videos = await channelVideos('@veritasium');
const hits = videos.filter((v) => /black hole/i.test(v.title));
console.table(hits.map((v) => ({ id: v.video_id, views: v.view_count, title: v.title })));

Option 3: search what is said in a channel

Titles only tell you what a video is called. The question people often really have is "where in this channel does the creator talk about X?", and no YouTube API answers it. Transcripts do. GET /v1/transcripts/{video_id} returns the captions as segments, each with text, start and duration in seconds, so every match comes with a link that opens the video at the right moment:

Python
def transcript_segments(video_id: str) -> list[dict]:
    r = requests.get(f"{API}/transcripts/{video_id}", headers=HEADERS, timeout=60)
    if r.status_code == 404:
        return []  # no captions on this video: not billed
    r.raise_for_status()
    return r.json()["segments"]


def search_channel_speech(channel: str, phrase: str, max_videos: int = 50):
    phrase = phrase.lower()
    for i, video in enumerate(channel_videos(channel)):
        if i >= max_videos:
            return
        for seg in transcript_segments(video["video_id"]):
            if phrase in seg["text"].lower():
                t = int(seg["start"])
                yield video["title"], f"https://www.youtube.com/watch?v={video['video_id']}&t={t}s", seg["text"]


for title, link, text in search_channel_speech("@veritasium", "quantum"):
    print(link, "|", title, "|", text)

Two practical notes. A phrase can be split across two caption segments, so for exact phrases search a window of two or three consecutive segments joined together. And for anything beyond one-off searches, store the transcripts once (1 credit per video, failed calls free) and index them: a full-text index for keywords, or embeddings for questions in natural language, as described in YouTube transcripts for RAG. The rate limit of 500 requests per minute lets you download a large channel in minutes.

Which option to choose

You needBest fit
A few keyword searches a day, YouTube's own rankingData API search.list with channelId
Every video of a big channel matching a title ruleChannel list + local search
Sorting or filtering by views and duration in the same stepChannel list + local search
What is said in the videos, with timestampsTranscripts
Many searches across many channels, no quotaChannel list (cached) + local search

The two approaches also combine well: Data API search for ad-hoc discovery, the channel list and transcripts for the systematic work.

Finding channels by keyword

"Channel search" sometimes means the opposite: finding the channels that cover a topic. In the Data API that is search.list with type=channel and q, again 100 units per page. With FetchTranscript, search for videos on the topic and group the results by channel; each result carries channel_id and channel_name:

Python
from collections import Counter

r = requests.get(f"{API}/search", headers=HEADERS, params={"q": "sourdough baking", "limit": 50}, timeout=30)
r.raise_for_status()
counts = Counter((v["channel_id"], v["channel_name"]) for v in r.json()["results"] if v["channel_id"])
for (cid, name), n in counts.most_common(10):
    print(n, cid, name)

Channels that appear several times in the top 50 are the ones YouTube considers relevant for the topic. Then fetch their size with GET /v1/channels/{channel_id}, as shown in how to get a YouTube channel's details, or start from the YouTube Channel API page, which you can try without an account.

Frequently asked questions

Can the YouTube API search within a specific channel?

Yes: the YouTube Data API's search.list accepts channelId together with q. It costs 100 quota units per page of up to 50 results and returns at most 500 videos for a channel.

Does FetchTranscript's search take a channel filter?

No. GET /v1/search searches all of YouTube. To search inside a channel, list its videos with GET /v1/channels/{channel}/videos and search the titles locally, or search its transcripts.

How do I search what a YouTuber says in their videos?

List the channel's videos, fetch each transcript with GET /v1/transcripts/{video_id}, and search the segments. Each segment has a start time, so a match becomes a link to that second of the video.

How much does searching a channel cost?

Listing costs 1 credit per page of up to 100 videos, so a 1,000-video channel is 10 credits, and the local searches after that are free. Transcripts cost 1 credit per video; videos without captions are not billed.

How do I find YouTube channels about a topic?

Use the Data API's search.list with type=channel, or search videos on the topic and group the results by channel_id: the channels that appear most often are the most relevant ones.

Is the channel list complete?

Yes. The cursor follows the channel's Videos tab to the end, and include_shorts=true adds the Shorts. There is no 500-result cap.

Try it on your own videos

100 free calls every month, no credit card. Then $1 per 1,000 calls, only for the calls that succeed.

← All articles