How do I use a Bilibili video link, BV ID, AV ID and uploader mid?
To fetch Bilibili video comments, take the BV or AV ID after /video/ in the full video URL and pass the ID to bilibili.app.fetch_video_comments as either bv_id or av_id. The Web comments action bilibili.web.fetch_video_comments takes the BV ID only. The uploader mid from a space.bilibili.com/ profile URL identifies the creator’s account, not a video, so do not use mid for comments. You do not need to retrieve video details to convert between ID types.
What does each identifier target?
AV IDs, mid values and comment identifiers can all look numeric. Store each identifier with the link or response it came from, and never substitute one type for another. Keep long numbers as text, including in spreadsheets.
Can I retrieve comments directly with a BV ID?
Yes. Pass the BV ID as bv_id to data:bilibili.app.fetch_video_comments; do not retrieve video details just to convert identifiers. data:bilibili.app.fetch_video_comments also accepts a confirmed av_id; send one of the two. The current data:bilibili.web.fetch_video_comments input declares BV only.
The helper prepare_bilibili_comments.py below converts an explicit BV ID, AV ID or long video URL into request.json for the first page of time-ordered comments. To choose recent or popular feedback, see comment ordering.
Prepare one newest-comment request from an explicit ID or long URL
Save the script below as prepare_bilibili_comments.py. The script takes one of three modes: bv, av or url. The script’s regular expressions check syntax only and do not prove that a video exists. In url mode the script accepts only HTTPS /video/ URLs on bilibili.com or www.bilibili.com, and rejects space, live-room and short links, URLs with user information and URLs with conflicting identity query parameters. Ordinary tracking parameters and fragments are left out of the API request.
Run one of the three commands for a given video, not all three:
The script writes only request.json and input-audit.json and makes no network call. In request.json, mode=2 requests time order and next_offset=1 selects the first page; the prepared request does not paginate automatically or guarantee complete historical order. The script discards a URL’s p part selector because bilibili.app.fetch_video_comments has no part input, so do not label the result as comments for that part only.
Check the target and budget before sending
- Open
request.jsonand confirm that the request contains exactly onebv_idorav_idand that the value matches the original target text. A numeric AV ID is not a creatormid. - If all you have is an unexplained number, stop instead of paying for requests to guess the number’s type.
- Choose a new output directory for each run; the script rejects an existing directory.
- For hot comments, inspect the
modecontract, then changemodeto 3 on purpose. Do not describe one result as both the newest and the hot ranking.
See the current pricing page. With a known BV or AV ID, send the comment request directly, and retrieve video details, more pages or replies only when the task needs them.
If you chose another directory, change the paths to match, and do not rerun the command over a previous response. Before the next step, check the HTTP status, the public error and request_id; HTTP 200 alone does not mean the response contains usable comments. bilibili.app.fetch_video_comments has no published, verifiable output paths for the comment list, replies or cursor yet, so request.json is a request, not a comment CSV. Keep a failed response as a failure instead of counting it as zero comments.
Sources: the App and Web comment input contracts. Offline tests of prepare_bilibili_comments.py cover BV case, long AV text, BV and AV long URLs, rejection of mid, short links, lookalike hosts and identity query parameters, existing-directory protection and zero network calls.

