
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
let object = await biliAPI({ mid: 349991143 }, ['uname', 'guardNum'])
object.uname // → "神楽Mea_Official"
object.guardNum // → 90
npm
npm install bili-api -S
Yarn
yarn add bili-api
const biliAPI = require('bili-api')
;
(async () => {
let up = await biliAPI({ mid: 349991143 }, ['follower'])
up.follower // → 865364
})()
以上便是根据<mid>查找粉丝数,很简单对不对→_→
想看看推的VTB有几个舰长,几个提督,有没有石油佬上总督?没问题!
const biliAPI = require('bili-api');
(async () => {
let { guardLevel } = await biliAPI({ mid: 415578378 }, ['guardLevel'], { wait: 200 })
guardLevel // → [
// 0,
// 0,
// 0
//]
})()
部分API支持不同来源分支查询,比如通过用户名查找 mid,后查找其余信息。
const biliAPI = require('bili-api');
(async () => {
let { guardNum } = await biliAPI({ uname: '帕里_Paryi' }, ['guardNum'])
guardNum // → 4
})()
通过视频 av 号查找UP主 mid,后查找UP主其余信息。
const biliAPI = require('bili-api');
(async () => {
// 迷 迭 迷 迭 帕 里 桑
let { uname } = await biliAPI({ aid: 54299141 }, ['uname'])
uname // → "马牌酸菜罐头"
})()
/**
* @method biliAPI
* @param {Object} object 输入的信息
* @param {Array} targets 需要的目标信息
* @param {Function} [option] 设置
* @return {Promise} Resolve一个带有所需targets的Object
*/
biliAPI(object, targets[, option])
object: Object,提供目前知道的信息,比如 { mid: 349991143 },不同key的说明可以参阅IDs
targets: Array,需要的信息,比如 ['follower'],每个值的说明可以参阅APIs
option: Object,可选设置。
wait: Number,默认0。
如果在短时间发起过多请求,可能会被bilibili暂时banIP,所以可以在这里指定一个请求delay,单位 ms 毫秒,每一个网络请求都会暂停一段时间。
比如上面的获取舰团数据例子就有 200 毫秒延迟,因为它需要遍历舰团的每一页,所以最好设置一个delay。
const biliAPI = require('bili-api');
(async () => {
let { allVideos } = await biliAPI({ mid: 380829248 }, ['allVideos'])
allVideos.length // → 803
allVideos[0] // → {
// "comment": 151,
// "typeid": 27,
// "play": 35467,
// "pic": "http://i1.hdslb.com/bfs/archive/7ebdf463d240d634c48ffd1fa07aa5b4300626a1.jpg",
// "subtitle": "",
// "description": "看一眼,这是什么,是花园橘猫,橘猫飞扑!再多看一眼,这是什么,是花园橘猫,橘猫飞扑!\n\n推特:https://twitter.com/hanazono_serena\n\n油管:https://www.youtube.com/channel/UCRXBTd80F5IIWWY4HatJ5Ug\n\ntwitcasting:http://www.twitcasting.tv/hanazono_serena/show",
// "copyright": "1",
// "title": "再多看一眼,是肥猫飞扑!!(ง˙o˙)ว",
// "review": 0,
// "author": "花园Serena",
// "mid": 380829248,
// "created": 1682341800,
// "length": "00:17",
// "video_review": 17,
// "aid": 697813388,
// "bvid": "BV1Dm4y127Rk",
// "hide_click": false,
// "is_pay": 0,
// "is_union_video": 0,
// "is_steins_gate": 0,
// "is_live_playback": 0,
// "meta": {
// "id": 1273994,
// "title": "猫猫小场景",
// "cover": "https://archive.biliimg.com/bfs/archive/d924dca6f0fe32acd664187541ad181a5f95402c.jpg",
// "mid": 380829248,
// "intro": "短视频合集",
// "sign_state": 0,
// "attribute": 140,
// "stat": {
// "season_id": 1273994,
// "view": 679218,
// "danmaku": 394,
// "reply": 2164,
// "favorite": 27482,
// "coin": 9946,
// "share": 3687,
// "like": 135269,
// "mtime": 1682420254,
// "vt": 1236324,
// "vv": 0
// },
// "ep_count": 15,
// "first_aid": 354674889,
// "ptime": 1682341800,
// "ep_num": 0
// },
// "is_avoided": 0,
// "attribute": 0
//}
})()
const biliAPI = require('bili-api');
(async () => {
let { cids } = await biliAPI({ aid: 27702699 }, ['cids'])
cids // → [
// 153368014,
// 154130876,
// 153022084,
// 152986511,
// 152985543,
// 152425880,
// 152002045,
// 150297919,
// 149694024,
// 148577829,
// 148579293,
// 148575538,
// 147100251,
// 146848245,
// 146854231,
// 146834824,
// 144775534,
// 144342789,
// 144606741,
// 144044432,
// 144039296,
// 144044987,
// 141818927,
// 141375841,
// 140200064,
// 140201152,
// 140201635,
// 138312230,
// 138314190,
// 138313436,
// 138095411,
// 138313721,
// 137399592,
// 138300762,
// 137513774,
// 137354408,
// 136834104,
// 136415428,
// 136413554,
// 136205486,
// 135178666,
// 135081523,
// 135082155,
// 134965028,
// 134890616,
// 134686293,
// 134482642,
// 134383394,
// 134383290,
// 134072123,
// 134686834,
// 133674390,
// 132804903,
// 132250522,
// 132252236,
// 132251210,
// 131783391,
// 138302683,
// 131095190,
// 130775348,
// 130679944,
// 130544896,
// 130064858,
// 130064687,
// 130065169,
// 129494135,
// 129471844,
// 128741177,
// 128328466,
// 127911562,
// 127882591,
// 126961245,
// 127411295,
// 126577294,
// 126412246,
// 126412697,
// 125886700,
// 125353459,
// 124221119,
// 124220678,
// 124220626,
// 123977663,
// 123669381,
// 124940385,
// 123102926,
// 123062231,
// 122770200,
// 122705097,
// 122541408,
// 121700107,
// 121698981,
// 121698543,
// 122249080,
// 121698118,
// 120802623,
// 120568983,
// 120419369,
// 119155112,
// 118858442,
// 118514627,
// 117565934,
// 117348519,
// 117346761,
// 117345948,
// 117343514,
// 117349741,
// 117349698,
// 116186644,
// 114763979,
// 114638549,
// 114418415,
// 114230987,
// 113685416,
// 113606632,
// 112946049,
// 112305652,
// 112299881,
// 112249982,
// 112249847,
// 112249715,
// 111800712,
// 111823761,
// 111806238,
// 111805606,
// 111804322,
// 110947294,
// 110946620,
// 113607080,
// 110945683,
// 108734088,
// 108728098,
// 108721702,
// 108721496,
// 107242490,
// 107147481,
// 113607702,
// 106752299,
// 106738746,
// 106011326,
// 105885163,
// 105883722,
// 105131095,
// 103894110,
// 103893362,
// 103025841,
// 103029620,
// 100426228,
// 100438286,
// 100073514,
// 100067702,
// 100064630,
// 98140930,
// 98176581,
// 97497904,
// 97074496,
// 98171575,
// 96396213,
// 96396029,
// 94227448,
// 94789318,
// 94254317,
// 93784890,
// 94257750,
// 94317035,
// 94319102,
// 94319353,
// 94319982,
// 94320142,
// 94320271,
// 94320723,
// 94320982,
// 94320998,
// 94321024,
// 97056382,
// 96535734,
// 96534727,
// 96534219,
// 96533304,
// 96541034,
// 103127764,
// 103128533,
// 103129216,
// 103129712,
// 103129922,
// 103130328,
// 103130885,
// 103130897,
// 1085091986,
// 103132696,
// 103132455,
// 103132879,
// 103111181,
// 103112536,
// 103113244,
// 103114950,
// 103117360,
// 103118025,
// 103118461,
// 103119415,
// 47780428
//]
})()
这里收集的API应该属于"匿名API(自造词)",即不需要 登陆/appkey 的API。
用处大概是公开信息获取,暂时没有涉及类似"发弹幕/评论"相关API的打算。
以下是可能满足类似需求的资料:
fython/BilibiliAPIDocs: Bilibili API (For thrid-party) Documents 哔哩哔哩开放接口第三方文档
lovelyyoshino/Bilibili-Live-API: BILIBILI 直播/番剧 API
Vespa314/bilibili-api: B站API收集整理及开发,测试【开发中】
UP主统计数据
前置: <mid>
UP主信息
前置: <mid>
视频信息
前置: <bvid>
弹幕
前置: <cid>
UP主公告
前置: <mid>
UP主的视频数
前置: <spaceSearch>
直播舰团
前置: <topList>
舰团列表
前置: <fullTopList>
舰团各等级数
前置: <guards>
轮播状态,轮播中为1
前置: <roomStatus>, <liveRoom>
直播状态,直播中为1,轮播/没播为0
前置: <roomStatus>, <liveRoom>
直播间标题
前置: <liveRoom>
公告
前置: <_notice>
UP主播放数
前置: <upstat>
UP主阅读数
前置: <upstat>
UP主头像的链接
前置: <info>
个人空间头图
前置: <info>
直播开始时间
前置: <getInfoByRoom>
大概是 Member ID?
UP主个人空间地址 https://space.bilibili.com/43222001/ 中的43222001就是这个mid了
就是av号啦→_→
比如视频 https://www.bilibili.com/video/av2134250/ 中的2134250就是aid
前置: <aid>
就是bv号,新出的www
比如视频 https://www.bilibili.com/video/BV1Xs411S77y 中的BV1Xs411S77y就是bvid
前置: <archiveStat>
直播房间号
前置: <liveRoom>
bilibili直播一周元气榜分区排名
前置: <mid>
UP主的动态
前置: <dynamicsRaw>
获取动态的起点。留空或设置为0可获取最新动态。使用上一次请求中的next_offset可获取下一页动态。
欢迎各种Issue和Pull Request
开Issue聊天也行→_→!!!
详细可以阅读 CONTRIBUTING.md
FAQs
Bilibili API 接口
The npm package bili-api receives a total of 35 weekly downloads. As such, bili-api popularity was classified as not popular.
We found that bili-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.