Skip to content

Python guide

Scrape YouTube comments
with Python.
Download them to CSV.

Download the comments on a public YouTube video: text, likes, reply counts and dates, saved to CSV. One API key. No YouTube login, Google Cloud project or browser.

  • 1 creditper page
  • 100comments on each recorded page
  • 0Google Cloud projects
import csv
import os
import requests

API_URL = "https://www.monocrawl.com/v1/youtube/video/comments"
HEADERS = {"x-api-key": os.environ["MONOCRAWL_API_KEY"]}
VIDEO = "https://www.youtube.com/watch?v=ohqxP8EEumo"


def get_comments(video_url, order="relevance", max_pages=100):
    params = {"url": video_url, "order": order, "format": "plainText"}
    for _ in range(max_pages):
        body = requests.get(API_URL, params=params, headers=HEADERS, timeout=60).json()
        if not body.get("success"):
            raise RuntimeError(body["error"]["message"])
        yield from body["data"]["items"]
        cursor = body["data"].get("cursor")
        if not body["data"].get("has_more") or not cursor:
            break
        params["cursor"] = cursor


with open("comments.csv", "w", newline="", encoding="utf-8") as file:
    writer = csv.writer(file)
    writer.writerow(["id", "published_at", "likes", "replies", "author", "text"])
    for comment in get_comments(VIDEO):
        author = comment.get("author") or {}
        writer.writerow([comment["id"], comment.get("published_at"), comment.get("likes"),
                         comment.get("reply_count"), author.get("name"), comment.get("text") or ""])

$ python comments.py

GET /v1/youtube/video/comments order=relevance · page 1

✓ 100 comments · 1 credit · has_more: true

✓ page 2: 100 more · 1 credit · 0 repeats

↻ following the cursor until has_more is false

✓ comments.csv · this video: 8,392 comments ≈ 84 pages ≈ 84 credits (estimate)

Replay of a real call, recorded 26 Sep 2026

Four steps

Copy, paste, run.
See what each step returns.

Terminal
export MONOCRAWL_API_KEY="mn_your_key_here"
pip install requests

What you get

MONOCRAWL_API_KEY=mn_••••••••Free plan · 1,000 credits a month · No card

What comes back

One page.
Real comments.

A real page from Marques Brownlee’s iPhone 18 Pro review: 100 of its 8,392 comments, top comments first, for 1 credit. The first 8 are below, commenters left out.

  • idThe comment’s YouTube id
  • textWhat the commenter wrote
  • published_atWhen, as an ISO timestamp
  • likesLikes on the comment
  • reply_countReplies in its thread
  • repliesThe first few replies, inline
  • authorThe commenter’s channel name and link
  • has_moreWhether another page follows
  1. Of course, he had it for a year.

    20,27513516 Sept 2026
  2. Thanks, Marques. I will wait another year.

    11,62014216 Sept 2026
  3. As a photography nerd, that demonstration of what the aperture actually does in real time was super slick 👏

    2,6372116 Sept 2026
  4. as a Burgundy color lover, this is the best iPhone color apple has launched

    2221117 Sept 2026
  5. Don't you love it when the sponsor is at the end of the video? It's really annoying if it's in the middle of the video

    5,6683816 Sept 2026
  6. I always enjoy watching things I can't afford

    4,09611316 Sept 2026
  7. Beating the M5 in single core performance. Absolutely insane

    4,00511216 Sept 2026
  8. Please create one video comparing with iPhone 15 pro and/or 16 pro, most people upgrade their phones every 2-3 years. It would be really helpful for everyone

    98618 Sept 2026
Show the JSON
{
  "success": true,
  "data": {
    "video_id": "ohqxP8EEumo",
    "count": 100,
    "has_more": true,
    "cursor": "mlc1.…",
    "items": [
      {
        "id": "Ugz7SyJW6C1vkR0QBep4AaABAg",
        "text": "Of course, he had it for a year.",
        "published_at": "2026-09-16T12:05:57Z",
        "likes": 20275,
        "reply_count": 135
      },
      {
        "id": "UgzgH1OCVhjNe-5Xbm94AaABAg",
        "text": "Thanks, Marques. I will wait another year.",
        "published_at": "2026-09-16T12:43:29Z",
        "likes": 11620,
        "reply_count": 142
      },
      {
        "id": "UgyDfnexb26BP72vrAZ4AaABAg",
        "text": "As a photography nerd, that demonstration of what the aperture actually does in real time was super slick 👏",
        "published_at": "2026-09-16T18:22:07Z",
        "likes": 2637,
        "reply_count": 21
      },
      {
        "id": "UgySmpmNEM8atiAw4eN4AaABAg",
        "text": "as a Burgundy color lover, this is the best iPhone color apple has launched",
        "published_at": "2026-09-17T18:00:35Z",
        "likes": 222,
        "reply_count": 11
      },
      {
        "id": "UgzZoHJETKA_y71WLR14AaABAg",
        "text": "Don't you love it when the sponsor is at the end of the video? It's really annoying if it's in the middle of the video",
        "published_at": "2026-09-16T15:24:21Z",
        "likes": 5668,
        "reply_count": 38
      },
      {
        "id": "UgzaDKooaOX0SQ5P5Vt4AaABAg",
        "text": "I always enjoy watching things I can't afford",
        "published_at": "2026-09-16T12:12:29Z",
        "likes": 4096,
        "reply_count": 113
      },
      {
        "id": "Ugzay2zCfoi2FTgaxxN4AaABAg",
        "text": "Beating the M5 in single core performance. Absolutely insane",
        "published_at": "2026-09-16T12:10:47Z",
        "likes": 4005,
        "reply_count": 112
      },
      {
        "id": "UgzI25sNHhUksb8cBZd4AaABAg",
        "text": "Please create one video comparing with iPhone 15 pro and/or 16 pro, most people upgrade their phones every 2-3 years. It would be really helpful for everyone",
        "published_at": "2026-09-18T16:10:23Z",
        "likes": 98,
        "reply_count": 6
      }
    ]
  }
}

Cost

1 credit a page.
Nothing for failures.

Every page of up to 100 comments costs 1 credit, and replies cost the same. Both recorded pages returned 100. Slide to see what a video costs.

84credits, one per page
11videos like this a month on the free plan
119on Starter, $29 a month

Estimated at 100 comments a page, as on both recorded pages. Failed calls are free.

Two more things

Replies, errors
and rate limits.

Replies to a comment

Each comment carries its first few replies inline. For the whole thread, call youtube/video/comment/replies with the comment’s id: up to 100 replies a page, same cursor, 1 credit a page.

replies.py
REPLIES_URL = "https://www.monocrawl.com/v1/youtube/video/comment/replies"

params = {"comment_id": "UgzgH1OCVhjNe-5Xbm94AaABAg", "format": "plainText"}
body = requests.get(REPLIES_URL, params=params, headers=HEADERS, timeout=60).json()
for reply in body["data"]["items"]:
    print(reply["likes"], reply["text"])

Errors and rate limits

A failed call returns success: false with an error type and message, and costs nothing. On HTTP 429, wait and try again.

Rate limits by plan
comments.py
import time

def get_page(params, attempts=5):
    for attempt in range(attempts):
        response = requests.get(API_URL, params=params, headers=HEADERS, timeout=60)
        if response.status_code != 429:
            return response.json()
        time.sleep(2 ** attempt)
    raise RuntimeError("Still rate limited; try again later")

Other platforms

Same loop.
Swap the endpoint.

The same key collects comments from other platforms. Each endpoint’s reference lists its fields and paging.

Questions

Scraping YouTube comments,
answered.

Do I need a YouTube account, cookies or a browser?

No. You call Monocrawl with your API key and get the comments back as JSON. It works for public videos.

How many comments does one call return?

Up to 100. Both recorded pages returned 100, with has_more set to true and a cursor for the next page. Pass the cursor back with the same URL and order.

What does it cost?

1 credit for each page that comes back, and replies cost the same. The free plan’s 1,000 credits a month cover 1,000 pages, up to 100,000 comments, and failed calls are free.

Can I sort or filter the comments?

Yes. Set order to time for the newest first, or relevance for top comments first, as here. Add searchTerm to get only the comments that match a word or phrase.

Can I get the replies to a comment?

Yes. Each comment carries its first few replies inline. For the whole thread, call youtube/video/comment/replies with the comment’s id; it pages the same way.

Why not use YouTube’s own API?

YouTube’s own API needs a Google Cloud project and an API key, and has daily quotas. Our YouTube API comparison sets out the official route and the main providers side by side.

Start free

The comments on any public YouTube video.
1 credit a page.

1,000 free credits every month. No card required.

Get a free API key