<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TranscriptYT Blog]]></title><description><![CDATA[TranscriptYT Blog]]></description><link>https://transcriptyt.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 28 Oct 2026 18:59:47 GMT</lastBuildDate><atom:link href="https://transcriptyt.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[YouTube Transcripts for RAG: Load Videos into LangChain and Vector Search]]></title><description><![CDATA[Video is full of knowledge that never reaches your RAG pipeline because it isn't text. Transcripts fix that, and timestamped segments let every answer link…]]></description><link>https://transcriptyt.hashnode.dev/youtube-transcripts-for-rag-load-videos-into-langchain-and-vector-search</link><guid isPermaLink="true">https://transcriptyt.hashnode.dev/youtube-transcripts-for-rag-load-videos-into-langchain-and-vector-search</guid><category><![CDATA[RAG ]]></category><category><![CDATA[langchain]]></category><dc:creator><![CDATA[Aadit]]></dc:creator><pubDate>Mon, 12 Oct 2026 07:39:11 GMT</pubDate><content:encoded><![CDATA[<p>Video is full of knowledge that never reaches your RAG pipeline because it isn't text. Transcripts fix that, and timestamped segments let every answer link to the exact moment it came from. This guide loads YouTube transcripts into LangChain documents ready for any vector store.</p>
<h2>Fetch paragraph-sized chunks with timestamps</h2>
<p>Raw caption cues are a few words each, too small to embed well. Request JSON with <code>paragraphs=true</code> and the API merges cues into paragraph-length segments on natural speech pauses. Each segment keeps its start time.</p>
<pre><code class="language-python">import os
import requests

def fetch_segments(video: str) -&gt; dict:
    res = requests.get(
        "https://transcript-yt.com/v1/transcript",
        params={"url": video, "paragraphs": "true"},
        headers={"Authorization": f"Bearer {os.environ['TRANSCRIPTYT_KEY']}"},
        timeout=120,
    )
    res.raise_for_status()
    return res.json()
</code></pre>
<h2>Turn segments into LangChain documents</h2>
<p>Store the video ID, title, and start time as metadata. The start time becomes a deep link, so a retrieved chunk can cite <code>youtube.com/watch?v=ID&amp;t=SECONDS</code>.</p>
<pre><code class="language-python">from langchain_core.documents import Document

def load_youtube(video: str) -&gt; list[Document]:
    data = fetch_segments(video)
    return [
        Document(
            page_content=seg["text"],
            metadata={
                "video_id": data["videoId"],
                "title": data["title"],
                "start": seg["start"],
                "source": f"https://www.youtube.com/watch?v={data['videoId']}&amp;t={int(seg['start'])}s",
            },
        )
        for seg in data["segments"]
    ]

docs = load_youtube("https://youtu.be/5f3Pn-N6yLc")
# vector_store.add_documents(docs)
</code></pre>
<h2>Index a whole channel or playlist</h2>
<p>Loop over video IDs and load each one. Results are cached, so re-indexing a video you've already fetched is fast. Failed requests are never billed, and you can skip videos that return <code>NO_CAPTIONS</code> or <code>VIDEO_UNAVAILABLE</code>.</p>
<h2>Tips for better retrieval</h2>
<p>A few choices make a large difference in answer quality:</p>
<ul>
<li><p>Prepend the video title to each chunk before embedding so short chunks keep their context.</p>
</li>
<li><p>Use <code>translate_to</code> to index multilingual videos in one language, or store the language as metadata and filter on it.</p>
</li>
<li><p>Return the source link with every answer so users can jump to the moment in the video and verify it.</p>
</li>
</ul>
<p>I built TranscriptYT, so I'm biased. The full docs are at <a href="https://transcript-yt.com/docs">https://transcript-yt.com/docs</a>.</p>
]]></content:encoded></item></channel></rss>