接口说明

YouTube Comments API 获取 YouTube 评论数据,支持接口列出的分页、排序或筛选参数。

使用 Pangolinfo API Key 调用,返回结构化 JSON 数据。

请求URL

POST https://scrapeapi.pangolinfo.com/api/v1/social/youtube-comments

请求头

参数名参数值类型说明
Content-Typeapplication/jsonstring数据格式
AuthorizationBearer xxxstring认证凭证

采集最长约75秒,客户端超时建议设为90秒。

请求参数

参数必填类型说明
targetYesstring帖子链接; 也可直接传视频 id (如 dQw4w9WgXcQ)
optionsNoobject仅处理下列开放参数;未列出的字段忽略,内部参数不可覆盖。

options 参数说明

参数必填类型说明
maxPagesNointeger本次请求翻几页,默认 1,最大 5,按实际返回条数计费,更多数据用返回的游标续取
默认值: 1
最小值: 1
最大值: 5
cursorNostring | null续取评论: 上次输出的 pagination.comments.cursor (top:/new: 前缀); 回复模式: 必填, 评论输出的 replyCursor, 或上次输出的 pagination.cursor
sortNostring不指定: 热门前两页 + 最新补齐; 指定则只采该排序;可选值:top / new
可用值: [“top”, “new”]
commentIdNostring回复模式: 主评论 commentId (评论输出的 commentId)

仅处理本页列出的请求参数,其他字段忽略。分页游标原样传回,不编码、解码或转换格式。

每次默认1页,最多5页;页数必须为正整数,超过5按5处理。

提供非空commentId进入独立回复模式,按返回的直接回复计费;Facebook同时计入返回的嵌套回复。按本页cursor说明续取。

普通评论模式每条评论最多自动附带200条回复;独立回复模式按页获取,不另设200条总数限制。

响应值

返回值类型说明
codeinteger状态码,0 表示成功
messagestring响应信息,成功时为 ok
pointCostnumber本次请求实际消耗的积点
dataobject返回数据,结构见下表
metaobject请求标识及耗时(毫秒)
billingobject计费条数、单价及规则版本

返回参数 data 说明

返回值类型说明
typestringcomments = 评论模式; replies = 回复模式 (传了 options.commentId)
可用值: [“comments”, “replies”]
commentsCountnumber | null评论模式: 评论总数
commentsobject[]评论模式: 评论, 与 youtube-post 同形
commentIdstring回复模式: 父评论 id
repliesobject[]回复模式: 回复, 与评论 replys[] 同形
paginationobject评论模式: {comments: {cursor, hasMore}}; 回复模式: {cursor, hasMore}

data.comments[] 字段说明

返回值类型说明
timeTextobject评论时间 (注意键是 timestamp 不是 value)
contentstring | null评论内容
likeCountnumber | null点赞数
replyCountnumber | null回复数
avatarstring | null评论者头像
nicknamestring | null评论者显示名 (@handle)
profileUrlstring | null评论者频道链接
commentIdstring评论 id; 回复模式传 options.commentId 用它
parentIdstring | null父评论 id; 顶层为 null
authorChannelIdstring | null评论者频道 id
authorIsVerifiedboolean评论者是否认证
authorIsCreatorboolean是否视频作者本人
authorIsArtistboolean是否官方艺人频道
replyLevelnumber | null层级: 0 顶层, 1 回复
timestampsobject[]正文里提到的视频时间点
replyCursorstring | null回复首页游标: 回复模式传 options.cursor (与 commentId 一起); 无回复为 null
replysobject[]附带的一级回复;视频详情不主动展开回复,普通评论模式每条评论最多自动附带200条回复。

data.comments[].timeText 字段说明

返回值类型说明
textstring | null相对时间原文, 如 “6 years ago (edited)“
timestampnumber | null按相对时间推算的毫秒时间戳 (近似值)

data.comments[].timestamps[] 字段说明

返回值类型说明
textstring原文, 如 1:23
secondsnumber秒数

data.comments[].replys[] 字段说明

返回值类型说明
timeTextobject评论时间 (注意键是 timestamp 不是 value)
contentstring | null评论内容
likeCountnumber | null点赞数
replyCountnumber | null回复数
avatarstring | null评论者头像
nicknamestring | null评论者显示名 (@handle)
profileUrlstring | null评论者频道链接
commentIdstring评论 id; 回复模式传 options.commentId 用它
parentIdstring | null父评论 id; 顶层为 null
authorChannelIdstring | null评论者频道 id
authorIsVerifiedboolean评论者是否认证
authorIsCreatorboolean是否视频作者本人
authorIsArtistboolean是否官方艺人频道
replyLevelnumber | null层级: 0 顶层, 1 回复
timestampsobject[]正文里提到的视频时间点
replyCursorstring | null回复首页游标: 回复模式传 options.cursor (与 commentId 一起); 无回复为 null
replysany[]不再向下展开, 恒为空

data.replies[] 字段说明

返回值类型说明
timeTextobject评论时间 (注意键是 timestamp 不是 value)
contentstring | null评论内容
likeCountnumber | null点赞数
replyCountnumber | null回复数
avatarstring | null评论者头像
nicknamestring | null评论者显示名 (@handle)
profileUrlstring | null评论者频道链接
commentIdstring评论 id; 回复模式传 options.commentId 用它
parentIdstring | null父评论 id; 顶层为 null
authorChannelIdstring | null评论者频道 id
authorIsVerifiedboolean评论者是否认证
authorIsCreatorboolean是否视频作者本人
authorIsArtistboolean是否官方艺人频道
replyLevelnumber | null层级: 0 顶层, 1 回复
timestampsobject[]正文里提到的视频时间点
replyCursorstring | null回复首页游标: 回复模式传 options.cursor (与 commentId 一起); 无回复为 null
replysany[]不再向下展开, 恒为空

请求示例

curl --request POST \
  --url https://scrapeapi.pangolinfo.com/api/v1/social/youtube-comments \
  --header 'Authorization: Bearer YOUR_PANGOLINFO_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "target": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}'

返回示例

下例截取实际响应中的首条列表记录,长文本与链接作了缩写;pointCost 为该次完整响应的实际费用。完整字段结构可在在线调试页查看。

{
  "code": 0,
  "message": "ok",
  "pointCost": 6.4,
  "data": {
    "type": "comments",
    "commentsCount": 2400000,
    "comments": [
      {
        "timeText": {
          "text": "6 years ago (edited)",
          "timestamp": 1604738279831
        },
        "content": "I Rick rolled my entire French class because we had to study a city in France and make a quiz about it as well as a presentation, I decided to make a Kahoot ...",
        "likeCount": 107000,
        "replyCount": 677,
        "avatar": "https://yt3.ggpht.com/ytc/AIdro_kDD-FhIbth2qcBbI9VGxR41dJa0kE3kN9iVlGzNgRU_g=s88-c-k-c0x00ffffff-no-rj",
        "nickname": "@grustache4569",
        "profileUrl": "https://www.youtube.com/channel/UCKrzgYonJnMd0Dk7zQXjYXw",
        "replys": [],
        "commentId": "UgzKYksqeQ5gA3t0g0F4AaABAg",
        "parentId": null,
        "authorChannelId": "UCKrzgYonJnMd0Dk7zQXjYXw",
        "authorIsVerified": false,
        "authorIsCreator": false,
        "authorIsArtist": false,
        "replyLevel": 0,
        "timestamps": [],
        "replyCursor": "Eg0SC2RRdzR3OVdnWGNRGAYygwEaUBIaVWd6S1lrc3FlUTVnQTN0MGcwRjRBYUFCQWciAggAKhhVQ3VBWEZrZ3N3MUw3eGFDZm5kNUpKT3cyC2RRdzR3OVdnWGNRQAFICoIBAggBQi9jb21tZW50LXJlcGxpZ..."
      }
    ],
    "pagination": {
      "comments": {
        "cursor": "top:Eg0SC2RRdzR3OVdnWGNRGAYyWCIxIgtkUXc0dzlXZ1hjUTAAeAKqAhpVZ3pLWWtzcWVRNWdBM3QwZzBGNEFhQUJBZ_ADATABQiFlbmdhZ2VtZW50LXBhbmVsLWNvbW1lbnRzLXNlY3Rpb24%3D",
        "hasMore": true
      }
    }
  },
  "meta": {
    "requestId": "pg-audit-r1-youtube-comments-1793954272596989200",
    "durationMs": 6196
  },
  "billing": {
    "unitPrice": 0.8,
    "ruleVersion": "social-primary-v2",
    "billedCount": 8,
    "pointCost": 6.4
  }
}

积点消耗说明

每条一级评论消耗 0.8 积点,附带回复免费。支持独立回复模式的接口按返回的直接回复条数计费,每条0.8积点,回复附带的下一层免费。

空结果、失败响应不扣费。同一响应中相同 ID 只计一次,独立调用和续页分别计费。详见 社媒评论 API 计费说明。

在线调试