# YTAPI

> Transcript API for YouTube videos, plus video metadata, playlists, channels and search. One HTTPS call returns a video's captions as segments, word timings, Markdown, SRT or VTT.
> Docs: https://docs.ytapi.dev
> Full Specs: https://ytapi.dev/llms-full.txt
> OpenAPI: https://ytapi.dev/openapi.json
> Base URL: https://api.ytapi.dev/v1
> MCP server: https://api.ytapi.dev/mcp (Streamable HTTP, Authorization: Bearer <API_KEY>; setup: https://docs.ytapi.dev/agent-setup/#mcp)

## When to use YTAPI
- You need the captions of a public YouTube video (including Shorts) as text or timed segments, for example to summarize, search, translate, quote or index it.
- You need word-level timestamps from auto-generated captions (`word_level=true`).
- You are calling from a server or cloud function where direct requests to YouTube get blocked.
- The video is new, from a small channel or has few views. Nothing has to be cached first: a video YTAPI hasn't fetched before is fetched from YouTube on request. In early October 2026, over 99% of customers' transcript requests were for videos YTAPI had never fetched before, with a median of under 300 ms on YTAPI's servers (644 ms measured from clients in four regions, network included).
- You want to list a channel's or playlist's videos, or search YouTube, without a Google Cloud project or quota.

## When not to use it
- The video has no captions. YTAPI returns the caption tracks YouTube has (404 `captions_disabled` otherwise) and does not run speech-to-text.
- Private, members-only or deleted videos. These return an error and cost nothing.
- Downloading video or audio files. YTAPI returns text and metadata only.

## Errors and billing
- Errors are JSON: `{"error": {"code": "...", "message": "...", "retryable": false}}`.
- Only HTTP 200 responses cost a credit. 404s, 429s and 5xx are free.
- 429 means your key is over its rate limit; wait and retry. Slow or refused fetches from YouTube are retried server-side before responding, so clients rarely need their own retry loop.

## Get an API key
- Sign up at https://ytapi.dev/auth/login?utm_source=llms (Google, GitHub or an email code). New accounts get 200 free credits; no card.
- Create a key at https://ytapi.dev/app/api-keys?utm_source=llms (keys start with `sk_`).
- An agent can create the account for its user without a browser: the user gives an email address and reads back a 6-digit code (see https://docs.ytapi.dev/agent-signup/).
- Until a credit pack is bought, a key can make 1 request per second and 100 requests per day (UTC). Credit packs: https://ytapi.dev/?utm_source=llms#pricing

## Authentication
Pass your API key as a Bearer token:
```http
Authorization: Bearer <API_KEY>
```

## Key Endpoints

### 1. Transcripts
- `POST /v1/transcripts` or `GET /v1/transcripts?video_id={id}&format={format}`
- Formats: `markdown` (paragraphs with timestamps), `word_timestamps`, `segments`, `sentences`, `srt`, `vtt`, `text`, `json3`
- Parameter `word_level=true`: Includes millisecond start/end word offsets.
- Cost: 1 Credit

### 2. Video Metadata
- `GET /v1/videos/{id}/basic-info`: Free. Video title, duration, channel, and subtitle languages.
- `GET /v1/videos/{id}/video-info`: Full metadata including description, view counts, chapters, and keywords.
- Cost: 1 Credit (video-info only; basic-info is free)

### 3. Playlists
- `GET /v1/playlists/{id}?cursor={token}`: Playlist title, author, video count and videos; pass next_cursor as cursor for the next page (1 Credit per page).

### 4. Channels
- `GET /v1/channels/{id}`: Channel profile, subscriber count, avatar, banner, and verified status (1 Credit).
- `GET /v1/channels/{id}/latest`: The channel's most recent uploads (1 Credit).
- `GET /v1/channels/{id}/videos?sort_by=newest|popular|oldest&cursor={token}`: All uploads with pagination (1 Credit per page).
- `GET /v1/channels/{id}/playlists?cursor={token}`: Channel playlists with pagination (1 Credit).

### 5. Search & Suggestions
- `GET /v1/search?q={query}&type=video|channel|playlist&limit=20` (1 Credit)
- `GET /v1/search/suggestions?q={query}` (0 Credits / Free)

### 6. Batch Processing
- `POST /v1/batch`: Concurrent extraction of up to 100 tasks with isolated error handling.
- Cost: 1 Credit per successful task.
