# youtube-subtitle-transcript

> A package for retrieving YouTube subtitle transcripts

Latest version **0.2.0** (published 2024-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install youtube-subtitle-transcript
pnpm add youtube-subtitle-transcript
yarn add youtube-subtitle-transcript
bun add youtube-subtitle-transcript
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2024-07-03 |
| First published | 2023-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Michael Esteban |
| Maintainers | mikeesto |
| Keywords | youtube, subtitle, transcript |

## Links

- npm: https://www.npmjs.com/package/youtube-subtitle-transcript
- Repository: https://github.com/mikeesto/youtube-subtitle-transcript
- Homepage: https://github.com/mikeesto/youtube-subtitle-transcript#readme
- Issues: https://github.com/mikeesto/youtube-subtitle-transcript/issues
- npm.io page: https://npm.io/package/youtube-subtitle-transcript

## Dependencies (1)

- [fast-xml-parser](https://npm.io/package/fast-xml-parser.md) ^4.4.0

## Recent versions

- 0.2.0 (latest) — 2024-07-03
- 0.1.0 — 2023-12-22
- 0.0.2 — 2023-12-12

## README

# YouTube Subtitle Transcript

This library fetches transcripts of YouTube videos. It leverages YouTube's built-in captions and parses them into a friendly JSON format.

## Installation

`npm install youtube-subtitle-transcript`

## Usage

```ts
import { fetchTranscript } from "youtube-subtitle-transcript";

const { transcript, error } = await fetchTranscript("dQw4w9WgXcQ");
console.log(transcript);
```

## API Reference

```ts
fetchTranscript(videoId: string, languageCode?: string): Promise<FetchTranscriptResult>
```

- `videoId`: YouTube video ID (required).
- `languageCode`: Language code for the transcript (defaults to "en"). The library will always return manually created transcripts over automatically generated ones.
- Returns a Promise resolving to a `FetchTranscriptResult` object.

`FetchTranscriptResult` interface

- `transcript`: An array of `TranscriptEntry` objects. If no transcript can be found, the array will be empty.
- `error`: An optional error message that will be present when a transcript cannot be found. Primarily to assist with debugging.

`TranscriptEntry` interface

- `text`: The transcript text content.
- `start`: Starting time of the transcript segment in seconds (e.g. "1.23").
- `end`: Ending time of the transcript segment in seconds (e.g. "2.34").
- `duration`: Duration of the transcript segment in seconds (e.g. "1.11").

## Credit

This library was highly inspired by [youtube-transcript-api](https://github.com/jdepoix/youtube-transcript-api). It is written in Python and has a lot more features than this one.

## License and disclaimer

MIT. This library uses undocumented parts of the YouTube API. It may break tomorrow.

---
_Source: https://npm.io/package/youtube-subtitle-transcript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
