YouTube2Text API Usage Guide
YouTube2Text is a utility for extracting bare text transcriptions from YouTube videos (without subtitle timecodes and any other metadata) for analytics, insights, summaries, content generation, and other text processing applications.
Getting Started
To get started quickly, you can obtain a demo API key by visiting https://api.youtube2text.org. However, demo keys rotate frequently and have limited usage quotas. For production use or regular usage, consider subscribing to one of the available plans for a stable, dedicated API key with higher quotas.
Direct API Usage
The YouTube2Text API is available at https://api.youtube2text.org. The primary endpoint for transcription is /transcribe.
Basic CURL Request
curl -X POST https://api.youtube2text.org/transcribe \ -H "Content-Type: application/json" \ -H "x-api-key: YT2TEXT_API_KEY" \ -d '{ "url": "https://www.youtube.com/watch?v=VIDEO_ID" }'
Input Parameters
url (required): The full YouTube video URL; maxChars (optional): Maximum characters to return (defaults to 150,000)
Response Structure
Success Response (200)
{ "result": { "videoId": "VIDEO_ID", "title": "Video Title", "pubDate": "2025-06-30T08:45:04-07:00", "content": "The full video transcription text without timestamps...", "contentSize": 12345, "truncated": false } }
Error Response (400/401/404/429/500)
{ "error": { "code": "ERROR_CODE", "message": "Error description", "status": 400, "retryAfterSeconds": 3600, "details": "Additional error details" } }
Response Codes
- 200: Success - transcription retrieved
- 400: Bad Request - invalid URL or validation error
- 401: Unauthorized - invalid or missing API key
- 404: Not Found - video not found or transcript unavailable
- 429: Rate Limited - quota exceeded or too many requests
- 500: Internal Server Error - server-side issue
Error Codes
- VALIDATION_ERROR: Invalid URL or missing parameters
- UNAUTHORIZED: Invalid or expired API key
- VIDEO_NOT_FOUND: YouTube video not found
- TRANSCRIPT_UNAVAILABLE: No transcript available for this video
- INVALID_URL: Malformed YouTube URL
- RATE_LIMIT_EXCEEDED: Monthly quota exceeded or rate limited
- INTERNAL_ERROR: Server-side error
MCP Integration
YouTube2Text supports Model Context Protocol (MCP) for seamless integration with various AI models.
Anthropic Claude
import anthropic from anthropic.types.beta import BetaRequestMCPServerURLDefinitionParam, BetaMessageParam default_key = "ANTHROPIC_API_KEY" client = anthropic.Anthropic(api_key=default_key) server = BetaRequestMCPServerURLDefinitionParam( name="youtube2text", type="url", url="https://api.youtube2text.org/mcp", authorization_token="YT2TEXT_API_KEY" ) prompt_message = BetaMessageParam(role="user", content="Please use the tools from the remote MCP server to help me. Provide the transcription of https://www.youtube.com/watch?v=DCv5p_eJTlU") response = client.beta.messages.create( model="claude-sonnet-4-20250514", max_tokens=10000, messages=[prompt_message], # Direct MCP server connection - no manual tool definition needed! mcp_servers=[server], # Required beta header for MCP connector extra_headers={ "anthropic-beta": "mcp-client-2025-04-04", } ) print(response.content)
OpenAI
from openai import OpenAI from openai.types.responses.tool_param import Mcp import os os.environ["OPENAI_API_KEY"] = "OPENAI_API_KEY" client = OpenAI() youtube_transcribe_mcp = Mcp( type="mcp", server_label="youtube2text", server_url="https://api.youtube2text.org/mcp", require_approval="never", headers={"Authorization": "Bearer YT2TEXT_API_KEY"} ) resp = client.responses.create( model="gpt-4.1", tools=[youtube_transcribe_mcp], input="Please use the tools from the remote MCP server to help me. Provide the transcription of https://www.youtube.com/watch?v=DCv5p_eJTlU", ) print(resp.output_text)
Google Gemini
import google.generativeai as genai import requests genai.configure(api_key="GEMINI_API_KEY") YOUTUBE_TRANSCRIPT_API_URL = "https://api.youtube2text.org/mcp" YOUTUBE_TRANSCRIPT_API_TOKEN = "YT2TEXT_API_KEY" # Define the External Tool (Function) def get_youtube_transcription(video_url: str): """ Retrieves the transcription of a YouTube video from a given URL. Args: video_url: The full URL of the YouTube video. """ headers = { "Content-Type": "application/json", "Authorization": f"Bearer {YOUTUBE_TRANSCRIPT_API_TOKEN}" } payload = {"url": video_url} try: response = requests.post(YOUTUBE_TRANSCRIPT_API_URL, headers=headers, json=payload) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: return {"error": str(e)} # Set up the Gemini Model with the Tool model = genai.GenerativeModel( model_name='gemini-2.5-flash', tools=[get_youtube_transcription] ) # Start a Chat Session and Send the Prompt chat = model.start_chat(enable_automatic_function_calling=True) prompt = "Please provide the transcription of https://www.youtube.com/watch?v=DCv5p_eJTlU" response = chat.send_message(prompt) print(response.text)
Automation Platform Integration
Zapier Integration
YouTube2Text can be integrated with Zapier through MCP connections. Zapier's AI Actions feature supports MCP servers, allowing you to create automated workflows that trigger video transcriptions. Search for "Zapier MCP integration" or "Zapier AI Actions MCP" in the Zapier documentation to learn how to connect external MCP servers like YouTube2Text to your workflows.
n8n Integration
n8n supports MCP integration through custom nodes and HTTP request nodes. You can connect YouTube2Text's MCP endpoint to n8n workflows for automated video processing pipelines. Search for "n8n MCP integration" or "n8n HTTP Request node MCP" in the n8n community documentation to find detailed setup instructions for connecting MCP servers to your automation workflows.
Additional Examples
For more implementation examples, advanced usage patterns, and integration guides, visit the project repository for comprehensive documentation and code samples.