HomeBlog

YouTube2Text API 사용 가이드

YouTube2Text는 분석, 인사이트, 요약, 콘텐츠 생성 및 기타 텍스트 처리 응용 프로그램을 위해 YouTube 비디오에서 순수 텍스트 전사(자막 시간 코드 및 기타 메타데이터 없이)를 추출하는 유틸리티입니다.

시작하기

빠르게 시작하려면 https://api.youtube2text.org를 방문하여 데모 API 키를 얻을 수 있습니다. 그러나 데모 키는 자주 순환되며 사용량 할당량이 제한되어 있습니다. 프로덕션 사용 또는 정기적인 사용의 경우, 더 높은 할당량을 가진 안정적이고 전용 API 키를 위해 사용 가능한 플랜 중 하나를 구독하는 것을 고려하십시오.

직접 API 사용

YouTube2Text API는 https://api.youtube2text.org에서 사용할 수 있습니다. 전사를 위한 주요 엔드포인트는 /transcribe입니다.

기본 CURL 요청

Basic API Call
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"
  }'

입력 매개변수

url (필수): 전체 YouTube 비디오 URL; maxChars (선택): 반환할 최대 문자 수 (기본값 150,000)

응답 구조

성공 응답 (200)

Success Response
{
  "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
  }
}

오류 응답 (400/401/404/429/500)

Error Response
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Error description",
    "status": 400,
    "retryAfterSeconds": 3600,
    "details": "Additional error details"
  }
}

응답 코드

오류 코드

MCP 통합

YouTube2Text는 다양한 AI 모델과의 원활한 통합을 위해 모델 컨텍스트 프로토콜(MCP)을 지원합니다.

Anthropic Claude

Claude MCP Integration
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

OpenAI MCP Integration
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

Gemini Integration
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)

자동화 플랫폼 통합

Zapier 통합

YouTube2Text는 MCP 연결을 통해 Zapier와 통합될 수 있습니다. Zapier의 AI Actions 기능은 MCP 서버를 지원하여 비디오 전사를 트리거하는 자동화된 워크플로를 생성할 수 있습니다.

n8n 통합

n8n은 사용자 정의 노드와 HTTP 요청 노드를 통해 MCP 통합을 지원합니다. YouTube2Text의 MCP 엔드포인트를 n8n 워크플로에 연결하여 자동화된 비디오 처리 파이프라인을 구현할 수 있습니다.

추가 예제

더 많은 구현 예제, 고급 사용 패턴 및 통합 가이드는 포괄적인 문서와 코드 샘플을 위해 프로젝트 저장소를 방문하십시오.