YouTube transcript API
Use when you need what is said in a YouTube video: full transcript text plus timestamped segments, in the requested language (manual captions preferred, auto-generated as fallback, optional translation). $0.005 per successful call; videos without captions and errors are not charged.
Parameters
GET https://scrapemole-api-mainnet.scrapemole.workers.dev/v1/youtube/transcript
| Name | Required | Description |
|---|---|---|
video | yes | YouTube video URL or 11-character video ID. |
lang | no | Preferred language code(s), comma-separated, in order of preference. Default: en |
translate | no | Translate the transcript into this language code if the video lacks it. |
segments | no | Include timestamped segments. One of: true falseDefault: true |
Call it
// npm i @x402/fetch @x402/evm viem import { wrapFetchWithPaymentFromConfig, decodePaymentResponseHeader } from '@x402/fetch'; import { ExactEvmScheme } from '@x402/evm'; import { privateKeyToAccount } from 'viem/accounts'; // Your agent's own wallet, holding a little USDC on Base. No ScrapeMole account or API key. const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY); const pay = wrapFetchWithPaymentFromConfig(fetch, { schemes: [{ network: 'eip155:8453', client: new ExactEvmScheme(account) }], }); // On 402 the wrapper signs the USDC authorization and retries once. const res = await pay('https://scrapemole-api-mainnet.scrapemole.workers.dev/v1/youtube/transcript?video=aircAruvnKk&segments=false'); console.log(res.status, await res.json()); // Settled only on 200; the receipt (tx hash) is in the PAYMENT-RESPONSE header. if (res.ok) console.log(decodePaymentResponseHeader(res.headers.get('payment-response')));
# 1. Unpaid: returns 402 with price $0.005 and the payTo address curl -i "https://scrapemole-api-mainnet.scrapemole.workers.dev/v1/youtube/transcript?video=aircAruvnKk&segments=false" # 2. Paid: repeat the request with a PAYMENT-SIGNATURE header (a signed USDC # authorization for the quoted amount). An x402 client does this for you: # see the JavaScript tab.
Also available as the MCP tool youtube_transcript on https://scrapemole-api-mainnet.scrapemole.workers.dev/mcp (x402 MCP transport, same price).
Example response
A real response from this endpoint (arrays and long strings trimmed here).
{
"videoId": "aircAruvnKk",
"url": "https://www.youtube.com/watch?v=aircAruvnKk",
"title": "But what is a neural network? | Deep learning chapter 1",
"channelName": "3Blue1Brown",
"channelId": "UCYO_jab_esuFRV4b17AJtAw",
"channelUrl": "https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw",
"durationSeconds": 1120,
"viewCount": 24708996,
"description": "What are the neurons, why are there layers, and what is the math underlying it?\nHelp fund future projects: https://www.patreon.com/3blue1…",
"keywords": [],
"thumbnailUrl": "https://i.ytimg.com/vi/aircAruvnKk/sddefault.jpg",
"isLive": false,
"publishDate": "2017-10-05",
"publishDateText": "Oct 5, 2017",
"language": "en",
"languageName": "English",
"isAutoGenerated": false,
"isTranslated": false,
"availableLanguages": [
{
"languageCode": "ar",
"languageName": "Arabic",
"isAutoGenerated": false
},
{
"languageCode": "bn",
"languageName": "Bangla",
"isAutoGenerated": false
},
"… 1 more"
],
"transcriptText": "This is a 3. It's sloppily written and rendered at an extremely low resolution of 28x28 pixels, but your brain has no trouble recognizing…",
"segments": [
{
"start": 4.22,
"duration": 1.18,
"end": 5.4,
"text": "This is a 3."
},
{
"start": 6.06,
"duration": 4.653,
"end": 10.713,
"text": "It's sloppily written and rendered at an extremely low resolution of 28x28 pixels,"
},
"… 1 more"
],
"srt": "1\n00:00:04,220 --> 00:00:05,400\nThis is a 3.\n\n2\n00:00:06,060 --> 00:00:10,713\nIt's sloppily written and rendered at an extremely low reso…",
"segmentCount": 286,
"wordCount": 3357,
"characterCount": 18430,
"transcriptSource": "IOS"
}Live test results
10/10Live calls from Cloudflare Workers (with regional retry), 11 Oct 2026 11:15 UTC
Paid end-to-end checks (Base Sepolia testnet, 11 Oct 2026 18:36 UTC)
| Call | Status | Charged | Pass |
|---|---|---|---|
unpaid /v1/youtube/transcript | 402 | price quoted | ✓ |
paid /v1/youtube/transcript?video=aircAruvnKk&segments=false | 200 | $0.005 | ✓ |
paid /v1/youtube/transcript?video=xxxxxxxxxxx (unknown video) | 404 | $0 | ✓ |
Errors
Failures return JSON like {"error": {"code": "NOT_FOUND", "message": "…", "charged": false}}. None of them are charged.
| Status / errorCode | Meaning |
|---|---|
400 INVALID_INPUT | Missing or malformed parameter. Fix the input. |
404 NOT_FOUND | The video, channel, product or term doesn't exist or isn't public. |
404 NO_DATA | It exists, but has nothing to return (for example no captions). |
503 BLOCKED | The source rate-limited us even after retries. Try again later. |
502 / 504 | Upstream error or timeout. Try again. |
402 | No or invalid payment. Pay the quoted amount and retry. |