Bbili-open-mcpMCP
★

三方通用资源接口

guide#116三方资源接口实现

**请注意:本页面接口为第三方实现接口后B站来调用。

<font size=5 color=Red>请注意:本页面接口为第三方实现接口后B站来调用。 第三方实现接口需要按照统一签名规范进行实现。 文档参考:接口签名实现标准</font>

实现接口前请先查看接入指引

获取资源列表#

接口说明:通过该接口获取接入方返回的资源列表信息 demo_path(仅供参考): https://{your_service_domain}/resource_list 请求方式:POST

Body 请求参数

json
{
  "page": 16,
  "page_size": 5,
  "biz_source": "bili",
  "request_id": "313b0f9976c4008e2c8a02737265795f",
  "biz_code":"bilibili_fgo",
  "open_id":"60b8cf87b2614ec7980f7935b8b00159"
  "start_time":1709712714,
  "end_time":1709712715,
}

B站发起请求参数#

名称位置类型必选中文名说明
biz_sourcebodystring是资源source用于标识业务方,当同一用户在第三方有多个业务接入时用于区分来源
request_idbodystring是请求idb站请求id,用于链路跟踪,建议日志记录该字段,方便后期追溯问题
pagebodyinteger是页码页码
page_sizebodyinteger是每页数据量每页数据
biz_codebodystring是三方业务码三方业务码,用于区分同一个业务方的不同应用
open_idbodystring否open_id用户在该应用下的唯一ID
start_timebodyint64否起始时间请求资源时间范围开始时间的时间戳
end_timebodyint64否结束时间请求资源时间范围结束时间的时间戳

接入方返回结果#

状态码状态码含义说明数据模型
200OK成功Inline

返回数据结构#

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone错误码0正常返回,其他错误码详见错误码枚举
» messagestringfalsenone描述发生错误可通过该字段返回错误描述
» request_idstringtruenone请求id三方的调用请求id
» pageobjecttruenonenone
»» pageintegertruenone页码页码
»» page_sizeintegertruenone每页数据量每页数据量
»» totalintegertruenone资源总数量资源总数量
» dataobjecttruenonenone
»» list[object]truenonenone
»»» titlestringtruenone资源名称none
»»» download_linkstringtruenone资源下载地址none
»»» download_expire_atintegertruenone资源下载地址有效期时间戳(秒级) utc;0表示永不过期
»»» idstringtruenone资源唯一idnone
»»» versionstringtruenone资源版本none
»»» create_atintegerfalsenone资源创建时间时间戳(秒级) utc;
»»» last_modify_atintegerfalsenone资源最近修改时间时间戳(秒级) utc
»»» owner_namestringfalsenone资源拥有者none
»»» owner_head_imgstringfalsenone资源拥有者头像none
»»» source_md5stringfalsenone资源md5none
»»» extrastringfalsenone额外参数json格式
»»» sizeintegertruenone资源大小none
»» extrastringtruenone额外数据json格式

返回示例

成功

json
{
  "code": 0,
  "request_id": "313b0f9976c4008e2c8a02737265795f",
  "message": "success",
  "page": {
    "page": 7,
    "page_size": 1,
    "total": 1000
  },
  "data": {
    "list": [
      {
        "title": "nico.mp4",
        "download_link": "http://www.bilibili.com/download",
        "download_expire_at": 1701231222,
        "id": "67",
        "version": "v1",
        "size": 1024,
        "last_modify_at": 1701231222,
        "source_md5": "asdjlfksdkal-aslkbbklakdf",
        "owner_head_img": "http://dummyimage.com/400x400",
        "owner_name": "nico",
        "extra": "{\"a\": 1}",
        "create_at": 1010774109731
      }
    ],
    "extra": "{\"a\": 1}"
  }
}

失败

json
{
  "page": {},
  "data": {
    "list": [],
    "extra": ""
  },
  "code": -1100,
  "request_id": "313b0f9976c4008e2c8a02737265795f",
  "message": "内部异常"
}

查询单个资源详情#

接口说明:通过该接口向接入方查询单个资源的详细信息 demo_path(仅供参考): https://{your_service_domain}/resource_detail 请求方式:POST

Body 请求参数

json
{
  "id": "3",
  "biz_source": "bili_r",
  "request_id": "2313b0f9976c4008e2c8a02737265795f",
  "biz_code": "bilibili_fgo"
}

B站发起请求参数#

名称位置类型必选中文名说明
biz_sourcebodystring是资源source用于标识业务方,当同一用户在第三方有多个业务接入时用于区分来源
request_idbodystring是请求idb站请求id,用于链路跟踪,建议日志记录该字段,方便后期追溯问题
idbodystring是资源id资源id
biz_codebodystring是三方业务码三方业务码,用于区分同一个业务方的不同应用

接入方返回结果#

状态码状态码含义说明数据模型
200OK成功Inline

返回数据结构#

状态码 200

名称类型必选约束中文名说明
codeintegertruenone错误码0正常返回,其他错误码详见错误码枚举
messagestringfalsenone描述发生错误可通过该字段返回错误描述
request_idstringtruenone请求id三方的调用请求id
dataobjecttruenonenone
» titlestringtruenone资源名称none
» download_linkstringtruenone资源下载地址none
» download_expire_atintegertruenone资源下载地址有效期时间戳(秒级) utc;0表示永不过期
» idstringtruenone资源唯一idnone
» versionstringtruenone资源版本none
» create_atintegerfalsenone资源创建时间时间戳(秒级) utc;
» last_modify_atintegerfalsenone资源最近修改时间时间戳(秒级) utc
» owner_namestringfalsenone资源拥有者none
» owner_head_imgstringfalsenone资源拥有者头像none
» source_md5stringfalsenone资源md5none
» extrastringfalsenone额外参数json格式
» sizeintegertruenone资源大小none

返回示例

成功

json
{
  "data": {
    "title": "nico.mp4",
    "download_link": "http://wwww.bilibili.com/download",
    "download_expire_at": 1701231222,
    "id": "67",
    "version": "v1",
    "size": 1024,
    "last_modify_at": 1701231222,
    "source_md5": "asdjlfksdkal-aslkbbklakdf",
    "owner_head_img": "http://dummyimage.com/400x400",
    "owner_name": "nico",
    "extra": "{\"a\": 1}",
    "create_at": 1010774109731
  },
  "code": 0,
  "request_id": "313b0f9976c4008e2c8a02737265795f",
  "message": "success"
}

失败

json
{
  "data": {},
  "code": -1100,
  "request_id": "313b0f9976c4008e2c8a02737265795f",
  "message": "内部错误"
}

与接入方错误码约定#

错误码含义B站侧处理逻辑
0成功
-1000资源不存在返回给上游业务
-1100内部错误返回给上游业务
-1200其他错误(请在message中简要描述错误)返回给上游业务
-1300并发限制返回给上游业务
-1400用户无权限返回给上游业务

原始文档:116_三方通用资源接口.md(7577 字节)。用 bili_docs_get { "ref": "116" } 读全文,用 bili_docs_search { "query": "…" } 检索。