LlamaIndex YouTube transcript data loader & video RAG
LlamaIndex is the premier data framework for LLM indexing and retrieval. Here is how to create a timestamp-aware YouTube video reader, build VectorStoreIndex over entire channels, and cite video evidence.
Building a custom LlamaIndex reader with VidWords API
LlamaIndex's built-in YoutubeTranscriptReader breaks on cloud hosts due to IP rate limits. You can build a resilient custom reader with the VidWords REST API:
import requests
from llama_index.core.readers.base import BaseReader
from llama_index.core.schema import Document
from llama_index.core import VectorStoreIndex
class VidWordsYouTubeReader(BaseReader):
def __init__(self, api_token: str):
self.api_token = api_token
def load_data(self, video_ids: list[str]) -> list[Document]:
url = "https://vidwords.com/api/transcripts"
headers = {"Authorization": f"Basic {self.api_token}"}
res = requests.post(url, json={"ids": video_ids}, headers=headers)
res.raise_for_status()
docs = []
for vid in res.json()["results"]:
video_id = vid["id"]
title = vid.get("title", "")
# Combine segments while preserving timestamp metadata in nodes
full_text = " ".join([seg["text"] for seg in vid["segments"]])
doc = Document(
text=full_text,
metadata={
"video_id": video_id,
"title": title,
"url": f"https://youtube.com/watch?v={video_id}",
}
)
docs.append(doc)
return docs
# Load and index
reader = VidWordsYouTubeReader(api_token="YOUR_API_TOKEN")
documents = reader.load_data(["dQw4w9WgXcQ"])
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("What are the main key takeaways discussed in this video?")
print(response)
Or let agents use the VidWords MCP Server directly
If you are building autonomous agents with LlamaIndex or Claude Code, you do not even need to write indexing code. Simply connect the hosted VidWords Model Context Protocol (MCP) server so your assistant can search across channels with search_transcript on demand.