Registry / productivity / youtube-transcript

youtube-transcript

JSON →
library1.3.1jsnpmunverified

Unofficial YouTube transcript fetcher for Node.js (v1.3.1). Extracts captions/subtitles from YouTube videos using undocumented internal APIs. Published as an ESM-only package with TypeScript types; requires Node >=18. Simple API: one function `fetchTranscript`. No dependencies. May break without notice if YouTube changes its API. Less feature-rich than youtubei.js or ytdl-core but minimal and focused on transcripts alone. Sporadic releases.

npm install youtube-transcript
INSTALL
IMPORT
SIG · YOUTUBE-TRANSCRIPT
Y
youtube-transcript
productivityjavascriptv1.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetchTranscript
import { fetchTranscript } from 'youtube-transcript'
const fetchTranscript = require('youtube-transcript')
ESM-only since v1; CommonJS require will fail with ERR_REQUIRE_ESM.
TranscriptResponse
import { TranscriptResponse } from 'youtube-transcript'
import TranscriptResponse from 'youtube-transcript'
It is a named type export, not default. TypeScript required for type import.
TranscriptConfig
import { TranscriptConfig } from 'youtube-transcript'
import type { TranscriptConfig } from 'youtube-transcript'
Can be imported as a type if not used at runtime, but library exports it as a value (interface) for options.

Fetches English transcript for a sample video and logs the array of text segments with duration and offset.

import { fetchTranscript } from 'youtube-transcript'; const videoId = 'dQw4w9WgXcQ'; const language = 'en'; try { const transcript = await fetchTranscript(videoId, { lang: language }); console.log(transcript); } catch (error) { console.error('Failed to fetch transcript:', error.message); }
Debug
Known issues
deprecatedThe package uses an unofficial YouTube API that may break without notice.
fix
Monitor the repo for updates; consider youtubei.js or ytdl-core for more stable YouTube access.
affects: <=1.3.1
gotchaRequires Node.js 18 or later; older versions will fail to import.
fix
Upgrade Node.js to >=18 or use a build tool that transforms ESM.
affects: >=1.0.0
gotchaOnly ESM import works; CommonJS require throws ERR_REQUIRE_ESM.
fix
Use dynamic import: `const { fetchTranscript } = await import('youtube-transcript');` in CJS projects.
affects: >=1.0.0
gotchaVideo must have captions/subtitles enabled; otherwise fetchTranscript rejects.
fix
Check if the video has captions before calling, or handle the error gracefully.
affects: >=1.0.0
gotchaThe library does not support YouTube shorts or live streams reliably.
fix
Test with those URL formats; may require workaround or alternative library.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using CommonJS require() to import an ESM-only package.
fix
Change to import statement or use dynamic import: await import('youtube-transcript')
Error: No transcript found for this video
Video does not have captions or the provided language is not available.
fix
Verify video has captions and specify a valid language code (e.g., 'en').
TypeError: fetchTranscript is not a function
Incorrect import style (e.g., default import instead of named import).
fix
Use { fetchTranscript } from 'youtube-transcript'
Error: Request failed with status code 404
Invalid video ID or URL, or YouTube API endpoint changed.
fix
Double-check the video ID/URL; if valid, API may have changed – check for library updates.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
40 hits · last 30 days
node
32
Amazon
1
OpenAI (training)
1
Resources
youtube-transcript — npm install youtube-transcript · libregistry