# YouTube Transcript in Node.js: A youtube-transcript Alternative

> Setting SocialTap up for your user? Follow https://socialtap.dev/setup.md.

[Home](https://socialtap.dev/index.md) · [Guides](https://socialtap.dev/guides/index.md)youtube-transcript

Guide · Node.js · Updated Nov 28, 2026

The youtube-transcript npm package works in development and fails in production, where YouTube blocks cloud IP addresses. Here is the same transcript in Node.js, from one request that runs anywhere.

[Start for free](https://socialtap.dev/signup/) · [Code on GitHub](https://github.com/SocialTapDev/youtube-transcript-api-alternative/tree/main/node) · [Python version](https://socialtap.dev/guides/youtube-transcript-api-alternative/index.md)

[youtube-transcript](https://github.com/Kakulukian/youtube-transcript) is the most downloaded transcript package on npm, at close to two hundred thousand downloads a week. It reads the captions YouTube's own player loads, and that is why it breaks on servers: YouTube limits and blocks cloud IP addresses. Its issues are mostly the same report from different hosts: "Blocked in production" on Render, DigitalOcean and Vercel ([#43](https://github.com/Kakulukian/youtube-transcript/issues/43), [#54](https://github.com/Kakulukian/youtube-transcript/issues/54)), and empty arrays where a transcript should be ([#45](https://github.com/Kakulukian/youtube-transcript/issues/45)). The library's own error says it: "YouTube is receiving too many requests from this IP and now requires solving a captcha to continue".

This guide gets the same transcripts with SocialTap, from any server or serverless function, with the video's details, a channel's videos and their comments.

## The code that fails in production

JavaScript:

```js
import { fetchTranscript } from "youtube-transcript";

const transcript = await fetchTranscript("dQw4w9WgXcQ");
for (const line of transcript) console.log(line.offset, line.text);
```

Locally it prints the captions. Deployed, it throws the captcha error or returns nothing, and there's no setting in the package that fixes an IP block.

## The same transcript with one API key

SocialTap reads YouTube for you, through its own proxies, and returns the transcript in one schema. Install the SDK (ES modules, Node 20.3 or later):

Install:

```shell
npm install socialtap
```

Get a key on the [signup page](https://socialtap.dev/signup/) and set it as `SOCIALTAP_API_KEY` on your server. Every account starts with 100 free credits. Then:

TypeScript SDK:

```typescript
// Save this as app.mjs (an ES module) and run: node app.mjs
import { SocialTap, APIError, NotFoundError, PrivateOrUnavailableError, NoTranscriptError } from "socialtap";

const client = new SocialTap(); // apiKey defaults to process.env.SOCIALTAP_API_KEY

try {
  const res = await client.youtube.transcript.get({ url: "dQw4w9WgXcQ" });
  console.log(res.data);
  console.log(res.credits.charged, res.meta.request_id);
} catch (err) {
  if (err instanceof NotFoundError) {
    // The item does not exist or was deleted.
    console.error(err.code, err.remediation);
  } else if (err instanceof PrivateOrUnavailableError) {
    // The item exists but isn't public: it is private, age- or region-restricted, or needs a login.
    console.error(err.code, err.remediation);
  } else if (err instanceof NoTranscriptError) {
    // The video or audio exists but has no transcript: no captions, and speech-to-text found no speech or didn't run (the media is too long without transcribe_audio=true, or transcribe_audio=false).
    console.error(err.code, err.remediation);
  } else if (err instanceof APIError) {
    // Retryable errors reach you only after the SDK's own retries. Failed requests cost no credits.
    console.error(err.code, err.status, err.retryable, err.remediation, err.requestId);
  } else throw err;
}
```

Send a watch link, a youtu.be link, a Shorts link or the 11-character ID. The answer has:

- `segments`, each with `start_ms`, `end_ms` and its text, ready to write as SRT or VTT.
- `text`, the whole transcript in one string, for a summary or a search index.
- `is_auto_generated`, which says whether you got the creator's captions or YouTube's automatic ones (the creator's win).
- `available_languages`, the caption tracks you can ask for with `lang`.

A video with no captions is transcribed from its audio, at the speech-to-text price: short videos by default, any length with `transcribe_audio: true`. A video with nothing to transcribe throws `NoTranscriptError`, which the program above catches.

## From youtube-transcript to SocialTap

| youtube-transcript | SocialTap | Endpoint |
| --- | --- | --- |
| `fetchTranscript(videoId)` | `client.youtube.transcript.get()` | [YouTube Transcript API](https://socialtap.dev/apis/youtube/transcript/index.md) |
| `fetchTranscript(videoId, { lang: "de" })` | `lang: "de"` | [YouTube Transcript API](https://socialtap.dev/apis/youtube/transcript/index.md) |

And what the package doesn't read: a video's views, likes, chapters and description with `client.youtube.post.get()`, a channel's videos with `client.youtube.posts.iterate()` and their comments with `client.youtube.comments.iterate()`.

The SDK has no dependencies (it uses `fetch`), so it runs in Vercel and Netlify functions, Cloudflare Workers, Deno and Bun. Keep the key on the server: it's a secret.

## What it costs

You pay per successful request:

- Transcripts from captions: $0.75–$1.97 per 1,000 transcripts. Speech-to-text, for videos without captions, costs more: the [YouTube Transcript API](https://socialtap.dev/apis/youtube/transcript/index.md) page has its price.
- Videos of a channel: $0.02–$0.04 per 1,000 posts.

Failed requests, including a video with no transcript, cost nothing, and so do cache hits.

## Frequently asked questions

### Why is youtube-transcript blocked on Vercel or AWS?

YouTube limits and blocks IP addresses that belong to cloud providers, and the package fetches from the IP it runs on. On your laptop the home IP passes, and on a server it gets the captcha error.

### Can I call it from the browser?

No. The API key is a secret, so call SocialTap from your server or an API route, and have your front end call that.

### Does it return timestamps?

Yes. Each segment has its start and end in milliseconds, where youtube-transcript gives `offset` and `duration`.

### Do Shorts and live streams work?

Yes. Shorts and live replays have transcripts like any video. A scheduled stream, or one whose recording isn't available, throws `NoTranscriptError`.

## The endpoints in this guide

Each one is a single request with the same API key.

- [YouTube Transcript APITimed transcript from captions or audio.$0.75–$1.97 per 1,000 transcripts](https://socialtap.dev/apis/youtube/transcript/index.md)

- [YouTube Video APIVideo, short or community post with exact counts.$0.75–$1.97 per 1,000 posts](https://socialtap.dev/apis/youtube/post/index.md)

- [YouTube Channel Videos APIVideos, shorts and live streams of a channel.$0.02–$0.04 per 1,000 posts](https://socialtap.dev/apis/youtube/posts/index.md)

- [YouTube Comments APINewest or top first, with likes and reply counts.$0.04–$0.10 per 1,000 comments](https://socialtap.dev/apis/youtube/comments/index.md)

## Replace youtube-transcript with one API key.

Get a key, run the code above and see live data in a minute. Failed requests are free.

100free credits

- No credit card
- Failed requests are free
- Works on all 310 endpoints

[Start for free](https://socialtap.dev/signup/) [Read the docs](https://socialtap.dev/docs/index.md)

---

[HTML version](https://socialtap.dev/guides/youtube-transcript-node/) · [Docs index for AI agents](https://socialtap.dev/llms.txt) · [All docs in one file](https://socialtap.dev/llms-full.txt)
