Answers
How do I get views, coins and danmaku count for a Bilibili BV id?
Short answer
Call Bilibili video detail with the BV id (or the video link) and view=full. One call returns views, likes, comments, shares and favorites, plus coins, danmaku count, aid, cid, duration and section under ext, for $0.002. A list of 200 BV ids costs $0.40.
A campaign report lands on your desk with 200 BV ids and claimed view numbers. Before you sign off, you want the real numbers for each one, including coins, which on Bilibili say more about how much viewers liked a video than likes do. One API call per BV id gets you all of it.
The endpoint
Bilibili video detail takes either id (a BV id such as BV1xx411c7mD) or url (the full bilibili.com/video/... link). Give one, not both. With view=full, this is where each number lives:
| What you want | Field |
|---|---|
| Views | metrics.views |
| Likes | metrics.likes |
| Coins | ext.coins |
| Favorites | metrics.favorites |
| Shares | metrics.shares |
| Comments | metrics.comments |
| Danmaku count | ext.danmaku |
| aid (the old AV number) | ext.aid |
| cid (of the first part) | ext.cid |
| Duration, seconds | ext.duration_s |
| Section | ext.section |
Title, description, cover, publish time and the uploader's name and mid come back too.
Cost
| Batch | Calls | Cost |
|---|---|---|
| One video | 1 | $0.002 |
| A 200-video campaign report | 200 | $0.40 |
| 1,000 videos | 1,000 | $2.00 |
A deleted or private video returns not_found, which is not charged.
Batch script
import csv, os, requests
URL = "https://api.okdata.online/v1/bilibili/videos/get"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
bvids = [line.strip() for line in open("bvids.txt") if line.strip()]
with open("stats.csv", "w", newline="", encoding="utf-8-sig") as f:
w = csv.writer(f)
w.writerow(["bvid", "views", "likes", "coins", "favorites", "danmaku", "fetched_at"])
for bv in bvids:
body = requests.get(URL, headers=H, params={"id": bv, "view": "full"}, timeout=60).json()
if body["code"] != "ok":
w.writerow([bv, body["code"]])
continue
v = body["data"]["item"]
w.writerow([bv, v["metrics"]["views"], v["metrics"]["likes"], v["ext"]["coins"],
v["metrics"]["favorites"], v["ext"]["danmaku"], body["meta"]["fetched_at"]])
Things to keep in mind
- The numbers are a snapshot. Keep
meta.fetched_atnext to them, because a video's views can double in a day. - Multi-part videos share one BV id; the counts cover the whole video, and
ext.cidis the first part's. - Completion rate, traffic sources and audience age are private to the uploader. No public API has them.
- If you only need the aid, you do not need a call at all. The BV-to-AV conversion is a published algorithm (bilibili-API-collect documents it), and a few lines of code run it locally for free.
Other ways
For five videos, open the pages and copy the numbers. If you run the campaign yourself, the creator center (创作中心) export from the uploader is richer than any public number. The open-source bilibili-api library reads the same public stats for free if you maintain it. To turn one-off lookups into ongoing tracking, see the competitor monitoring guide.
Updated