npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bili-api

v1.10.1

Published

Bilibili API 接口

Downloads

150

Readme

Bili-api Node CI Coveralls github npm

let object = await biliAPI({ mid: 349991143 }, ['uname', 'guardNum'])
object.uname // → "神楽Mea_Official"
object.guardNum // → 90

目录

biliAPI

安装

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 // → "马牌酸菜罐头"
})()

biliAPI Document

/**
 * @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
  //}
})()
获取视频分P的所有cid
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
  //]
})()

Router Graph

Graph of apis

Bilibili API Document

这里收集的API应该属于"匿名API(自造词)",即不需要 登陆/appkey 的API。

用处大概是公开信息获取,暂时没有涉及类似"发弹幕/评论"相关API的打算。

以下是可能满足类似需求的资料:

fython/BilibiliAPIDocs: Bilibili API (For thrid-party) Documents 哔哩哔哩开放接口第三方文档

lovelyyoshino/Bilibili-Live-API: BILIBILI 直播/番剧 API

Vespa314/bilibili-api: B站API收集整理及开发,测试【开发中】

DATAs

Contribution

欢迎各种Issue和Pull Request

开Issue聊天也行→_→!!!

详细可以阅读 CONTRIBUTING.md