# YouTube transcript API and MCP server

Turn an available caption track from a public YouTube video into timestamped plain text. Pass a video URL or ID to the REST API or the MCP tool. The YouTube tool retrieves transcripts only.

## YouTube transcript API pricing

A transcript costs $0.01 per call through either `POST /api/v1/youtube/get` or `glim_youtube_get`. Use a glim.sh API key or [pay from a wallet](https://glim.sh/docs/payments.md).

## Get a transcript from a video URL

For REST, pass the URL or its 11-character ID in `video_id`. The response includes the caption language, the caption source in `origin`, and the cleaned text in `transcript` when it fits inline.

**Get a transcript with REST**

```
curl -X POST https://glim.sh/api/v1/youtube/get \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"video_id":"https://youtu.be/LCEmiRjPEtQ","language_code":"en"}'
```

For MCP, pass the same video in `ref`. The default output is text, with the transcript after a short metadata header. Use `json` when your agent needs the download link, byte size and expiry time on every result.

**Get transcript text and metadata with MCP (tools/call parameters)**

```
{
  "name": "glim_youtube_get",
  "arguments": { "ref": "https://youtu.be/LCEmiRjPEtQ", "format": "json" }
}
```

## Caption languages and sources

English (`en`) is the default. Set `language_code` to request another language, such as `de`. glim.sh looks for uploader-provided captions first. If that track is missing, it tries auto-generated captions in the requested language. To request those directly, set `origin` to `auto_generated`.

## Read or download a long transcript

The inline limit is 40,000 characters of cleaned text. Above that limit, follow `download_url` for the full transcript. REST and MCP JSON also return `length_chars`, `size_bytes` and `expires_at`. The download link is valid for one hour.

To get just the metadata and link over REST, set `format` to `url`. On MCP, both `text` and `json` include the transcript when it fits.

## Connect the YouTube MCP server

Use `https://glim.sh/mcp` as the server URL. To give your agent only the transcript tool, connect to `https://glim.sh/mcp?tools=glim_youtube_get`. See the [MCP quickstart](https://glim.sh/docs/quickstart.md) for client configuration.

- **Claude Code**: `claude mcp add -s user -t http glim https://glim.sh/mcp`
- **Codex**: `codex mcp add glim --url https://glim.sh/mcp`
- **OpenCode**: `opencode mcp add`
  Interactive: choose remote, paste https://glim.sh/mcp
- **Wallet**: `npx x402-proxy mcp add glim https://glim.sh/mcp`
  No account: your agent pays per call in USDC (x402) from a local wallet, auto-generated on first run.

## Compare ways to retrieve YouTube captions

- The [YouTube Data API caption download](https://developers.google.com/youtube/v3/docs/captions/download?hl=en) requires permission to edit the video.
- The [youtube-transcript-api Python library](https://github.com/jdepoix/youtube-transcript-api) lets you fetch a transcript by video ID from your Python program.
- Use glim.sh for a hosted HTTPS endpoint or an MCP tool. Supply a public video URL with available captions and read the resulting text.

## Good to know

- The transcript strips caption tags and removes lines repeated across consecutive cues. Timestamps such as `[2:30]` mark passages roughly 30 seconds apart so you can locate a quote.
- glim.sh caches transcript metadata for seven days by video ID, language and caption source. Call again for a fresh download link after yours expires.

## FAQ

### What if a video has no captions?

The tool reads existing caption tracks. If it cannot find one in the requested language, REST returns HTTP `404` and MCP returns a tool error. Try a language available on the video. The tool does not transcribe the audio.

### Can I search for videos with the YouTube MCP tool?

No. Start with a video URL or ID. Video search, uploads and channel statistics are outside the scope of this tool.

---

## All docs pages


**Get started**

- [Introduction](https://glim.sh/docs.md)
- [MCP quickstart](https://glim.sh/docs/quickstart.md)
- [REST API quickstart](https://glim.sh/docs/quickstart-rest.md)
- [JavaScript quickstart](https://glim.sh/docs/quickstart-javascript.md)
- [Python quickstart](https://glim.sh/docs/quickstart-python.md)
- [Payments & auth](https://glim.sh/docs/payments.md)
- [MPP (Tempo)](https://glim.sh/docs/mpp.md)

**Tools**

- [Twitter / X](https://glim.sh/docs/twitter.md)
- [Reddit](https://glim.sh/docs/reddit.md)
- [Web](https://glim.sh/docs/web.md)
- [GitHub](https://glim.sh/docs/github.md)
- [Amazon](https://glim.sh/docs/amazon.md)
- [YouTube](https://glim.sh/docs/youtube.md)
- [Telegram](https://glim.sh/docs/telegram.md)

**Reference**

- [Changelog](https://glim.sh/docs/changelog.md)
- [API reference](https://glim.sh/docs/api-reference)
- [OpenAPI spec](https://glim.sh/openapi.json)
