├── package.json ├── .github └── workflows │ └── npm-publish.yml ├── LICENSE ├── .gitignore ├── src ├── index.js └── index.cjs └── README.md /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "youtube-transcript-api", 3 | "version": "3.0.0", 4 | "author": "0x6a69616e", 5 | "description": "A YouTube video transcript extractor based on reverse-engineered youtube-transcript.io", 6 | "main": "./src/index.js", 7 | "type": "module", 8 | "exports": { 9 | "import": "./src/index.js", 10 | "require": "./src/index.cjs" 11 | }, 12 | "scripts": { 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "keywords": [ 16 | "captions", 17 | "node", 18 | "nodejs", 19 | "subtitles", 20 | "youtube", 21 | "youtube-transcript", 22 | "transcript" 23 | ], 24 | "license": "MIT", 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/0x6a69616e/youtube-transcript-api.git" 28 | }, 29 | "dependencies": { 30 | "axios": "^1.10.0", 31 | "cheerio": "^1.1.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: workflow_dispatch 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: actions/setup-node@v3 14 | with: 15 | node-version: 20 16 | - run: npm ci 17 | 18 | publish-npm: 19 | needs: build 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v4 23 | - uses: actions/setup-node@v3 24 | with: 25 | node-version: 20 26 | registry-url: https://registry.npmjs.org/ 27 | - run: npm ci 28 | - run: npm publish 29 | env: 30 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-2025 0x6a69616e 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import * as cheerio from "cheerio"; 3 | 4 | /** 5 | * Generates a random hex string. 6 | * @param {number} size - Length of hex string 7 | * @returns A random hex string 8 | */ 9 | function generateRandomHex(size) { 10 | return [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join(""); 11 | } 12 | 13 | class TranscriptClient { 14 | ready; // ready event trigger 15 | #instance; // Axios Instance 16 | #firebase_cfg_creds; // Firebase configuration credentials 17 | 18 | constructor(AxiosOptions) { 19 | this.#instance = axios.create({ 20 | ...(AxiosOptions || {}), 21 | headers: { 22 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0", 23 | ...(AxiosOptions?.headers || {}) 24 | }, 25 | baseURL: "https://www.youtube-transcript.io/" 26 | }); 27 | 28 | // Promise-based ready event trigger system 29 | this.ready = new Promise(async resolve => { 30 | this.#firebase_cfg_creds = await this.#get_firebase_cfg_creds(); 31 | resolve(); 32 | }); 33 | } 34 | 35 | /** 36 | * Gets Google Firebase configuration credentials 37 | * @returns Firebase auth details 38 | */ 39 | #get_firebase_cfg_creds() { 40 | return (async () => { 41 | const { data } = await this.#instance.get("/"); 42 | const $ = cheerio.load(data); 43 | 44 | for (const elem of $("script[src]").toArray()) { 45 | const url = $(elem).attr("src"); 46 | const { data: script } = await this.#instance.get(url); 47 | 48 | const match = script.match(/\(\{[^}]*apiKey:"([^"]+)"[^}]*\}\)/gm); 49 | if (match) return Function("return " + match[0])(); 50 | } 51 | })(); 52 | } 53 | 54 | /** 55 | * Gets API authorization details from the Google Identity Platform 56 | * @returns SignupNewUserResponse 57 | */ 58 | #get_auth() { 59 | const creds = this.#firebase_cfg_creds; 60 | if (!creds) throw new Error("client not fully initialized!"); 61 | 62 | const url = new URL("https://identitytoolkit.googleapis.com/v1/accounts:signUp"); 63 | url.searchParams.set("key", creds.apiKey); 64 | 65 | return (async () => { 66 | const { data } = await this.#instance.post(url, { 67 | returnSecureToken: true 68 | }, { 69 | headers: { 70 | "X-Client-Version": "Firefox/JsCore/10.14.1/FirebaseCore-web", 71 | "X-Firebase-Client": JSON.stringify({ 72 | "version": 2, 73 | "heartbeats": [ 74 | { 75 | "agent": "fire-core/0.10.13 fire-core-esm2017/0.10.13 fire-js/ fire-js-all-app/10.14.1 fire-auth/1.7.9 fire-auth-esm2017/1.7.9", 76 | "dates": [ 77 | new Date().toISOString().split('T')[0] 78 | ] 79 | } 80 | ] 81 | }), 82 | "X-Firebase-gmpid": creds.appId.slice(2) 83 | } 84 | }); 85 | return data; 86 | })(); 87 | } 88 | 89 | /** 90 | * Retrieves the transcript of a particular video. 91 | * @param {string} id - The YouTube video ID 92 | * @param {object} [config] - Request configurations for the Axios HTTP client 93 | * @returns A Promise that resolves to the transcript object 94 | */ 95 | async getTranscript(id, config) { 96 | const auth = await this.#get_auth(); 97 | 98 | try { 99 | const { data } = await this.#instance.post("/api/transcripts", { 100 | ids: [ id ] 101 | }, { 102 | ...(config || {}), 103 | headers: { 104 | ...(config?.headers || {}), 105 | Authorization: "Bearer " + auth.idToken, 106 | 'X-Hash': generateRandomHex(64) 107 | } 108 | }); 109 | 110 | return data[0]; 111 | } catch (e) { 112 | if (e.status == 403) throw new Error('invalid video ID'); 113 | else throw e; 114 | } 115 | } 116 | 117 | /** 118 | * Retrieves the transcript of multiple videos. 119 | * @param {string[]} ids - A list of YouTube video IDs 120 | * @param {object} [config] - Request configurations for the Axios HTTP client 121 | * @returns A Promise that resolves to an array of transcript objects 122 | */ 123 | async bulkGetTranscript(ids, config) { 124 | const auth = await this.#get_auth(); 125 | 126 | try { 127 | const { data } = await this.#instance.post("/api/transcripts", { 128 | ids 129 | }, { 130 | ...(config || {}), 131 | headers: { 132 | ...(config?.headers || {}), 133 | Authorization: "Bearer " + auth.idToken, 134 | 'X-Hash': generateRandomHex(64) 135 | } 136 | }); 137 | 138 | return data; 139 | } catch (e) { 140 | if (e.status == 403) throw new Error('video not found or unavailable'); 141 | else throw e; 142 | } 143 | } 144 | } 145 | 146 | export { TranscriptClient as default }; 147 | -------------------------------------------------------------------------------- /src/index.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var axios = require('axios'); 4 | var cheerio = require('cheerio'); 5 | 6 | function _interopNamespaceDefault(e) { 7 | var n = Object.create(null); 8 | if (e) { 9 | Object.keys(e).forEach(function (k) { 10 | if (k !== 'default') { 11 | var d = Object.getOwnPropertyDescriptor(e, k); 12 | Object.defineProperty(n, k, d.get ? d : { 13 | enumerable: true, 14 | get: function () { return e[k]; } 15 | }); 16 | } 17 | }); 18 | } 19 | n.default = e; 20 | return Object.freeze(n); 21 | } 22 | 23 | var cheerio__namespace = /*#__PURE__*/_interopNamespaceDefault(cheerio); 24 | 25 | /** 26 | * Generates a random hex string. 27 | * @param {number} size - Length of hex string 28 | * @returns A random hex string 29 | */ 30 | function generateRandomHex(size) { 31 | return [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join(""); 32 | } 33 | 34 | class TranscriptClient { 35 | ready; // ready event trigger 36 | #instance; // Axios Instance 37 | #firebase_cfg_creds; // Firebase configuration credentials 38 | 39 | constructor(AxiosOptions) { 40 | this.#instance = axios.create({ 41 | ...(AxiosOptions || {}), 42 | headers: { 43 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0", 44 | ...(AxiosOptions?.headers || {}) 45 | }, 46 | baseURL: "https://www.youtube-transcript.io/" 47 | }); 48 | 49 | // Promise-based ready event trigger system 50 | this.ready = new Promise(async resolve => { 51 | this.#firebase_cfg_creds = await this.#get_firebase_cfg_creds(); 52 | resolve(); 53 | }); 54 | } 55 | 56 | /** 57 | * Gets Google Firebase configuration credentials 58 | * @returns Firebase auth details 59 | */ 60 | #get_firebase_cfg_creds() { 61 | return (async () => { 62 | const { data } = await this.#instance.get("/"); 63 | const $ = cheerio__namespace.load(data); 64 | 65 | for (const elem of $("script[src]").toArray()) { 66 | const url = $(elem).attr("src"); 67 | const { data: script } = await this.#instance.get(url); 68 | 69 | const match = script.match(/\(\{[^}]*apiKey:"([^"]+)"[^}]*\}\)/gm); 70 | if (match) return Function("return " + match[0])(); 71 | } 72 | })(); 73 | } 74 | 75 | /** 76 | * Gets API authorization details from the Google Identity Platform 77 | * @returns SignupNewUserResponse 78 | */ 79 | #get_auth() { 80 | const creds = this.#firebase_cfg_creds; 81 | if (!creds) throw new Error("client not fully initialized!"); 82 | 83 | const url = new URL("https://identitytoolkit.googleapis.com/v1/accounts:signUp"); 84 | url.searchParams.set("key", creds.apiKey); 85 | 86 | return (async () => { 87 | const { data } = await this.#instance.post(url, { 88 | returnSecureToken: true 89 | }, { 90 | headers: { 91 | "X-Client-Version": "Firefox/JsCore/10.14.1/FirebaseCore-web", 92 | "X-Firebase-Client": JSON.stringify({ 93 | "version": 2, 94 | "heartbeats": [ 95 | { 96 | "agent": "fire-core/0.10.13 fire-core-esm2017/0.10.13 fire-js/ fire-js-all-app/10.14.1 fire-auth/1.7.9 fire-auth-esm2017/1.7.9", 97 | "dates": [ 98 | new Date().toISOString().split('T')[0] 99 | ] 100 | } 101 | ] 102 | }), 103 | "X-Firebase-gmpid": creds.appId.slice(2) 104 | } 105 | }); 106 | return data; 107 | })(); 108 | } 109 | 110 | /** 111 | * Retrieves the transcript of a particular video. 112 | * @param {string} id - The YouTube video ID 113 | * @param {object} [config] - Request configurations for the Axios HTTP client 114 | * @returns A Promise that resolves to the transcript object 115 | */ 116 | async getTranscript(id, config) { 117 | const auth = await this.#get_auth(); 118 | 119 | try { 120 | const { data } = await this.#instance.post("/api/transcripts", { 121 | ids: [ id ] 122 | }, { 123 | ...(config || {}), 124 | headers: { 125 | ...(config?.headers || {}), 126 | Authorization: "Bearer " + auth.idToken, 127 | 'X-Hash': generateRandomHex(64) 128 | } 129 | }); 130 | 131 | return data[0]; 132 | } catch (e) { 133 | if (e.status == 403) throw new Error('invalid video ID'); 134 | else throw e; 135 | } 136 | } 137 | 138 | /** 139 | * Retrieves the transcript of multiple videos. 140 | * @param {string[]} ids - A list of YouTube video IDs 141 | * @param {object} [config] - Request configurations for the Axios HTTP client 142 | * @returns A Promise that resolves to an array of transcript objects 143 | */ 144 | async bulkGetTranscript(ids, config) { 145 | const auth = await this.#get_auth(); 146 | 147 | try { 148 | const { data } = await this.#instance.post("/api/transcripts", { 149 | ids 150 | }, { 151 | ...(config || {}), 152 | headers: { 153 | ...(config?.headers || {}), 154 | Authorization: "Bearer " + auth.idToken, 155 | 'X-Hash': generateRandomHex(64) 156 | } 157 | }); 158 | 159 | return data; 160 | } catch (e) { 161 | if (e.status == 403) throw new Error('video not found or unavailable'); 162 | else throw e; 163 | } 164 | } 165 | } 166 | 167 | module.exports = TranscriptClient; 168 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # youtube-transcript-api 3 | 4 | ![npm version badge](https://img.shields.io/npm/v/youtube-transcript-api?color=4287f5&style=flat-square) 5 | ![npm downloads badge](https://img.shields.io/npm/dm/youtube-transcript-api?color=4287f5&style=flat-square) 6 | 7 | > A YouTube video transcript extractor based on reverse-engineered [youtube-transcript.io](https://www.youtube-transcript.io) 8 | 9 | ## 📚 Table of Contents 10 | 11 | 12 | - [youtube-transcript-api](#youtube-transcript-api) 13 | * [✨ Features](#features) 14 | * [📦 Installation](#installation) 15 | * [🛠️ Usage](#usage) 16 | * [🧪 API](#api) 17 | + [`new TranscriptClient([AxiosOptions])`](#new-transcriptclientaxiosoptions) 18 | + [`client.ready : Promise`](#clientready-promisevoid) 19 | + [`client.getTranscript(id, [config])`](#clientgettranscriptid-config) 20 | - [Parameters](#parameters) 21 | - [Returns](#returns) 22 | - [Errors](#errors) 23 | - [Example](#example) 24 | * [Transcript not available](#transcript-not-available) 25 | * [Video not found or unavailable](#video-not-found-or-unavailable) 26 | + [`client.bulkGetTranscript(ids, [config])`](#clientbulkgettranscriptids-config) 27 | - [Parameters](#parameters-1) 28 | - [Returns](#returns-1) 29 | - [Errors](#errors-1) 30 | - [Example](#example-1) 31 | * [Transcript not available](#transcript-not-available-1) 32 | * [🕰️ Previous Versions](#previous-versions) 33 | * [📄 License](#license) 34 | 35 | 36 | 37 | --- 38 | 39 | 40 | ## ✨ Features 41 | 42 | * Retrieve transcript for a single YouTube video. 43 | * Retrieve transcripts in bulk (multiple YouTube videos). 44 | * Complete multilanguage support. 45 | * Retrieve additional YouTube video metadata. 46 | 47 | --- 48 | 49 | 50 | ## 📦 Installation 51 | 52 | ```bash 53 | $ npm install youtube-transcript-api 54 | ``` 55 | 56 | --- 57 | 58 | 59 | ## 🛠️ Usage 60 | 61 | ```js 62 | import TranscriptClient from "youtube-transcript-api"; // both CJS and ESM are supported 63 | 64 | const client = new TranscriptClient(); 65 | 66 | (async () => { 67 | await client.ready; // wait for client initialization 68 | const transcript = await client.getTranscript("dQw4w9WgXcQ"); 69 | console.log(transcript); 70 | })(); 71 | ``` 72 | 73 | --- 74 | 75 | 76 | ## 🧪 API 77 | 78 | 79 | ### `new TranscriptClient([AxiosOptions])` 80 | 81 | Creates a new instance of the `TranscriptClient`. 82 | 83 | * `AxiosOptions` *(optional)*: Custom Axios configuration object passed to the internal Axios instance. Useful for setting custom headers, timeouts, proxies, etc. See available options [here](https://axios-http.com/docs/req_config) 84 | 85 | ```js 86 | const client = new TranscriptClient({ 87 | headers: { 88 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36" 89 | } 90 | }); 91 | ``` 92 | 93 | 94 | ### `client.ready : Promise` 95 | 96 | A promise that resolves when the client is fully initialized and ready to use. 97 | 98 | Upon instantiation of `TranscriptClient`, Firebase configuration credentials for the youtube-transcript.io application need to be scraped. Always `await` this before calling methods. 99 | 100 | --- 101 | 102 | 103 | ### `client.getTranscript(id, [config])` 104 | 105 | Fetch the transcript of a single YouTube video. 106 | 107 | 108 | #### Parameters 109 | 110 | * `id` **(string)** – The ID of the YouTube video. 111 | * `config` **(object)** *(optional)* – Additional Axios request config. See available options [here](https://axios-http.com/docs/req_config) 112 | 113 | 114 | #### Returns 115 | 116 | * A **Promise** that resolves to the transcript object. 117 | 118 | 119 | #### Errors 120 | 121 | * `"invalid video ID"`: Received status 403 from API. A video with the specified `id` does not exist. 122 | 123 | 124 | #### Example 125 | 126 | ```js 127 | const transcript = await client.getTranscript("dQw4w9WgXcQ"); 128 | console.log(transcript); 129 | ``` 130 | 131 | ```json 132 | { 133 | "id": "dQw4w9WgXcQ", 134 | "title": "Rick Astley - Never Gonna Give You Up (Official Music Video)", 135 | "microformat": { 136 | "playerMicroformatRenderer": { 137 | "thumbnail": { 138 | "thumbnails": [ 139 | { 140 | "url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg", 141 | "width": 1280, 142 | "height": 720 143 | } 144 | ] 145 | }, 146 | "embed": { 147 | "iframeUrl": "https://www.youtube.com/embed/dQw4w9WgXcQ", 148 | "width": 1280, 149 | "height": 720 150 | }, 151 | "title": { 152 | "simpleText": "Rick Astley - Never Gonna Give You Up (Official Music Video)" 153 | }, 154 | "description": { 155 | "simpleText": "The official video for “Never Gonna Give You Up” by Rick Astley. \n\nNever: The Autobiography 📚 OUT NOW! \nFollow this link to get your copy and listen to Rick’s ‘Never’ playlist ❤️ #RickAstleyNever\nhttps://linktr.ee/rickastleynever\n\n“Never Gonna Give You Up” was a global smash on its release in July 1987, topping the charts in 25 countries including Rick’s native UK and the US Billboard Hot 100. It also won the Brit Award for Best single in 1988. Stock Aitken and Waterman wrote and produced the track which was the lead-off single and lead track from Rick’s debut LP “Whenever You Need Somebody”. The album was itself a UK number one and would go on to sell over 15 million copies worldwide.\n\nThe legendary video was directed by Simon West – who later went on to make Hollywood blockbusters such as Con Air, Lara Croft – Tomb Raider and The Expendables 2. The video passed the 1bn YouTube views milestone on 28 July 2021.\n\nSubscribe to the official Rick Astley YouTube channel: https://RickAstley.lnk.to/YTSubID\n\nFollow Rick Astley:\nFacebook: https://RickAstley.lnk.to/FBFollowID \nTwitter: https://RickAstley.lnk.to/TwitterID \nInstagram: https://RickAstley.lnk.to/InstagramID \nWebsite: https://RickAstley.lnk.to/storeID \nTikTok: https://RickAstley.lnk.to/TikTokID\n\nListen to Rick Astley:\nSpotify: https://RickAstley.lnk.to/SpotifyID \nApple Music: https://RickAstley.lnk.to/AppleMusicID \nAmazon Music: https://RickAstley.lnk.to/AmazonMusicID \nDeezer: https://RickAstley.lnk.to/DeezerID \n\nLyrics:\nWe’re no strangers to love\nYou know the rules and so do I\nA full commitment’s what I’m thinking of\nYou wouldn’t get this from any other guy\n\nI just wanna tell you how I’m feeling\nGotta make you understand\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\nWe’ve known each other for so long\nYour heart’s been aching but you’re too shy to say it\nInside we both know what’s been going on\nWe know the game and we’re gonna play it\n\nAnd if you ask me how I’m feeling\nDon’t tell me you’re too blind to see\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\n#RickAstley #NeverGonnaGiveYouUp #WheneverYouNeedSomebody #OfficialMusicVideo" 156 | }, 157 | "lengthSeconds": "213", 158 | "ownerProfileUrl": "http://www.youtube.com/@RickAstleyYT", 159 | "externalChannelId": "UCuAXFkgsw1L7xaCfnd5JJOw", 160 | "isFamilySafe": true, 161 | "availableCountries": [ 162 | "AD", 163 | "AE", 164 | "AF", 165 | "AG", 166 | "AI", 167 | ... 168 | ], 169 | "isUnlisted": false, 170 | "hasYpcMetadata": false, 171 | "viewCount": "1646819896", 172 | "category": "Music", 173 | "publishDate": "2009-10-24T23:57:33-07:00", 174 | "ownerChannelName": "Rick Astley", 175 | "uploadDate": "2009-10-24T23:57:33-07:00", 176 | "isShortsEligible": false, 177 | "externalVideoId": "dQw4w9WgXcQ", 178 | "likeCount": "18306193" 179 | } 180 | }, 181 | "tracks": [ 182 | { 183 | "language": "English (auto-generated)", 184 | "transcript": [ 185 | { 186 | "text": "we're no strangers to", 187 | "start": "18.8", 188 | "dur": "7.239" 189 | }, 190 | { 191 | "text": "love you know the rules and so do", 192 | "start": "21.8", 193 | "dur": "7.84" 194 | }, 195 | { 196 | "text": "I I full commitments while I'm thinking", 197 | "start": "26.039", 198 | "dur": "5.201" 199 | }, 200 | { 201 | "text": "of", 202 | "start": "29.64", 203 | "dur": "5.88" 204 | }, 205 | { 206 | "text": "you wouldn't get this from any other guy", 207 | "start": "31.24", 208 | "dur": "8.2" 209 | }, 210 | ... 211 | ] 212 | } 213 | ], 214 | "isLive": false, 215 | "languages": [ 216 | { 217 | "label": "English (auto-generated)", 218 | "languageCode": "en" 219 | } 220 | ], 221 | "isLoginRequired": false, 222 | "playabilityStatus": { 223 | "status": "OK", 224 | "playableInEmbed": true, 225 | "miniplayer": { 226 | "miniplayerRenderer": { 227 | "playbackMode": "PLAYBACK_MODE_ALLOW" 228 | } 229 | }, 230 | "contextParams": "Q0FFU0FnZ0I=" 231 | }, 232 | "author": "Rick Astley", 233 | "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw", 234 | "keywords": [ 235 | "rick astley", 236 | "Never Gonna Give You Up", 237 | "nggyu", 238 | "never gonna give you up lyrics", 239 | "rick rolled", 240 | ... 241 | ] 242 | } 243 | ``` 244 | 245 | 246 | ##### Transcript not available 247 | 248 | ```js 249 | await client.getTranscript("JGJPVl7iQUM"); 250 | ``` 251 | 252 | ```json 253 | { 254 | "id": "JGJPVl7iQUM", 255 | "microformat": { 256 | "playerMicroformatRenderer": { 257 | "category": "Music", 258 | "description": { 259 | "simpleText": "Provided to YouTube by IIP-DDS\n\nClair de Lune (Studio Version) · Johann Debussy\n\nClair de Lune (Studio Version)\n\n℗ Michael Lee Moen\n\nReleased on: 2021-12-14\n\nProducer: Michael Lee Moen\nMusic Publisher: Claude Debussy\nComposer: Claude Debussy\n\nAuto-generated by YouTube." 260 | }, 261 | "externalChannelId": "UC2VEp_GJTawei2IkYuqQdFA", 262 | "lengthSeconds": "311", 263 | "ownerChannelName": "Johann Debussy", 264 | "publishDate": "2021-12-14", 265 | "title": { 266 | "simpleText": "Clair de Lune (Studio Version)" 267 | } 268 | } 269 | }, 270 | "isLive": false, 271 | "isLoginRequired": false, 272 | "languages": [ 273 | { 274 | "label": "en", 275 | "languageCode": "en" 276 | } 277 | ], 278 | "playabilityStatus": { 279 | "status": "OK", 280 | "reason": "Transcript not available" 281 | }, 282 | "title": "Clair de Lune (Studio Version)", 283 | "tracks": [] 284 | } 285 | ``` 286 | 287 | 288 | ##### Video not found or unavailable 289 | 290 | ```js 291 | await client.getTranscript("1dsfsdfsdfs"); 292 | ``` 293 | ```json 294 | { 295 | "id": "", 296 | "title": "", 297 | "tracks": [], 298 | "isLive": false, 299 | "languages": [], 300 | "isLoginRequired": false, 301 | "playabilityStatus": { 302 | "status": "LOGIN_REQUIRED", 303 | "reason": "Video not found or unavailable" 304 | }, 305 | "failedReason": "PLAYABILITY_STATUS_NOK" 306 | } 307 | ``` 308 | 309 | --- 310 | 311 | 312 | ### `client.bulkGetTranscript(ids, [config])` 313 | 314 | Fetch transcripts for multiple YouTube videos in a single request. 315 | 316 | 317 | #### Parameters 318 | 319 | * `ids` **(string[])** – An array of YouTube video IDs. 320 | * `config` **(object)** *(optional)* – Additional Axios request config. See available options [here](https://axios-http.com/docs/req_config) 321 | 322 | 323 | #### Returns 324 | 325 | * A **Promise** that resolves to an array of transcript objects. 326 | 327 | 328 | #### Errors 329 | 330 | * `"video not found or unavailable"`: Received status 403 from API. One or more videos could not be found or are unavailable, or a specified video ID does not exist. 331 | 332 | 333 | #### Example 334 | 335 | ```js 336 | const transcripts = await client.bulkGetTranscript([ 337 | "1E3tv_3D95g", 338 | "dQw4w9WgXcQ" 339 | ]); 340 | console.log(transcripts); 341 | ``` 342 | 343 | ```json 344 | [ 345 | { 346 | "id": "1E3tv_3D95g", 347 | "microformat": { 348 | "playerMicroformatRenderer": { 349 | "category": "Science & Technology", 350 | "description": { 351 | "simpleText": "Hands on with iOS 26 and everything you need to know from WWDC 2025\n\nMKBHD Merch: http://shop.MKBHD.com\n\nIntro Track: Jordyn Edmonds\nPlaylist of MKBHD Intro music: https://goo.gl/B3AWV5\n\n~\nhttp://twitter.com/MKBHD\nhttp://instagram.com/MKBHD\nhttp://facebook.com/MKBHD\n\n0:00 26 All the Things\n2:01 iOS 16\n5:39 Liquid Glass concerns\n6:35 WatchOS 26\n7:53 tvOS 26\n8:10 macOS Tahoe\n10:55 visionOS 26\n12:48 iPadOS 26\n16:11 What about AI and Siri?" 352 | }, 353 | "externalChannelId": "UCBJycsmduvYEL83R_U4JriQ", 354 | "lengthSeconds": "1102", 355 | "ownerChannelName": "Marques Brownlee", 356 | "publishDate": "2025-06-10", 357 | "title": { 358 | "simpleText": "WWDC 2025 Impressions: Liquid Glass!" 359 | } 360 | } 361 | }, 362 | "isLive": false, 363 | "isLoginRequired": false, 364 | "languages": [ 365 | { 366 | "label": "en", 367 | "languageCode": "en" 368 | } 369 | ], 370 | "playabilityStatus": { 371 | "status": "OK", 372 | "reason": "" 373 | }, 374 | "title": "WWDC 2025 Impressions: Liquid Glass!", 375 | "tracks": [ 376 | { 377 | "language": "en", 378 | "transcript": [ 379 | { 380 | "start": "0.2", 381 | "dur": "3.06", 382 | "text": "[Music]" 383 | }, 384 | { 385 | "start": "3.439", 386 | "dur": "2.081", 387 | "text": "all right So today was Apple's big" 388 | }, 389 | { 390 | "start": "5.52", 391 | "dur": "4.079", 392 | "text": "software event for 2025 WWDC And it was" 393 | }, 394 | { 395 | "start": "9.599", 396 | "dur": "1.841", 397 | "text": "a really it was actually a really" 398 | }, 399 | { 400 | "start": "11.44", 401 | "dur": "1.279", 402 | "text": "interesting one I was kind of wondering" 403 | }, 404 | ... 405 | ] 406 | } 407 | ] 408 | }, 409 | ... 410 | ] 411 | ``` 412 | 413 | 414 | ##### Transcript not available 415 | 416 | ```js 417 | await client.bulkGetTranscript([ 418 | "JGJPVl7iQUM", 419 | "dQw4w9WgXcQ" 420 | ]); 421 | ``` 422 | 423 | ```json 424 | [ 425 | { 426 | "id": "JGJPVl7iQUM", 427 | "microformat": { 428 | "playerMicroformatRenderer": { 429 | "category": "Music", 430 | "description": { 431 | "simpleText": "Provided to YouTube by IIP-DDS\n\nClair de Lune (Studio Version) · Johann Debussy\n\nClair de Lune (Studio Version)\n\n℗ Michael Lee Moen\n\nReleased on: 2021-12-14\n\nProducer: Michael Lee Moen\nMusic Publisher: Claude Debussy\nComposer: Claude Debussy\n\nAuto-generated by YouTube." 432 | }, 433 | "externalChannelId": "UC2VEp_GJTawei2IkYuqQdFA", 434 | "lengthSeconds": "311", 435 | "ownerChannelName": "Johann Debussy", 436 | "publishDate": "2021-12-14", 437 | "title": { 438 | "simpleText": "Clair de Lune (Studio Version)" 439 | } 440 | } 441 | }, 442 | "isLive": false, 443 | "isLoginRequired": false, 444 | "languages": [ 445 | { 446 | "label": "en", 447 | "languageCode": "en" 448 | } 449 | ], 450 | "playabilityStatus": { 451 | "status": "OK", 452 | "reason": "Transcript not available" 453 | }, 454 | "title": "Clair de Lune (Studio Version)", 455 | "tracks": [] 456 | }, 457 | ... 458 | ] 459 | ``` 460 | 461 | --- 462 | 463 | 464 | ## 🕰️ Previous Versions 465 | * **v2.0.4** [[npm](https://www.npmjs.com/package/youtube-transcript-api/v/2.0.4)] [[jsDelivr](https://www.jsdelivr.com/package/npm/youtube-transcript-api?version=2.0.4)] 466 | * Based on a [Free Youtube Transcript Generator by Tactiq.io](https://tactiq.io/tools/youtube-transcript) 467 | * Issue [#5](https://github.com/0x6a69616e/youtube-transcript-api/issues/5) 468 | 469 | * **v1.1.2** [[npm](https://www.npmjs.com/package/youtube-transcript-api/v/1.1.2)] [[jsDelivr](https://www.jsdelivr.com/package/npm/youtube-transcript-api?version=1.1.2)] 470 | * Based on [youtubetranscript.com](https://youtubetranscript.com) 471 | * Issue [#4](https://github.com/0x6a69616e/youtube-transcript-api/issues/4) 472 | 473 | --- 474 | 475 | 476 | ## 📄 License 477 | 478 | This repository is licensed under the MIT License. 479 | ``` 480 | Copyright (c) 2023-2025 0x6a69616e 481 | 482 | Permission is hereby granted, free of charge, to any person obtaining a copy 483 | of this software and associated documentation files (the "Software"), to deal 484 | in the Software without restriction, including without limitation the rights 485 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 486 | copies of the Software, and to permit persons to whom the Software is 487 | furnished to do so, subject to the following conditions: 488 | 489 | The above copyright notice and this permission notice shall be included in all 490 | copies or substantial portions of the Software. 491 | 492 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 493 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 494 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 495 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 496 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 497 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 498 | SOFTWARE. 499 | ``` 500 | --------------------------------------------------------------------------------