# YouTube Transcript API

> Retrieve transcript from YouTube with a single API request.

- Request: `GET https://fetchgoblin.com/api/data/v1/youtube/video/transcript`
- Cost: 1 credit per successful request. Failed requests are not charged. Supports `cache_max_age` for zero-credit cached responses.
- Authentication: `x-api-key` header
- HTML reference: https://fetchgoblin.com/docs/get-v1-youtube-video-transcript
- MCP: call tool `call_endpoint` with `endpoint_id: "get-v1-youtube-video-transcript"` at https://fetchgoblin.com/mcp

## Query parameters

| Parameter | Required | Type | Description |
| --- | --- | --- | --- |
| `url` | yes | string | YouTube video or short URL. Example: `https://www.youtube.com/watch?v=bjVIDXPP7Uk` |
| `language` | no | string | Language code, ie 'en', 'es', 'fr' or 'en-US'. Overrides the default track selection unless original_audio=true. If omitted, prefers captions matching the original spoken language when YouTube identifies the original audio. If that metadata is unavailable or ambiguous, prefers an auto-generated caption, otherwise the first caption track. If the requested or identified original language has no matching captions, the transcript will be null and no credits are charged. Example: `en` |
| `original_audio` | no | boolean | Set to true to return captions only in the original spoken language identified by YouTube. Takes precedence over language. If the original audio cannot be reliably identified or has no matching captions, transcript, transcript_only_text, and language are null and no credits are charged. No extra lookup or credit cost; a returned transcript costs the usual 1 credit. Omit or set to false for the existing default selection. Example: `true` |
| `cache_max_age` | no | enum: 1d, 3d, 7d, 14d, 30d | If we have a response in the cache that is this many days old or newer, return the cached response (0 credits, with "cached": true and a "cached_at" timestamp). Otherwise, scrape a live result (1 credit). [See the Caching page for details.](https://fetchgoblin.com/docs#credits) Example: `7d` |

## Example request

```sh
curl --request GET 'https://fetchgoblin.com/api/data/v1/youtube/video/transcript?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbjVIDXPP7Uk' \
  --header "x-api-key: $FETCHGOBLIN_API_KEY"
```

## Example response

Some platform fields may be absent or null. Every response also includes `credits_charged`, `credits_remaining` and `request_id`.

```json
{
  "success": true,
  "videoId": "bjVIDXPP7Uk",
  "type": "video",
  "url": "https://www.youtube.com/watch?v=bjVIDXPP7Uk",
  "transcript": [
    {
      "text": "welcome back to the hell farm and the",
      "startMs": "160",
      "endMs": "1920",
      "startTimeText": "0:00"
    }
  ],
  "transcript_only_text": "welcome back to the hell farm and the backyard trails we built these jumps two years ago and last year we just kind of rebuilt them and this year......",
  "language": "English",
  "credits_charged": 1,
  "credits_remaining": 1000,
  "request_id": "00000000-0000-4000-8000-000000000000"
}
```
