Skip to the content
EnrichedNowDocs

    Type to search every page.

    Menu

    Scraper APIYouTube

    youtube.comments

    The comments under a YouTube video, top or newest first, with replies on request: text, likes, reply count, time, pinned and hearted marks, and the author's channel.

    Id
    youtube.comments
    Version
    1
    Billed per
    record — 1 unit for each record of a charged run
    Runs
    within one request

    Start it with POST /v1/scrapers/youtube.comments/runs. How runs work is in Running a scraper; what a run costs is in Usage and units.

    Inputs

    The fields of input. A field that is not listed here is refused.

    Inputs of youtube.comments
    FieldTypeDescription
    urlstringThe video's address: a youtube.com/watch, youtu.be, /shorts/, /live/ or /embed/ link.Limit: at most 500 characters.
    video_idstringThe video's 11-character id.Limit: at most 500 characters.
    sort"top" | "newest"The order: "top" (YouTube's default ranking) or "newest" first.Default: "top".
    max_resultsintegerThe most comments to return, replies included. Comments load 20 at a time, so a larger number takes longer.Limit: 1 to 500. Default: 20.
    replies_per_commentintegerHow many replies to return under each comment that has some. 0 returns top-level comments only.Limit: 0 to 50. Default: 0.
    • Give exactly one of url and video_id. Both, or neither, is refused with invalid_input.
    • sort is top (YouTube's own ranking, the default) or newest. A comment the channel pinned comes first in either order, with pinned true.
    • Comments load 20 at a time. max_results is 20 by default and goes up to 500, replies included; a larger number takes longer. If a later batch cannot be loaded, the run ends partial with the comments it has.
    • replies_per_comment is 0 by default: top-level comments only, each with its reply_count. Above 0, up to that many replies follow each comment that has some, with is_reply true and the comment's id in parent_id.
    • published_text is the time as YouTube words it ("3 weeks ago"); it shows no exact time. like_count is exact below a thousand and the rounded figure YouTube shows above ("223K" is 223000).
    • The author is returned as shown beside the comment: the name (usually a handle), the channel id and the channel's address. No picture is returned, and comments are read by video only.
    • A video with comments turned off, or with no comments yet, ends ok with zero records. A stream that is on air has a live chat and no comments, and a video behind a sign-in shows none: both end the run unsupported with comments_unavailable. A video that does not exist ends it failed with not_found.
    • Billed per record: a charged run costs 1 unit for each comment or reply it returns.

    Record fields

    Every record of a run has these fields. A value that is not known is null — never an empty string and never 0.

    Record fields of youtube.comments
    FieldTypeNotes
    positionintegerIts place among the returned records, from 1: comments in the order asked for, each followed by its replies.
    idstringThe comment's id.
    video_idstringThe id of the video it is under.
    urlstringA link that opens the video with this comment highlighted.
    is_replybooleanTrue for a reply to another comment, false for a top-level comment.
    parent_idstring or nullFor a reply: the id of the comment it answers; null for a top-level comment.
    textstring or nullThe comment's text.
    published_textstring or nullWhen it was posted, as shown ("3 weeks ago").
    editedbooleanYouTube marks the comment as edited.Default: false.
    like_count_textstring or nullThe likes as shown ("223K", "42"); null when no count is shown.
    like_countinteger or nullThe likes as a number: exact below a thousand, the rounded figure YouTube shows above; 0 when no count is shown.
    reply_countinteger or nullFor a top-level comment: how many replies it has; null for a reply.
    pinnedbooleanThe channel pinned this comment to the top.Default: false.
    heartedbooleanThe channel gave this comment its heart.Default: false.
    author_namestring or nullThe author's name as shown beside the comment, usually a handle ("@name").
    author_channel_idstring or nullThe author's channel id (UC…).
    author_channel_urlstring or nullThe author's channel address, as the page links it.
    author_is_channel_ownerboolean or nullTrue when the author is the channel that published the video.
    author_verifiedboolean or nullThe author's channel shows a verified or official-artist badge.

    Example request

    # Start a run and wait up to 60 seconds for it to finish
    curl -X POST "https://api.enrichednow.com/v1/scrapers/youtube.comments/runs?wait=60" \
      -H "Authorization: Bearer $ENRICHEDNOW_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"input":{"video_id":"jfKfPfyJRdk","max_results":6}}'
    
    # Read its records, with the id the first call answered
    curl "https://api.enrichednow.com/v1/runs/$RUN_ID/records?limit=100" \
      -H "Authorization: Bearer $ENRICHEDNOW_API_KEY"
    from enrichednow import EnrichedNow
    
    client = EnrichedNow()  # reads ENRICHEDNOW_API_KEY
    
    # Start a run, wait for it to end, and get its records
    result = client.scrape("youtube.comments", {
        "video_id": "jfKfPfyJRdk",
        "max_results": 6,
    })
    print(result.run.id, result.run.status, result.run.record_count)
    
    # Read its records: pages are fetched as you go
    for record in result.records:
        print(record)

    Install it with pip install enrichednow, then save as run.py and run python3 run.py

    import EnrichedNow from "enrichednow";
    
    const client = new EnrichedNow(); // reads ENRICHEDNOW_API_KEY
    
    // Start a run, wait for it to end, and get its records
    const { run, records } = await client.scrape("youtube.comments", {
      video_id: "jfKfPfyJRdk",
      max_results: 6,
    });
    console.log(run.id, run.status, run.record_count);
    
    // Read its records: pages are fetched as you go
    for await (const record of records) console.log(record);

    Install it with npm install enrichednow, then save as run.mjs and run node run.mjs

    package main
    
    import (
    	"context"
    	"fmt"
    	"log"
    	"time"
    
    	enrichednow "github.com/enrichednow/enrichednow-go"
    )
    
    func main() {
    	client, err := enrichednow.NewClient() // reads ENRICHEDNOW_API_KEY
    	if err != nil {
    		log.Fatal(err)
    	}
    	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
    	defer cancel()
    
    	// Start a run, wait for it to end, and get its records
    	run, records, err := client.Scrape(ctx, "youtube.comments", map[string]any{"video_id": "jfKfPfyJRdk", "max_results": 6})
    	if err != nil {
    		log.Fatal(err)
    	}
    	fmt.Println(run.ID, run.Status, run.RecordCount)
    
    	// Read its records: pages are fetched as you go
    	for records.Next() {
    		fmt.Println(string(records.Current()))
    	}
    	if err := records.Err(); err != nil {
    		log.Fatal(err)
    	}
    }

    Install it with go get github.com/enrichednow/enrichednow-go@latest, then save as run.go and run go run run.go

    import com.enrichednow.EnrichedNowClient;
    import com.enrichednow.ScrapeResult;
    import java.util.Map;
    
    public class Run {
        public static void main(String[] args) {
            EnrichedNowClient client = EnrichedNowClient.fromEnv(); // reads ENRICHEDNOW_API_KEY
    
            // Start a run, wait for it to end, and get its records
            ScrapeResult result = client.scrape("youtube.comments", Map.of("video_id", "jfKfPfyJRdk", "max_results", 6));
            System.out.println(result.run().id() + " " + result.run().status() + " " + result.run().recordCount());
    
            // Read its records: pages are fetched as you go
            for (Map<String, Object> record : result.records()) {
                System.out.println(record);
            }
        }
    }

    Add com.enrichednow:enrichednow-java:0.4.0 to your Maven or Gradle build, then save as Run.java

    enrichednow run youtube.comments --input video_id=jfKfPfyJRdk --input max_results=6

    Install it with curl -fsSL https://raw.githubusercontent.com/enrichednow/enrichednow-cli/main/install.sh | sh

    It starts a run with this scraper’s example input, waits for it to finish and reads its records a page at a time. The key is read from ENRICHEDNOW_API_KEY.

    The body on its own:

    JSON
    {
      "input": {
        "video_id": "jfKfPfyJRdk",
        "max_results": 6
      }
    }

    Example response

    The run, once it has ended. A run that has not ended within wait comes back with 202 and the status queued or running.

    JSON
    {
      "id": "run_841742f37553189ff9c27ba1",
      "scraper_id": "youtube.comments",
      "scraper_version": 1,
      "status": "ok",
      "reason": null,
      "input": {
        "video_id": "jfKfPfyJRdk",
        "max_results": 6
      },
      "record_count": 1,
      "units": 1,
      "units_per_request": null,
      "units_per_record": 1,
      "units_per_page": null,
      "diagnostics": {
        "requests": 1,
        "bytes": 259214,
        "wall_ms": 885,
        "facts": {}
      },
      "created_at": "2026-11-16T22:37:50.170950Z",
      "started_at": "2026-11-16T22:37:50.178331Z",
      "finished_at": "2026-11-16T22:37:51.066313Z"
    }

    Its records, from GET /v1/runs/{id}/records. The record is a real one: this scraper's own parser read it from a page recorded from the site.

    JSON
    {
      "records": [
        {
          "position": 1,
          "id": "UgwMz6w7c5oC_ZvYmzB4AaABAg",
          "video_id": "jfKfPfyJRdk",
          "url": "https://www.youtube.com/watch?v=jfKfPfyJRdk&lc=UgwMz6w7c5oC_ZvYmzB4AaABAg",
          "is_reply": false,
          "parent_id": null,
          "text": "The radio is back online, join us now: https://youtu.be/EWrX250Zhko \nThank you for your patience🧡",
          "published_text": "5 months ago",
          "edited": false,
          "like_count_text": "42",
          "like_count": 42,
          "reply_count": 2,
          "pinned": true,
          "hearted": false,
          "author_name": "@LofiGirl",
          "author_channel_id": "UCSJ4gkVC6NrvII8umztf0Ow",
          "author_channel_url": "https://www.youtube.com/@LofiGirl",
          "author_is_channel_owner": true,
          "author_verified": true
        }
      ],
      "next_cursor": null
    }

    A run does not always end ok. Results and statuses lists every status and the reasons every scraper shares; the reasons of the YouTube scrapers are in their own section there.