Transcript — Getting Started
Fetch YouTube transcripts without an API key
What is the transcript module?
Lyra SDK includes a built-in module for fetching YouTube video transcripts. Unlike the core SDK (which uses the YouTube Data API v3), the transcript module accesses YouTube's internal Innertube API directly.
Key differences from the core SDK:
| Feature | Core SDK (yt()) | Transcript module |
|---|---|---|
| API key required | Yes | No |
| Quota consumption | Yes | No |
| Import path | lyra-sdk | lyra-sdk/transcript |
| Data source | YouTube Data API v3 | YouTube Innertube API |
| What you get | Video/channel/playlist info | Captions/transcript text |
Installation
The transcript module is included in lyra-sdk — no separate install needed:
npm install lyra-sdkpnpm add lyra-sdkyarn add lyra-sdkbun add lyra-sdkYour first transcript
import { transcribeVideo } from 'lyra-sdk/transcript'
const lines = await transcribeVideo('dQw4w9WgXcQ')
for (const line of lines) {
console.log(`[${line.offset}s] ${line.text}`)
}No API key, no yt() client, no configuration needed. Just import and call.
Fetch a specific language
const lines = await transcribeVideo('dQw4w9WgXcQ', { lang: 'es' })To see what languages are available:
import { listCaptionTracks } from 'lyra-sdk/transcript'
const tracks = await listCaptionTracks('dQw4w9WgXcQ')
// [{ languageCode: 'en', languageName: 'English', isAutoGenerated: true }, ...]Get video metadata alongside transcript
const result = await transcribeVideo('dQw4w9WgXcQ', { includeMeta: true })
console.log(result.meta.title) // "Rick Astley - Never Gonna Give You Up"
console.log(result.meta.author) // "Rick Astley"
console.log(result.meta.views) // 1600000000
console.log(result.lines.length) // 61Output as SRT or VTT
import { transcribeVideo, toSRT, toVTT, toPlainText } from 'lyra-sdk/transcript'
const lines = await transcribeVideo('dQw4w9WgXcQ')
// SubRip format (.srt)
const srt = toSRT(lines)
// WebVTT format (.vtt)
const vtt = toVTT(lines)
// Plain text with custom separator
const text = toPlainText(lines, ' ')Custom networking
Custom User-Agent
const lines = await transcribeVideo('dQw4w9WgXcQ', {
userAgent: 'MyApp/1.0',
})HTTP mode (no TLS)
const lines = await transcribeVideo('dQw4w9WgXcQ', {
useHttp: true,
})useHttp: true disables HTTPS. Not recommended for production use.
Proxy via custom fetch
const lines = await transcribeVideo('dQw4w9WgXcQ', {
customFetch: async (url, init) => {
return fetch(`https://my-proxy.com/fetch?url=${encodeURIComponent(url)}`, init)
},
})AbortSignal
const controller = new AbortController()
setTimeout(() => controller.abort(), 10000) // 10s timeout
const lines = await transcribeVideo('dQw4w9WgXcQ', {
signal: controller.signal,
})Reusable client
For multiple requests with shared configuration, use TranscriptClient:
import { TranscriptClient, InMemoryCache } from 'lyra-sdk/transcript'
const client = new TranscriptClient({
lang: 'en',
retries: 2,
retryDelay: 500,
cache: new InMemoryCache(),
})
// All calls inherit the config above
const lines1 = await client.transcribe('dQw4w9WgXcQ') // cold fetch + cached
const lines2 = await client.transcribe('dQw4w9WgXcQ') // cache hit
const tracks = await client.availableTracks('jNQXAC9IVRw') // new videoNext steps
Transcript API
Full API reference for every function, type, and option.
Batch Transcript
Fetch transcripts for entire playlists.
Caching
InMemoryCache, FsCache, and custom cache backends.
Retry
Exponential backoff and AbortSignal integration.
Architecture
How the transcript module works internally.
Batch Guide
Concurrency tuning, caching, and partial failures.