YouTube API — Endpoints — FetchLayer Docs
FetchLayer fetchlayer.dev Sign in

Endpoints

All endpoints follow the same pattern: POST https://api.fetchlayer.dev/youtube/{endpoint} with a JSON body and Bearer auth header.

TypeScript / JavaScript? Use the open-source SDK: @fetchlayer/youtube on npm · Source on GitHub

OpenAPI JSON

Comments

Extract comments and nested replies from YouTube videos.

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

Extract YouTube comments

Collects top-level comments and nested replies from a YouTube video. Supports sorting by top or newest, configurable reply depth, and pagination through the comment section.

Parameters

Name Type Required Description
videoUrl string Yes Full YouTube video URL.
sort string Yes Sort order: top (most liked) or newest. (default: top)
depth number No Levels of replies to include (0 = top-level only, no replies). (default: 0)
pages number No Number of scrolls for more comments. (default: 1)

Example Request

json
{
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "sort": "top"
}

Example Response

json
[
  {
    "username": "@User123",
    "comment": "Great video!",
    "likes": 42,
    "hasReplies": true,
    "date": "1 day ago",
    "nestedReplies": [
      {
        "username": "@ReplyUser",
        "comment": "Agreed!",
        "likes": 5,
        "hasReplies": false,
        "date": "1 day ago"
      }
    ]
  }
]

Response Fields

comments

Extract YouTube comments

Field Type Description
[].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").
[].nestedReplies object[] Nested reply comments (same structure, recursive).