Nimbryxo Studio

Use YouTube Video Comment & Reply Thread Scraper with Python

Get a YouTube video's comments with nested replies attached, author identity, like counts, and pinned/hearted/verified flags, filterable by keyword and minimum likes.

1. Choose the data you need

Review the published README for supported collection modes, examples, and limits. The recipe below uses the current published input definition.

2. Prepare a source-based input

This JSON contains published prefills and required-field defaults. Review every value for your task before running it; it is not a promise of successful collection.

{
  "channelUrls": [],
  "emitStatusRows": true,
  "includeReplies": true,
  "keywords": [],
  "maxComments": 3,
  "maxRepliesPerComment": 3,
  "maxReplyDepth": 1,
  "maxTotalRows": 20,
  "minLikes": 0,
  "onlyCreatorHearted": false,
  "outputMode": "flat",
  "playlistUrls": [],
  "searchQueries": [],
  "sortBy": "top",
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ]
}

Download input.example.json and save your reviewed copy as input.json.

FieldTypeRequiredDescription
videoUrlsarrayoptionalWatch, youtu.be, Shorts, embed, live, v/ links, or bare 11-character IDs. Every video is normalized to a watch URL internally.
channelUrlsarrayoptionalChannel /videos sources: /@handle, /channel/UC..., /c/name, /user/name, a bare @handle, or a UC... channel ID. Scrapes up to Max videos per source.
playlistUrlsarrayoptionalPlaylist sources: youtube.com/playlist?list=... or a bare playlist ID. Scrapes up to Max videos per source.
searchQueriesarrayoptionalYouTube search terms or search-result URLs. Only video results are used, deduplicated, up to Max videos per source.
maxVideosPerSourceintegeroptionalDiscovery cap for channel, playlist and search sources. 0 = every video the source exposes.
maxCommentsintegeroptionalTop-level comments to examine per video. 0 = all. Comments rejected by filters still count toward this scan cap (so restrictive filters cannot paginate forever); replies do not. Both emitted comments and replies count toward Max total rows.
includeRepliesbooleanoptionalFetch reply threads. Emitted as flat rows by default; use Output mode tree to embed them instead.
maxRepliesPerCommentintegeroptionalPer-thread reply cap. 0 = all replies, stopping when the continuation token is exhausted. YouTube serves roughly 9-10 on the first reply page and 44-49 afterwards.
maxReplyDepthintegeroptional0 = top-level comments only, 1 = direct replies (the shape observed publicly). Values above 1 are reserved for nested sub-threads, which YouTube has not exposed in the samples used to build this actor.
maxTotalRowsintegeroptionalGlobal budget for emitted comment + reply rows. 0 = unlimited. Status rows are never counted and are not billable data rows.
sortBystringoptionaltop = YouTube relevance order; newest = chronological, recommended for date cutoffs and complete windows. A date cutoff forces newest automatically.
commentsSincestringoptionalOptional cutoff as an ISO date/datetime (2026-10-16) or relative duration (7d, 24h, 30m). Forces newest sort. Pinned comments are always kept; pagination stops at the first non-pinned comment older than the cutoff.
keywordsarrayoptionalCase-insensitive OR filter on comment and reply text. Empty = no keyword filter. A parent comment that does not match is skipped, so its replies are not fetched.
minLikesintegeroptionalDrop comments and replies below this like count. Applied after fetching. YouTube only exposes rounded counts (K/M), so the comparison uses the rounded value.
onlyCreatorHeartedbooleanoptionalKeep only comments/replies that the video creator hearted. HeartedBy identifies the creator where YouTube exposes the tooltip.
outputModestringoptionalflat = one row per comment and reply (recommended for CSV/Excel/SQL); tree = parent rows with embedded replies[] (backward compatible); both = flat rows plus parent rows carrying replies[].
emitStatusRowsbooleanoptionalWrite one recordType=status row for blocked, private, unavailable, comments-off, empty-token, invalid-input, partial and budget-stop cases. Status rows are never counted toward Max total rows; disable this to keep the dataset data-only.

3. Start an Actor run

Set APIFY_TOKEN in your environment. Python 3.10 or newer is sufficient; this recipe uses no third-party packages.

Execution may incur charges. Review current pricing on Apify. The request asks for a 120-second timeout and a charge limit; these settings are subject to Apify’s pricing and do not guarantee an all-inclusive spending cap.

import json
import os
import urllib.request

# Save the schema-derived example as input.json; review and edit it first.
with open("input.json", encoding="utf-8") as stream:
    actor_input = json.load(stream)

token = os.environ["APIFY_TOKEN"]
request = urllib.request.Request(
    "https://api.apify.com/v2/acts/jrued2m8jluwhSMcX/runs?timeout=120&maxTotalChargeUsd=0.50",
    data=json.dumps(actor_input).encode("utf-8"),
    headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
    method="POST",
)
# This starts a potentially billable run. Do not automatically retry this POST.
with urllib.request.urlopen(request, timeout=40) as response:
    run = json.load(response)["data"]
print("Run ID:", run["id"])
print("Status:", run["status"])
# Inspect and download results in Apify Console once the run succeeds.

4. Inspect the actual results

Open the run in Apify Console and wait for a successful completion. Use the published output schema to locate results and the dataset schema to understand declared views. Missing or optional record fields must not be treated as guaranteed values.

Flat comment and reply rows with author identity, rounded engagement counts, honest approximate dates, thread fields, video statistics, and optional status rows.

Questions before you run

Which inputs are required?

No top-level fields are marked required in the published schema. Conditional requirements can still apply; check the README.

What does this guide verify?

The fields, prefills, and schema links are rendered from the published build. This is a usage recipe, not a paid live extraction test. Source availability and collection results can vary.

What if the run request times out?

Check Apify Console before retrying. The first request may already have created a run. Do not automatically repeat a run-creation POST.

Generated from source build 0a5GXomczgZPh2iFX and its README and schemas. Source changes regenerate this guide; no third-party editorial claims are inferred.