Bilibili-Web-API
获取番剧分集评论/Get bangumi episode comments
Changed on[中文]
用途:
- 获取指定番剧分集的可见评论,支持正片及附加分集。
参数:
- ep_id: 分集ID,例如链接 /bangumi/play/ep359441 中的 359441。
- ep_id为正整数,不包含ep前缀;这里的评论属于指定分集,不是整季点评。
- mode: 3为热门(默认),2为时间。
- pagination_str: 首页留空或传 {"offset":""};后续传 {"offset":"上一页的next_offset值"}。
- pagination_str必须为仅包含offset字符串的JSON对象,最长16384个字符,作为单个查询参数传递。
返回与翻页:
- data.data.replies: 评论列表;data.data.top_replies: 置顶评论。
- data.data.cursor.all_count: 评论总数,可能高于当前可获取的评论数量。
- data.data.cursor.pagination_reply.next_offset: 下一页offset,作为字符串原样使用;其值可能保持不变。
- data.data.cursor.is_end 为true时停止翻页,不再发起下一页请求。
- 翻页时保持ep_id和mode不变;更换分集或排序时清空pagination_str,重新从首页开始。
- 不要把offset转换为数字、解析后重建,或因其值未改变而认定结束;以is_end为准。
- 每页数量可能变化,不要用固定条数判断结束;rpid可用于评论去重。
请求与翻页示例:
GET /api/v1/bilibili/web/fetch_bangumi_comments?ep_id=359441&mode=3
下一页将本次响应的next_offset直接放入JSON,整个JSON作为pagination_str参数传递:
import json
cursor = response["data"]["data"]["cursor"]
if not cursor["is_end"]:
pagination_str = json.dumps(
{"offset": cursor["pagination_reply"]["next_offset"]}, ensure_ascii=False
)
NEXT_OFFSET仅为下方示例中的占位符,实际请求使用响应中的原始值。
响应结构示例(字段及评论已省略):
{
"code": 200,
"data": {
"code": 0,
"data": {
"replies": [{"rpid": 123456789, "oid": 415180064, "content": {"message": "评论内容"}}],
"top_replies": [],
"cursor": {
"all_count": 2465,
"is_end": false,
"pagination_reply": {"next_offset": "NEXT_OFFSET"}
}
}
}
}
错误:
- 422: ep_id、mode或pagination_str格式不合法。
- 400: 未能获取有效的分集评论。
[English]
Purpose:
- Get visible comments for a regular or additional bangumi episode.
Parameters:
- ep_id: Episode ID, such as 359441 in /bangumi/play/ep359441.
- ep_id must be a positive integer without the ep prefix. These are episode comments, not season reviews.
- mode: 3 for hot (default), 2 for time.
- pagination_str: Leave empty or use {"offset":""} for page one; then pass {"offset":"previous next_offset value"}.
- Pass this JSON object as one query parameter, containing only a string offset; maximum 16384 characters.
Response and pagination:
- data.data.replies: Comments; data.data.top_replies: Pinned comments.
- data.data.cursor.all_count: Total comments; may exceed the currently accessible count.
- data.data.cursor.pagination_reply.next_offset: Use this string unchanged as the next offset; its value may stay the same.
- Stop pagination when data.data.cursor.is_end is true.
- Keep ep_id and mode unchanged between pages. Clear pagination_str when changing either one.
- Do not convert or rebuild the offset, or stop merely because it stayed the same; use is_end.
- Page size may vary. Do not infer completion from item count; rpid can be used for deduplication.
Examples:
- First page: /api/v1/bilibili/web/fetch_bangumi_comments?ep_id=359441&mode=3
- For the next page, serialize {"offset": next_offset} as pagination_str, as shown above.
- The JSON example above omits other fields and comments; NEXT_OFFSET is a placeholder.
Errors:
- 422: Invalid ep_id, mode or pagination_str.
- 400: Valid episode comments could not be retrieved.
[示例/Example]
ep_id = 359441 mode = 3 pagination_str = ""
get/api/v1/bilibili/web/fetch_bangumi_comments
Request
- Base URLhttps://api.tikhub.io (the document declares no server; this is the origin it was published from)
- AuthHTTP bearer
Query parameters
ep_idinteger required
分集链接中ep后的数字/Digits after ep in the episode URL
Example:359441
modeinteger
排序:3热门,2时间/Sort: 3 hot, 2 time
pagination_strstring
翻页JSON,首页留空/Pagination JSON; leave empty for the first page
Example:{"offset":""}
Response
Successful Response
Changes
- info
endpoint added
- info