How to get YouTube comments in Node.js

Checked on 2026-11-24.

For comments, the official YouTube Data API is a good route from Node.js: Google's googleapis package calls commentThreads.list with an API key, and the daily quota goes a long way. Without a Google Cloud project there are two more: the youtubei.js library, which reads YouTube's internal API, and an HTTP API you call with fetch.

1. The YouTube Data API with googleapis

You need a Google Cloud project with the YouTube Data API enabled and an API key. Reading public comments needs no OAuth: the getting-started page says that for list methods "unauthorized requests only retrieve public data". The client is set up the way the googleapis README shows for an API key, and the parameters are those of commentThreads.list:

JavaScript
// npm install googleapis
const { google } = require('googleapis');

const youtube = google.youtube({ version: 'v3', auth: process.env.YOUTUBE_API_KEY });

async function main() {
  let pageToken;
  do {
    const res = await youtube.commentThreads.list({
      part: ['snippet'],
      videoId: 'jNQXAC9IVRw',
      maxResults: 100,         // 1 to 100; 20 when left out
      order: 'relevance',      // or 'time', the default
      textFormat: 'plainText', // 'html' is the default
      pageToken,
    });
    for (const thread of res.data.items ?? []) {
      const comment = thread.snippet.topLevelComment.snippet;
      console.log(comment.authorDisplayName, comment.likeCount, comment.textDisplay);
    }
    pageToken = res.data.nextPageToken;
  } while (pageToken);
}

main().catch(console.error);

"A call to this method has a quota cost of 1 unit", and the default allowance is "10,000 units per day combined" for every method except search and uploads, so reading every thread of a video costs one unit per hundred. A video with comments turned off fails with 403 and the reason commentsDisabled. Each thread's replies are "only a subset" of its replies: for all of them the documentation sends you to comments.list. When the quota runs out, the guide to the quotaExceeded error explains what to do.

Where it stops: mostly at setup and at the package. The latest googleapis, version 190.0.0, declares Node.js 22 or newer on npm, and its README says the libraries "are considered complete and are in maintenance mode". To reduce start-up time, the README offers each API as a submodule of its own; for YouTube that is npm install @googleapis/youtube. The data itself is the most complete of the three routes: every thread, newest or most relevant first, with exact dates in publishedAt.

2. youtubei.js, without a key

YouTube.js, published on npm as youtubei.js, is "A JavaScript client for YouTube's internal API". It needs no key and no Google project. The method and fields below are from its API documentation and source:

JavaScript
// npm install youtubei.js
import { Innertube } from 'youtubei.js';

const youtube = await Innertube.create();
let page = await youtube.getComments('jNQXAC9IVRw', 'TOP_COMMENTS'); // or 'NEWEST_FIRST'

for (let pages = 0; pages < 3; pages++) {
  for (const thread of page.contents) {
    const comment = thread.comment;
    console.log(comment?.author?.name, comment?.like_count, comment?.content?.toString());
  }
  if (!page.has_continuation) break;
  page = await page.getContinuation();
}

Counts such as like_count arrive as text, and published_time is text as well, not a timestamp.

Where it breaks: when YouTube changes its internal API, until the library catches up. In July 2026 getComments() began to crash for some videos on version 17.2.0 (issue 1204, since closed), and one user wrote: "This started happening recently without any code changes on my side." Keep it updated; the latest version on 2026-11-24 was 18.3.0. In the browser it does not work on its own: its documentation says "To use YouTube.js in the browser, you must proxy requests through your own server." Its README adds that the project "is not affiliated with, endorsed, or sponsored by YouTube".

3. An HTTP API, with fetch or the npm client

With Pipefetch the top or the newest comments of a video are one HTTPS request with one key, from any server, with no Google project and no YouTube quota. A plain fetch call:

JavaScript
const url = new URL('https://pipefetch.com/v1/youtube/comments');
url.searchParams.set('video', 'jNQXAC9IVRw');
url.searchParams.set('limit', '100');
url.searchParams.set('sort', 'top'); // or 'newest'

const res = await fetch(url, {
  headers: { 'x-api-key': process.env.PIPEFETCH_API_KEY },
  signal: AbortSignal.timeout(90_000),
});
if (res.status === 404) {
  console.log('No comments, comments turned off, or no such video'); // not charged
} else if (!res.ok) {
  throw new Error(`Pipefetch answered ${res.status}`);
} else {
  const { data } = await res.json();
  console.log(data.totalComments, 'comments in total');
  for (const comment of data.comments) console.log(comment.author.name, comment.likeCount, comment.text);
}

The npm client, pipefetch, has a method for it:

JavaScript
// npm install pipefetch
import Pipefetch, { NotFoundError } from 'pipefetch';

const pf = new Pipefetch(); // reads PIPEFETCH_API_KEY

try {
  const { comments } = await pf.comments('jNQXAC9IVRw', { limit: 40, sort: 'newest' }); // 2 credits
  for (const c of comments) console.log(c.publishedText, c.replyCount, c.isPinned, c.text);
} catch (error) {
  if (error instanceof NotFoundError) console.log(error.code); // comments_disabled, for example: not charged
  else throw error;
}

One limit to know: it returns up to 100 comments per video, the top ones or the newest ones, and no further pages. They are top-level comments, each with its replyCount and flags for pinned and creator-hearted comments; replies themselves are not returned. The date is YouTube's own text, such as "6 years ago", not a timestamp. It costs 1 credit per started 20 comments, so 100 comments are 5 credits, and a video with comments turned off answers 404 and costs nothing. The reference lists every field.

Where it stops: at that page of 100 and at replies. It is not an official API, and Pipefetch is not affiliated with YouTube or Google.

Which one should you use?

You needUse
Every comment of a video, replies, or exact datesThe official API with googleapis
Comments without a key, from a script you keep up to dateyoutubei.js
The top or newest comments of many videos, from a server, without a Google Cloud projectAn HTTP API such as Pipefetch

Comments are personal data

A comment comes with its author's public name and channel. Under laws such as the GDPR that is personal data, whichever route you used to fetch it. Keep only what your purpose needs, and do not publish lists of commenters. For the same task in Python, see YouTube comments in Python; for transcripts in JavaScript, YouTube transcripts in Node.js.

Try it with 100 free credits. No card needed. No Google Cloud project or OAuth. Get an API key or read the docs.

Every source

Instagram

Websites

TikTok

Facebook

Google

Threads

LinkedIn

App stores

Steam

X

Pinterest

Airbnb

Real estate

Keywords

Job boards

Eventbrite

Shopify stores

Public tenders

All guides