All use cases

Chat with YouTube: RAG over whole channels

A chat-with-YouTube app needs three things: every video's transcript, pieces small enough to embed, and a way to point the answer at the moment it came from. TranscriptFetch returns all three in one call, for one video or a whole channel, playlist or search.

How it works

  1. 01

    Collect the videos

    List a YouTube channel, a playlist, a TikTok or Instagram profile or a search, or hand over a whole channel as one background job.

  2. 02

    Fetch transcripts as chunks

    Ask for chunks and every transcript comes back split for an embedding model: about 500 tokens a piece by default, slightly overlapping, never cut mid-word. Each piece carries its start and end time and a link that opens the video at that moment.

  3. 03

    Embed and answer

    Put the chunks in your vector store. When a question matches a chunk, answer from its text and cite its link, so readers can jump to the exact moment.

  4. 04

    Keep it fresh

    A monitor watches the channel and sends each new upload, with its transcript and chunks, to your webhook.

Example

Python: a channel's latest videos as chunks for your vector store

python
import requests

API = "https://transcriptfetch.com/api/v2"
H = {"Authorization": "Bearer tf_live_YOUR_KEY"}

videos = requests.post(f"{API}/transcripts/channel", headers=H,
                       json={"channel": "@lexfridman", "limit": 20}).json()["data"]["videos"]

for v in videos:
    r = requests.post(f"{API}/transcripts/video", headers=H,
                      json={"video": v["url"], "chunks": True})
    if r.status_code != 200:
        continue  # 202 = long video still transcribing: poll the job, or pass callback_url
    for c in r.json()["data"]["chunks"]:
        store.add(text=c["text"], metadata={"url": c["url"], "start": c["start"], "title": v["title"]})

What you get

  • Chunks sized for embedding models (100 to 2,000 tokens, your choice), counted with OpenAI's tokenizer
  • A start time, an end time and a link to the moment on every chunk, for answers that cite their source
  • Markdown with clickable timestamps when you would rather pass whole transcripts to a long-context model
  • Whole channels as one background job, playlists and searches as paged lists, new uploads by webhook

Questions

  • How do I chat with a YouTube channel?

    Fetch the channel's transcripts with chunks turned on, embed the chunks in a vector store, and have your model answer from the closest matches. Every chunk links to the moment it came from, so the answer can cite it.

  • Do I have to chunk the transcripts myself?

    No. Send chunks: true for the defaults, or set max_tokens and overlap_tokens. The chunks are free: they repackage the transcript you already paid for.

  • Can I do this for TikTok and Instagram too?

    Yes. Profiles list the same way as YouTube channels, and the transcripts come back in the same shape. TikTok and Instagram chunks link to the post.

  • How do I keep the knowledge base up to date?

    Create a monitor on the channel or profile with transcripts on. Each new video is sent to your webhook with its transcript, and its chunks if you ask for them.

More use cases

Get a free API key

Every account gets 50 free credits a month, no card needed. Failed requests are free.