YouTube-Web-V2-API

获取视频评论/Get video comments

Changed on

[中文]

用途:

  • 获取YouTube视频的一级评论

参数详解:

📌 必选参数:

video_id (string)

  • 作用: 视频ID
  • 格式: YouTube视频ID字符串
  • 示例: "oaSNBz4qMQY"
  • 获取方式: 从URL https://www.youtube.com/watch?v=oaSNBz4qMQY 中提取

⚙️ 可选参数:

language_code (string, 可选)

  • 作用: 设置评论显示的语言偏好
  • 默认值: "zh-CN"
  • 可用值: "zh-CN", "en-US", "ja-JP", "ko-KR" 等

country_code (string, 可选)

  • 作用: 设置地区代码
  • 默认值: "US"
  • 可用值: "US", "JP", "GB" 等

sort_by (string, 可选)

  • 作用: 评论排序方式
  • 默认值: "top"
  • 可用值:
    • "top" - 热门评论(按点赞数排序)
    • "newest" - 最新评论(按时间排序)

continuation_token (string, 可选)

  • 作用: 翻页令牌,用于获取下一页评论
  • 默认值: null
  • 获取方式: 从上一次请求的响应中提取

need_format (boolean, 可选)

  • 作用: 是否返回清洗后的精简数据
  • 默认值: true
  • 可用值:
    • false - 返回原始完整数据
    • true - 返回清洗后的精简数据(推荐,默认)

返回数据结构 (need_format=true):

{
  "comments": [
    {
      "comment_id": "UgzRDoUJAvDNn5_8i8p4AaABAg",
      "content": "评论内容文本",
      "published_time": "1天前",
      "reply_level": 0,
      "like_count": "2",
      "like_count_a11y": "2 次赞",
      "reply_count": "0",
      "reply_count_a11y": "0 条回复",
      "reply_count_text": "1 条回复",
      "reply_continuation_token": "...",
      "author": {
        "channel_id": "UCzRzHrLFuH0lHZYnrI84I8Q",
        "display_name": "@username",
        "channel_url": "https://www.youtube.com/@username",
        "avatar_url": "https://yt3.ggpht.com/...",
        "avatar_thumbnails": [
          {"url": "...", "width": 88, "height": 88}
        ],
        "is_verified": false,
        "is_creator": false,
        "is_artist": false
      },
      "creator_thumbnail_url": "https://yt3.ggpht.com/..."
    }
  ],
  "continuation_token": "下一页token"
}

字段说明:

  • comment_id: 评论唯一ID
  • content: 评论文本内容
  • published_time: 发布时间(相对时间,如"1天前")
  • reply_level: 回复层级(0表示一级评论)
  • like_count: 点赞数
  • reply_count: 回复数
  • reply_count_text: 回复数文本(如"1 条回复")
  • reply_continuation_token: 获取该评论回复的token
  • author: 评论作者信息
    • channel_id: 作者频道ID
    • display_name: 显示名称
    • channel_url: 频道URL
    • avatar_url: 头像URL
    • is_verified: 是否已认证
    • is_creator: 是否为视频创作者
    • is_artist: 是否为音乐人
  • creator_thumbnail_url: 视频创作者头像URL

[English]

Purpose:

  • Get YouTube video first-level comments

Parameters:

📌 Required:

video_id (string)

  • Purpose: Video ID
  • Format: YouTube video ID string
  • Example: "oaSNBz4qMQY"
  • How to get: Extract from URL https://www.youtube.com/watch?v=oaSNBz4qMQY

⚙️ Optional:

language_code (string, optional)

  • Purpose: Set language preference for comments
  • Default: "zh-CN"
  • Values: "zh-CN", "en-US", "ja-JP", "ko-KR", etc.

country_code (string, optional)

  • Purpose: Set region code
  • Default: "US"
  • Values: "US", "JP", "GB", etc.

sort_by (string, optional)

  • Purpose: Comment sorting method
  • Default: "top"
  • Values:
    • "top" - Top comments (sorted by likes)
    • "newest" - Newest comments (sorted by time)

continuation_token (string, optional)

  • Purpose: Pagination token for next page
  • Default: null
  • How to get: Extract from previous response

need_format (boolean, optional)

  • Purpose: Whether to return cleaned simplified data
  • Default: true
  • Values:
    • false - Return raw complete data
    • true - Return cleaned simplified data (recommended, default)

Response Structure (need_format=true):

{
  "comments": [
    {
      "comment_id": "UgzRDoUJAvDNn5_8i8p4AaABAg",
      "content": "Comment text content",
      "published_time": "1 day ago",
      "reply_level": 0,
      "like_count": "2",
      "like_count_a11y": "2 likes",
      "reply_count": "0",
      "reply_count_a11y": "0 replies",
      "reply_count_text": "1 reply",
      "reply_continuation_token": "...",
      "author": {
        "channel_id": "UCzRzHrLFuH0lHZYnrI84I8Q",
        "display_name": "@username",
        "channel_url": "https://www.youtube.com/@username",
        "avatar_url": "https://yt3.ggpht.com/...",
        "avatar_thumbnails": [
          {"url": "...", "width": 88, "height": 88}
        ],
        "is_verified": false,
        "is_creator": false,
        "is_artist": false
      },
      "creator_thumbnail_url": "https://yt3.ggpht.com/..."
    }
  ],
  "continuation_token": "next page token"
}

Field Descriptions:

  • comment_id: Unique comment ID
  • content: Comment text content
  • published_time: Published time (relative, e.g., "1 day ago")
  • reply_level: Reply level (0 for first-level comments)
  • like_count: Number of likes
  • reply_count: Number of replies
  • reply_count_text: Reply count text (e.g., "1 reply")
  • reply_continuation_token: Token to get replies for this comment
  • author: Comment author info
    • channel_id: Author's channel ID
    • display_name: Display name
    • channel_url: Channel URL
    • avatar_url: Avatar URL
    • is_verified: Whether verified
    • is_creator: Whether video creator
    • is_artist: Whether artist
  • creator_thumbnail_url: Video creator's avatar URL

[示例/Examples]

获取热门评论

GET /youtube_web/get_video_comments?video_id=oaSNBz4qMQY&sort_by=top

获取最新评论

GET /youtube_web/get_video_comments?video_id=oaSNBz4qMQY&sort_by=newest

获取清洗后的评论数据(推荐)

GET /youtube_web/get_video_comments?video_id=oaSNBz4qMQY&need_format=true

翻页获取更多评论

GET /youtube_web/get_video_comments?video_id=oaSNBz4qMQY&continuation_token=xxx&need_format=true

get/api/v1/youtube/web_v2/get_video_comments

Request

  • Base URL
    https://api.tikhub.io (the document declares no server; this is the origin it was published from)
  • Auth
    HTTP bearer

Query parameters

video_idstring required

视频ID/Video ID

language_codestring

语言代码(如zh-CN, en-US等)/Language code

country_codestring

国家代码(如US, JP等)/Country code

sort_by'top' | 'newest'

评论排序方式

排序方式 | Sort by

continuation_tokenstring

翻页令牌/Pagination token

need_formatboolean

是否需要清洗数据,提取关键内容,移除冗余数据/Whether to clean and format the data

Response

Successful Response

codeinteger

HTTP status code | HTTP状态码

request_idstring nullable

Unique request identifier | 唯一请求标识符

messagestring

Response message (EN-US) | 响应消息 (English)

message_zhstring

Response message (ZH-CN) | 响应消息 (中文)

supportstring

Support message | 支持消息

timestring

The time the response was generated | 生成响应的时间

time_stampinteger

The timestamp the response was generated | 生成响应的时间戳

time_zonestring

The timezone of the response time | 响应时间的时区

docsstring nullable

Link to the API Swagger documentation for this endpoint | 此端点的 API Swagger 文档链接

cache_messagestring nullable

Cache message (EN-US) | 缓存消息 (English)

cache_message_zhstring nullable

Cache message (ZH-CN) | 缓存消息 (中文)

cache_urlstring nullable

The URL to access the cached result | 访问缓存结果的 URL

routerstring

The endpoint that generated this response | 生成此响应的端点

paramsunknown
dataunknown

Changes

    • info

      added the optional property // to the response with the status

    • info

      added the optional property // to the response with the status

    • info

      the response's property default value changed from This request will be cached. You can access the cached result directly using the URL below valid for 24 hours. Accessing the cache will not incur additional charges. to This response is cached and accessible via the URL below for 24 hours at no extra cost. The cache is for request tracing only — it doesn't affect the API's data freshness and won't be returned through the API again. for the status

    • info

      the response's property default value changed from 本次请求将被缓存,你可以使用下面的 URL 直接访问缓存结果,有效期为 24 小时,访问缓存不会产生额外费用。 to 本次响应已缓存,可通过下方 URL 直接查看,有效期 24 小时,访问缓存链接无额外费用。缓存仅用于请求溯源,不影响接口数据的时效性,也不会再次通过接口返回。 for the status