YouTube Comments API - Extract Video Comments

Extract YouTube comments

Collects top-level comments from a YouTube video. Supports sorting by top or newest and pagination through the comment section. Use the separate replies endpoint to load a specific comment thread.

POST /comments Comments
https://api.fetchlayer.dev/youtube/comments
OpenAPI JSON

Headers

Authorization string required

Bearer token — your FetchLayer API key.

Parameters

videoUrl string required

YouTube video URL or 11-character video ID. Also accepts youtube.com/live/ and /embed/ links, m.youtube.com and music.youtube.com links, and http://. A URL is echoed unchanged.

sort string optional

Sort order: top (most liked) or newest. YouTube can reorder top comments between two requests; newest keeps a fixed order. (default: top)

limit integer optional

Maximum number of top-level comments to return. Defaults to no limit, in which case pages decides how many come back.

pages integer optional

Number of comment batches to collect. More pages return more comments. (default: 1)

cursor string optional

Continue where a previous response stopped: pass its nextCursor, with the same videoUrl and sort. It picks up right after the last comment returned and never repeats a comment already returned. With sort top, YouTube may reorder comments between requests, so a comment can move into the part already read and be missed; use newest for a complete walk.

Response Fields

comments

Extract YouTube comments

comments object[]

Top-level comments, in the requested sort order.

comments[].id string | null

Comment ID, for the replies endpoint.

comments[].username string

Comment author username (with @).

comments[].comment string

Full comment text.

comments[].likes number

Number of likes, as YouTube shows it (rounded above 1,000).

comments[].hasReplies boolean

Whether this comment has replies.

comments[].replyCount number | null

Number of replies YouTube shows for the comment.

comments[].date string

When it was posted, as YouTube words it (e.g. "1 day ago"). YouTube shows no exact date for comments.

comments[].authorChannelId string | null

The commenter's channel ID (UC…).

comments[].authorIsVerified boolean | null

Whether the commenter's channel is verified.

comments[].authorIsChannelOwner boolean | null

Whether the commenter is the channel that posted the video.

comments[].isHearted boolean | null

Whether the video owner hearted the comment.

totalCommentCount number | null

The video's total comment count, when YouTube shows it.

fetchedCommentCount number

Comments returned in this response.

pagesFetched number

Comment batches collected for this response.

nextCursor string | null

Pass as cursor (same videoUrl and sort) for the next comments; null when there are no more.

Request

curl -X POST "https://api.fetchlayer.dev/youtube/comments" \
  -H "Authorization: Bearer ss-your-key" \
  -H "Content-Type: application/json" \
  -d '{"videoUrl":"https://www.youtube.com/watch?v=dQw4w9WgXcQ","sort":"top","limit":1}'

Response

{
  "comments": [
    {
      "id": "UgyEnXfdC-umwvTt8JF4AaABAg",
      "username": "@User123",
      "comment": "Great video!",
      "likes": 42,
      "hasReplies": true,
      "replyCount": 3,
      "date": "1 day ago",
      "authorChannelId": "UCdi6tGxvFvTRGe-7dAn7m7w",
      "authorIsVerified": false,
      "authorIsChannelOwner": false,
      "isHearted": false
    }
  ],
  "totalCommentCount": 2461470,
  "fetchedCommentCount": 1,
  "pagesFetched": 1,
  "nextCursor": "flc1.…"
}
Product overview YouTube API: what it returns, pricing and use cases