Price alert Hurry up! Google SERP API from $0.03/1K calls — prices likely to rise 10× from December 2026.Hurry up! Google SERP from $0.03/1K — likely 10× from Dec 2026Google SERP $0.03/1K · likely 10× from Dec$0.03/1K · likely 10× in Dec Deposit Now

How to Scrape YouTube Comments in Python and Node

By Anurag Pathak · · 13 min read

To get YouTube comments in Python or Node, send one GET request with the video link, then follow the cursor for the next page. Google's official Data API does the same job with a Google Cloud API key and a default quota of 10,000 units a day. Both routes are shown below.

Short answer: If you are happy to set up a Google Cloud project and keep an eye on a daily quota, YouTube's Data API costs no money and returns exact dates and like counts. If you would rather make one call with one key, use Serpent: from $0.17 per 1K API calls (about $0.0085 per 1,000 comments) — pay as you go, no subscription. One call returns one page of comments (20 in each answer saved for this post), not one comment, and sort=newest is the order to use when you need a walk you can run again. See pricing.

Comments are the part of a video people write themselves, which is why they end up in dashboards, support queues and research projects. Getting them into your own code takes one request. The decisions are which service answers it, how you page, and what the values look like when they arrive.

What are the two ways to get YouTube comments in code?

One is YouTube's own Data API v3, a free service from Google. The other is a comments API, which is what Serpent sells. Serpent is not affiliated with YouTube or Google, and what this post says about Google comes from its documentation pages, which I read on 24 November 2026.

Both routes return JSON. They differ in the credential you need, what a call costs, how many comments come back, how ordering and paging work, and whether dates and like counts arrive exact or as shown. The figure sets them side by side, and the comparison table further down adds detail.

How does the official YouTube Data API route work?

You call the commentThreads.list method with part=snippet, a videoId and a key from a Google Cloud project that has the YouTube Data API enabled. Google's getting-started page says unauthorized list requests retrieve only public data, which covers comments on public videos.

The price is quota, not dollars. The quota page lists commentThreads.list at 1 unit and gives a default of 10,000 units a day. Every extra page costs the same, and even an invalid request costs at least one unit. maxResults takes 1 to 100 and defaults to 20, so at 100 per call the whole default quota is 10,000 calls, or up to 1,000,000 top-level comments a day if nothing else in your project spends units.

Ordering is order=time (the default) or order=relevance. For the next page you send the previous response's nextPageToken back as pageToken. Each thread carries only a limited number of replies; to get the rest you call comments.list with parentId, at another unit per call.

Example code, not run (it needs your own Google key, and I made no call to Google's API for this post). The field names follow the documentation for the commentThread and comment resources.

import requests

KEY = "YOUR_GOOGLE_API_KEY"
HOST = "https://www.googleapis.com"
URL = HOST + "/youtube/v3/commentThreads"

params = {
    "part": "snippet",
    "videoId": "dQw4w9WgXcQ",
    "maxResults": 100,
    "order": "relevance",
    "textFormat": "plainText",
    "key": KEY,
}
data = requests.get(URL, params=params, timeout=60).json()

for item in data.get("items", [])[:3]:
    c = item["snippet"]["topLevelComment"]["snippet"]
    print(c["likeCount"], item["snippet"]["totalReplyCount"], c["publishedAt"], c["authorDisplayName"])
    print(" ", c["textDisplay"])

# Next page: send this value back as the pageToken parameter
print("nextPageToken:", data.get("nextPageToken"))

The same request in Node 18 or later, saved as official.mjs. Also example code, not run:

const KEY = "YOUR_GOOGLE_API_KEY";
const HOST = "https://www.googleapis.com";
const URL_BASE = HOST + "/youtube/v3/commentThreads";

const params = new URLSearchParams({
  part: "snippet",
  videoId: "dQw4w9WgXcQ",
  maxResults: "100",
  order: "relevance",
  textFormat: "plainText",
  key: KEY,
});
const data = await (await fetch(`${URL_BASE}?${params}`)).json();

for (const item of (data.items || []).slice(0, 3)) {
  const c = item.snippet.topLevelComment.snippet;
  console.log(c.likeCount, item.snippet.totalReplyCount, c.publishedAt, c.authorDisplayName);
  console.log(" ", c.textDisplay);
}

// Next page: send this value back as the pageToken parameter
console.log("nextPageToken:", data.nextPageToken);

This route has real strengths. It costs no money, publishedAt is an exact date and time, and likeCount is an exact count. The friction is the project and key, a quota shared by every call your project makes, and a video with comments turned off, which Google's documentation says answers with a 403 commentsDisabled error that your code has to catch.

How do you get comments with one call in Python?

Send a GET request to https://apiserpent.com/api/social/youtube/comments with your key in the X-API-Key header. video is required and takes an 11-character id or a YouTube link. sort is top or newest, and cursor is the next_cursor from the previous page. One call returns one page of top-level comments, and each answer saved for this post held 20.

Install requests, put your key in place of the placeholder, and use this:

import requests

API_KEY = "sk_live_your_api_key"
BASE = "https://apiserpent.com/api/social/youtube/comments"


def get_page(video, sort="top", cursor=None):
    params = {"video": video, "sort": sort}
    if cursor:
        params["cursor"] = cursor
    r = requests.get(BASE, params=params, headers={"X-API-Key": API_KEY}, timeout=60)
    r.raise_for_status()
    return r.json()


page = get_page("https://www.youtube.com/watch?v=dQw4w9WgXcQ", sort="top")

if not page.get("comments"):
    print("No comments came back for this video")
else:
    print(page["video_id"], "| sort:", page["sort"], "| total_comments:", page["total_comments"])
    for c in page["comments"][:3]:
        print(f'{c["like_text"]:>5} likes | {c["reply_count"]:>4} replies | {c["published"]} | {c["author"]}')
        print("      " + c["text"].replace("\n", " "))
    print("more pages:", "yes" if page.get("next_cursor") else "no")

The output below comes from answers our API returned on 29 November 2026, saved before launch, with the comment text and handles replaced by invented ones. I ran the code above with only the HTTP request swapped for that file. The saved copy keeps the first two of the 20 comments the call returned, so the loop prints two comments where a full answer would print three.

dQw4w9WgXcQ | sort: top | total_comments: 2462804
 128K likes |  702 replies | 7 years ago | @viewer1
      Came back to hear this one more time
  73K likes |  728 replies | 7 years ago | @viewer2
      My study group shared this link instead of the notes
more pages: yes

The page-level fields are video_id, total_comments, comments_disabled, sort, next_cursor and the comments list. total_comments is the count YouTube showed at the time (2,462,804 here) and it appears on the first page only: on page two of the same walk it was null. The 128K and 73K are like_text, the label as YouTube displays it.

The code tests the comments list, not the HTTP status, because a video with nothing to give still answers normally. Three saved answers show it. A video with comments turned off came back with comments_disabled true, an empty comments list and a null next_cursor. A removed video and a well-formed id for a video that does not exist came back the same way, with comments_disabled false. A value that is not a video id or a YouTube video link is rejected with a 400 error.

Check the list before you write anything to your database. This continues the Python file:

off = get_page("e_04ZrNroTo")
print()
print(off["video_id"], "| comments_disabled:", off["comments_disabled"],
      "| comments:", len(off["comments"]), "| next_cursor:", off["next_cursor"])

Printed from the saved answer for the comments-off video:

e_04ZrNroTo | comments_disabled: True | comments: 0 | next_cursor: None

And in Node?

Node 18 and later includes fetch, so there is nothing to install. This version asks for the newest comments on the same video, then repeats the comments-off check. Save it as comments.mjs so top-level await works:

const API_KEY = "sk_live_your_api_key";
const BASE = "https://apiserpent.com/api/social/youtube/comments";

async function getPage(video, { sort = "top", cursor } = {}) {
  const params = new URLSearchParams({ video, sort });
  if (cursor) params.set("cursor", cursor);
  const res = await fetch(`${BASE}?${params}`, { headers: { "X-API-Key": API_KEY } });
  if (res.ok === false) throw new Error(`HTTP ${res.status}`);
  return res.json();
}

const page = await getPage("dQw4w9WgXcQ", { sort: "newest" });

if (!page.comments || page.comments.length === 0) {
  console.log("No comments came back for this video");
} else {
  console.log(`${page.video_id} | sort: ${page.sort} | total_comments: ${page.total_comments}`);
  for (const c of page.comments.slice(0, 2)) {
    console.log(`${c.published} | ${c.likes} likes | ${c.reply_count} replies | ${c.author}`);
    console.log(`  ${c.text}`);
  }
}

const off = await getPage("e_04ZrNroTo");
console.log();
console.log(`${off.video_id} | comments_disabled: ${off.comments_disabled} | comments: ${off.comments.length} | next_cursor: ${off.next_cursor}`);

Printed output, again from the saved answers with only fetch swapped for the file:

dQw4w9WgXcQ | sort: newest | total_comments: 2462805
7 minutes ago | 0 likes | 0 replies | @viewer4
  Playing this while I tidy my desk
31 minutes ago | 0 likes | 0 replies | @viewer5
  A friend sent me this link and I am not even mad

e_04ZrNroTo | comments_disabled: true | comments: 0 | next_cursor: null

These two comments were posted 7 and 31 minutes before the call, so they have no likes yet: likes is 0, like_text is an empty string, and replies_cursor is null because there are no replies to fetch. Across the 20 newest comments in the saved answer, 18 had no likes and 2 had one. The last line is the comments-off check in Node, where the same answer prints true and null.

What does one comment look like?

Each comment has fourteen fields: comment_id, text, author, author_channel_id, published, is_edited, likes, like_text, reply_count, replies_cursor, is_pinned, is_hearted, is_creator and is_verified. The figure shows the first comment from the Python output above.

Two fields differ from the official route. published is the text YouTube shows, such as "7 years ago", with no exact timestamp. likes is the number as shown, rounded above 999, so 128K arrives as 128000 beside like_text "128K".

Should you use sort=top or sort=newest?

Use top for a quick look at what viewers see first, and newest when you need a walk you can run again. top is YouTube's own ranking, and it can change between calls. Google's API offers the same two choices as relevance and time.

Here is how much it can move. In a check our team ran on 24 November 2026, the first page of two videos was fetched twice, 10 minutes apart. On one video 17 of the first 20 comments repeated and on the other 16. The second page was less stable, with 15 of 20 and 8 of 20 repeating.

Pass the cursor from the last page to continue; a new walk that starts over with top may come back in a different order. The saved answers from 29 November show the ranking is not simply by likes either: the second comment on page one has 73K likes and the first comment on page two has 85K.

With newest, fresh comments join the front of the list and older ones follow in order, so start each run from the first page and drop repeats by comment_id. How far you can page is whatever YouTube lets a visitor page through, and this post gives no number for it, so treat a missing next_cursor as the end and never assume you hold every comment.

How do you page through the comments?

Pass the next_cursor from one response as cursor on the next call, for the same video and sort. When it is null or missing, the pages have run out. This generator walks newest-first, skips repeats, and stops after a page limit you choose. It continues the Python file above and is example code, not run:

import time


def walk_newest(video, max_pages=5):
    """Yield comments newest first, one page per call, skipping repeats."""
    seen, cursor = set(), None
    for _ in range(max_pages):
        page = get_page(video, sort="newest", cursor=cursor)
        for c in page.get("comments", []):
            if c["comment_id"] not in seen:
                seen.add(c["comment_id"])
                yield c
        cursor = page.get("next_cursor")
        if not cursor:
            break
        time.sleep(0.5)


for comment in walk_newest("dQw4w9WgXcQ", max_pages=3):
    print(comment["published"], comment["text"])

Every call that completes is billed as one page, so the page limit caps your spending. A request we could not complete is refunded automatically; a call that completes and genuinely finds nothing (for example a video with comments off) is a real answer and is charged. If a page holds 20 comments, as it did in every saved answer here, a thousand comments is 50 calls; a small video or the last page returns fewer. The same loop in Node is a while over getPage that feeds the cursor back in.

How do you get the replies to a comment?

Send a comment's replies_cursor to /api/social/youtube/comments/replies with the same video. A call returns one page of replies, and the size of a page varies, so do not plan around a fixed number. In the saved answers, the first call for a thread of 702 replies returned 9 and the second returned 45. An earlier check of ours on 24 November 2026 (12 first calls on six videos, two each) saw between 1 and 10 on a first call.

Follow next_cursor for the rest. This continues the Python file and walks two calls:

REPLIES = "https://apiserpent.com/api/social/youtube/comments/replies"

first = page["comments"][0]
cursor = first["replies_cursor"]
print()
print(f'{first["reply_count"]} replies under the first comment')
for call in (1, 2):
    if not cursor:
        break
    r = requests.get(
        REPLIES,
        params={"video": page["video_id"], "cursor": cursor},
        headers={"X-API-Key": API_KEY},
        timeout=60,
    )
    r.raise_for_status()
    replies = r.json()
    got = replies["replies"]
    if not got:
        break
    print(f'call {call}: {len(got)} replies, the first has {got[0]["like_text"]} likes | {got[0]["published"]} | {got[0]["author"]}')
    cursor = replies.get("next_cursor")
print("more replies:", "yes" if cursor else "no")

Printed from the saved answers. After two calls there was still a next_cursor, so the thread had more to give:

702 replies under the first comment
call 1: 9 replies, the first has 6.5K likes | 7 years ago | @viewer24
call 2: 45 replies, the first has 34 likes | 6 years ago | @viewer32
more replies: yes

Those 54 replies are 7.7% of the 702. A reply has comment_id, text, author, author_channel_id, published, is_edited, likes, like_text and the three flags. Replies calls cost $0.47 per 1K API calls at pay as you go and $0.17 at the top tier, so the two calls above cost $0.00034 at the top tier. On the official route the matching call is comments.list with parentId.

How do the two routes compare, and what do they cost?

Serpent's YouTube Comments API is from $0.17 per 1K API calls (about $0.0085 per 1,000 comments) — pay as you go, no subscription. The lowest rate takes a $1,250 deposit; you can start with $10. A call is one page of comments, and the per-comment figure assumes 20 to a page, as in every saved answer here; a small video or the last page returns fewer, so the price per comment is higher there. The pricing page shows how deposit size sets the rate, and the YouTube comments price comparison sets it beside other sellers.

YouTube Data API v3 and a Serpent call, for reading the comments on one video. Google facts read 24 Nov 2026.
QuestionYouTube Data API v3Serpent API
What you needGoogle Cloud project, API keyOne key in an X-API-Key header
Comments per call1 to 100, default 20A page of top-level comments; 20 in each saved answer
What a call costs1 quota unit, 10,000 units a day by default, no cashFrom $0.17 per 1K API calls, pay as you go
Orderorder=time or order=relevancesort=newest or sort=top
Next pagepageToken from nextPageTokencursor from next_cursor
Date and likesExact date-time, exact count"7 years ago", likes as shown
RepliesA limited number inline, then comments.list with parentIdOne page per call from the replies endpoint; the size varies (9, then 45, in the saved answers)
Comments off, video removed or id not found403 commentsDisabled error when comments are offA normal response with an empty comments list; comments_disabled is true when comments are off

The Data API costs nothing in cash. You pay with setup and with a daily ceiling you have to watch. Serpent charges per call and needs one key, which suits comments feeding a product or a schedule.

Which route should you pick?

You can try a video in the playground before writing code. The YouTube API page lists what else sits under the same key.

How we checked this

Code. The Serpent snippets were run against the saved answers on Python 3.15.2 and Node 26.5.0. Only the network call was replaced by the saved file, so the printed output is what the snippets produced from answers our API returned. The request address, header and parameters were checked by the stand-in and no live call was made.

Saved answers. Answers our API returned on 29 November 2026, saved before launch: handles replaced by placeholders, channel ids replaced by UC…, comment ids replaced by invented ones (c01…), cursors replaced by a fixed string, and the text of every comment and reply replaced by invented text. The two sort=top pages are trimmed to 2 and 1 of the 20 comments each call returned; the newest page and both replies pages are complete.

Google's documentation. I read the quota, commentThreads.list, commentThreads, comments, comments.list and getting-started pages on 24 November 2026. None shows a last-updated date.

What I could not verify:

  • The official-route code is example code. I did not run it, because it needs a Google key and this post made no call to Google's API.
  • The Google pages I read do not say in so many words that an API key alone is enough for comments. Check the current authorisation rules before you build.
  • I did not read the YouTube API Services terms or the process for asking for more quota. Read both before building a product on the Data API.
  • The top-order stability figures (17 and 16 of 20 on page one, 15 and 8 of 20 on page two) come from a check on 24 November 2026 that I did not repeat on 29 November. It covered top only; how stable newest is between runs was not measured.
  • The saved answers hold one thread of replies, one comments-off video, one removed video and one id that does not exist. Reply page sizes of 9 and 45 describe that thread, not every thread.
  • How deep the cursor goes is not given here, because it depends on what YouTube lets a visitor page through.

Pull the comments on one video before you write much code

Serpent's YouTube Comments API is from $0.17 per 1K API calls (about $0.0085 per 1,000 comments) — pay as you go, no subscription. Paste a video link into the playground and see the JSON.

Get Your Free API Key

Explore: YouTube Comments API · Playground · Docs · Pricing

FAQ

How do I get YouTube comments in Python?

Send a GET request to the comments endpoint with the video link as the video parameter and your key in the X-API-Key header, then read the JSON. The response holds a comments list, a total_comments figure on the first page and a next_cursor for the next page. Check that the comments list is not empty before you save anything.

Is there an official YouTube API for comments, and is it free?

Yes. The YouTube Data API v3 has commentThreads.list, which costs 1 quota unit per call against a default of 10,000 units a day, and it charges no money. You need a Google Cloud project and a key, and each call returns up to 100 comments. Check Google's current documentation and terms before you build on it.

How many comments does one call return?

One Serpent call returns one page of top-level comments, 20 in each answer saved for this post, and the price is per call, not per comment. A small video or the last page returns fewer. The official Data API returns 1 to 100 per call, with 20 as the default. To read more, follow next_cursor from each response to the next page, and stop when it is null or missing.

Why do my comments change between two calls with sort=top?

The top order is YouTube's own ranking, and it changes over time. In a check our team ran on 24 November 2026, the first page of two videos was fetched twice, 10 minutes apart, and 17 and 16 of the first 20 comments repeated; page 2 repeated 15 and 8 of 20. Use sort=newest for a walk you can run again, and drop repeats by comment_id.

How do I get the replies to a comment?

Each comment carries a reply_count and a replies_cursor, which is null when there are no replies. Send the replies_cursor to the replies endpoint with the same video. Each call returns one page of replies and the size varies: in the saved answers a thread of 702 replies gave 9 on the first call and 45 on the second. next_cursor continues the list. Replies calls cost $0.47 per 1K API calls at pay as you go and $0.17 at the top tier.

Can I get exact timestamps for comments?

Not from this API. The published field is text as YouTube shows it, such as "7 years ago", and likes is the number as shown, with like_text holding the original label such as 128K. The official Data API returns an exact date and time and an exact like count, so use it when you need those values.

Sources

YouTube Data API documentation (read 24 Nov 2026):

Serpent data in this post: answers our API returned on 29 Nov 2026, saved before launch, a check of ours dated 24 Nov 2026, and the checks listed under "How we checked this". Pricing is on the pricing page.

Related Posts