YouTube Transcript API
@minhleathvn
A MCP server helps to transcript a youtube video
Overview
What is YouTube Transcript API?
YouTube Transcript API is a Python service that provides APIs to fetch and transcribe YouTube video content. It supports both a REST API (Flask) and an MCP server implementation, making it suitable for developers who need to extract video transcripts programmatically.
How to use YouTube Transcript API?
Install dependencies with pip install -r requirements.txt, then start the MCP server with python apps/mcp_server.py. Use the exposed MCP tools such as get_transcript(video_id, language) and extract_transcript(video_id, language) to retrieve transcripts. Alternatively, start the Flask server with python apps/flask_server.py and call its REST endpoints.
Key features of YouTube Transcript API
- Fetch transcripts in multiple languages (English, Vietnamese)
- Auto-detect and use available transcripts
- Fallback to audio transcription via Whisper when captions are missing
- Support for both REST API and MCP server interfaces
- Automatic language detection with langdetect
- Temporary file cleanup after audio processing
Use cases of YouTube Transcript API
- Get video transcripts for content analysis or subtitle generation
- Automatically fall back to Whisper‑based transcription when no captions exist
- Search for YouTube videos and extract their transcripts in one workflow
- Integrate transcript extraction into MCP‑compatible tools or Flask web apps
FAQ from YouTube Transcript API
Which languages are supported for transcripts?
English (en) and Vietnamese (vi) are explicitly supported, and the system can auto‑detect other languages using the langdetect library.
How can I get a transcript if no captions are available?
The API falls back to downloading the audio and transcribing it using Whisper (via the extract_transcript tool or endpoint).
What are the main dependencies?
Key dependencies include youtube-transcript-api, pytube, whisper, torch, langdetect, flask (for the REST API), and mcp (for the MCP server).
How do I run the MCP server versus the REST API?
Run python apps/mcp_server.py for the MCP server, or python apps/flask_server.py for the Flask‑based REST API. Both are located under the apps/ directory.
Are there health check or video info endpoints?
Yes, the Flask server exposes /health and /video/info?video_id=<id> endpoints. The MCP server provides search_youtube_video(query) to find videos.