YouTube Comments API - Extract Video Comments
FetchLayer fetchlayer.dev Sign in

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

Full YouTube video URL.

sort string required

Sort order: top (most liked) or newest. (default: top)

limit number optional

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

pages number optional

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

Response Fields

comments

Extract YouTube comments

[].username string

Comment author username (with @).

[].comment string

Full comment text.

[].likes number

Number of likes.

[].hasReplies boolean

Whether this comment has nested replies.

[].date string

Relative date string (e.g. "1 day ago").

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"}'

Response

[
  {
    "username": "@User123",
    "comment": "Great video!",
    "likes": 42,
    "hasReplies": true,
    "date": "1 day ago"
  }
]