2020-05-13 21:53:25 +08:00
|
|
|
|
# 直播间管理
|
|
|
|
|
|
2020-11-20 20:13:12 +08:00
|
|
|
|
- [更新直播间标题](#更新直播间标题)
|
|
|
|
|
- [开始直播](#开始直播)
|
|
|
|
|
- [关闭直播](#关闭直播)
|
|
|
|
|
|
|
|
|
|
---
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
## 更新直播间标题
|
|
|
|
|
|
2022-08-24 23:27:11 +08:00
|
|
|
|
> https://api.live.bilibili.com/room/v1/Room/update
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
|
|
|
|
|
|
|
|
|
鉴权方式:Cookie中`bili_jct`的值正确并与`csrf`相同
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ------- | ---- | ------------------------ | ------ | -------------------- |
|
2021-07-12 21:31:27 +08:00
|
|
|
|
| room_id | num | 直播间id | 必要 | 必须为自己的直播间id |
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| title | str | 直播间标题 | 必要 | 最大20字符 |
|
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 必要 | |
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ------ | -------- | ------------------------------------------------------ |
|
|
|
|
|
| code | num | 返回值 | 0:成功<br />65530:token错误(登录错误)<br />1:错误 |
|
|
|
|
|
| msg | str | 错误信息 | 默认为ok |
|
|
|
|
|
| message | str | 错误信息 | 默认为ok |
|
2020-06-12 14:10:21 +08:00
|
|
|
|
| data | array | 空 | |
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
|
|
|
|
修改直播间`10352053`标题为`测试`
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
2023-01-17 15:23:59 +08:00
|
|
|
|
curl 'https://api.live.bilibili.com/room/v1/Room/update' \
|
2020-10-16 19:31:41 +08:00
|
|
|
|
--data-urlencode 'room_id=10352053' \
|
|
|
|
|
--data-urlencode 'title=测试' \
|
|
|
|
|
--data-urlencode 'csrf=xxx' \
|
2020-07-18 23:56:10 +08:00
|
|
|
|
-b 'SESSDATA=xxx;bili_jct=xx'
|
|
|
|
|
```
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-05-13 21:53:25 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"msg": "ok",
|
|
|
|
|
"message": "ok",
|
|
|
|
|
"data": []
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-05-13 21:53:25 +08:00
|
|
|
|
## 开始直播
|
|
|
|
|
|
2022-08-24 23:27:11 +08:00
|
|
|
|
> https://api.live.bilibili.com/room/v1/Room/startLive
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
|
|
|
|
|
|
|
|
|
鉴权方式:Cookie中`bili_jct`的值正确并与`csrf`相同
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
开播时必须有分区选择,开播后返回推流地址
|
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| -------- | ---- | ------------------------ | ------ | ----------------------------------- |
|
2021-07-12 21:31:27 +08:00
|
|
|
|
| room_id | num | 直播间id | 必要 | 必须为自己的直播间id |
|
|
|
|
|
| area_v2 | num | 直播分区id(子分区id) | 必要 | 详见[直播分区](live_area.md) |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| platform | str | 直播平台 | 必要 | web端:<br />bililink:android_link |
|
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 必要 | |
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
|
|
|
|
| code | num | 返回值 | 0:成功<br />65530:token错误(登录错误)<br />1:错误<br />60009:分区不存在<br />**(其他错误码有待补充)** |
|
|
|
|
|
| msg | str | 错误信息 | 默认为空 |
|
|
|
|
|
| message | str | 错误信息 | 默认为空 |
|
|
|
|
|
| data | obj | 信息本体 | |
|
|
|
|
|
|
|
|
|
|
`data`对象:
|
|
|
|
|
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| --------- | ----- | ---------------- | ---------------------- |
|
|
|
|
|
| change | num | 是否改变状态 | 0:未改变<br />1:改变 |
|
|
|
|
|
| status | str | LIVE | |
|
|
|
|
|
| room_type | num | 0 | 作用尚不明确 |
|
|
|
|
|
| rtmp | obj | RTMP推流地址信息 | |
|
|
|
|
|
| protocols | array | ??? | 作用尚不明确 |
|
|
|
|
|
| try_time | str | ??? | 作用尚不明确 |
|
|
|
|
|
| live_key | str | ??? | 作用尚不明确 |
|
|
|
|
|
| notice | obj | ??? | 作用尚不明确 |
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
`data`中的`rtmp`对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| -------- | ---- | -------------------------------- | ------------ |
|
|
|
|
|
| addr | str | RTMP推流(发送)地址 | **重要** |
|
|
|
|
|
| code | str | RTMP推流参数(密钥) | **重要** |
|
|
|
|
|
| new_link | str | 获取CDN推流ip地址重定向信息的url | 没啥用 |
|
|
|
|
|
| provider | str | ??? | 作用尚不明确 |
|
|
|
|
|
|
|
|
|
|
`data`中的`protocols`数组:
|
|
|
|
|
|
|
|
|
|
| 项 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ---- | ---- | ------ | ------------ |
|
|
|
|
|
| 0 | obj | ??? | 作用尚不明确 |
|
|
|
|
|
|
|
|
|
|
`data`中的`protocols`数组中的对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| -------- | ---- | -------------------------------- | ------------ |
|
|
|
|
|
| protocol | str | rtmp | 作用尚不明确 |
|
|
|
|
|
| addr | str | RTMP推流(发送)地址 | |
|
|
|
|
|
| code | str | RTMP推流参数(密钥) | |
|
|
|
|
|
| new_link | str | 获取CDN推流ip地址重定向信息的url | |
|
|
|
|
|
| provider | str | txy | 作用尚不明确 |
|
|
|
|
|
|
|
|
|
|
`data`中的`notice`对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ----------- | ---- | ---- | ------------ |
|
|
|
|
|
| type | num | 1 | 作用尚不明确 |
|
|
|
|
|
| status | num | 0 | 作用尚不明确 |
|
|
|
|
|
| title | str | 空 | 作用尚不明确 |
|
|
|
|
|
| msg | str | 空 | 作用尚不明确 |
|
|
|
|
|
| button_text | str | 空 | 作用尚不明确 |
|
|
|
|
|
| button_url | str | 空 | 作用尚不明确 |
|
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
2021-07-12 21:31:27 +08:00
|
|
|
|
以`27`作为分区id开播直播间`10352053`
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
其中`"data"."rtmp"."addr"`为推流地址
|
|
|
|
|
|
|
|
|
|
`"data"."rtmp"."code"`为推流参数
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
2023-01-17 15:23:59 +08:00
|
|
|
|
curl 'https://api.live.bilibili.com/room/v1/Room/startLive' \
|
2020-10-16 19:31:41 +08:00
|
|
|
|
--data-urlencode 'room_id=10352053' \
|
|
|
|
|
--data-urlencode 'area_v2=27' \
|
|
|
|
|
--data-urlencode 'platform=pc' \
|
|
|
|
|
--data-urlencode 'csrf=xxx' \
|
2020-07-18 23:56:10 +08:00
|
|
|
|
-b 'SESSDATA=xxx;bili_jct=xx'
|
|
|
|
|
```
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-05-13 21:53:25 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"msg": "",
|
|
|
|
|
"message": "",
|
|
|
|
|
"data": {
|
|
|
|
|
"change": 1,
|
|
|
|
|
"status": "LIVE",
|
|
|
|
|
"room_type": 0,
|
|
|
|
|
"rtmp": {
|
|
|
|
|
"addr": "rtmp://txy.live-send.acg.tv/live-txy/",
|
|
|
|
|
"code": "?streamname=live_293793435_1567354&key=***",
|
|
|
|
|
"new_link": "http://tcdns.myqcloud.com:8086/bilibili_redirect?up_rtmp=txy.live-send.acg.tv%2Flive-txy%2F%3Fstreamname%3Dlive_293793435_1567354%26key%3D***",
|
|
|
|
|
"provider": "txy"
|
|
|
|
|
},
|
|
|
|
|
"protocols": [
|
|
|
|
|
{
|
|
|
|
|
"protocol": "rtmp",
|
|
|
|
|
"addr": "rtmp://txy.live-send.acg.tv/live-txy/",
|
|
|
|
|
"code": "?streamname=live_293793435_1567354&key=***",
|
|
|
|
|
"new_link": "http://tcdns.myqcloud.com:8086/bilibili_redirect?up_rtmp=txy.live-send.acg.tv%2Flive-txy%2F%3Fstreamname%3Dlive_293793435_1567354%26key%3D***",
|
|
|
|
|
"provider": "txy"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"try_time": "0000-00-00 00:00:00",
|
|
|
|
|
"live_key": "l:one:live:record:10352053:1589344980",
|
|
|
|
|
"notice": {
|
|
|
|
|
"type": 1,
|
|
|
|
|
"status": 0,
|
|
|
|
|
"title": "",
|
|
|
|
|
"msg": "",
|
|
|
|
|
"button_text": "",
|
|
|
|
|
"button_url": ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-05-13 21:53:25 +08:00
|
|
|
|
## 关闭直播
|
|
|
|
|
|
2022-08-24 23:27:11 +08:00
|
|
|
|
> https://api.live.bilibili.com/room/v1/Room/stopLive
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
|
|
|
|
|
|
|
|
|
鉴权方式:Cookie中`bili_jct`的值正确并与`csrf`相同
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ------- | ---- | ------------------------ | ------ | -------------------- |
|
2021-07-12 21:31:27 +08:00
|
|
|
|
| room_id | num | 直播间id | 必要 | 必须为自己的直播间id |
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 必要 | |
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
|
|
|
|
| code | num | 返回值 | 0:成功<br />65530:token错误(登录错误)<br />-400:没有权限<br />**(其他错误码有待补充)** |
|
|
|
|
|
| msg | str | 错误信息 | 默认为空 |
|
|
|
|
|
| message | str | 错误信息 | 默认为空 |
|
|
|
|
|
| data | obj | 信息本体 | |
|
|
|
|
|
|
|
|
|
|
`data`对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------ | ---- | ------------ | ---------------------- |
|
|
|
|
|
| change | num | 是否改变状态 | 0:未改变<br />1:改变 |
|
|
|
|
|
| status | str | PREPARING | |
|
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
|
|
|
|
关闭直播间`10352053`的直播
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
2023-01-17 15:23:59 +08:00
|
|
|
|
curl 'https://api.live.bilibili.com/room/v1/Room/stopLive' \
|
2020-10-16 19:31:41 +08:00
|
|
|
|
--data-urlencode 'room_id=10352053' \
|
|
|
|
|
--data-urlencode 'csrf=xxx' \
|
2020-07-18 23:56:10 +08:00
|
|
|
|
-b 'SESSDATA=xxx;bili_jct=xxx'
|
|
|
|
|
```
|
2020-05-13 21:53:25 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-05-13 21:53:25 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"msg": "",
|
|
|
|
|
"message": "",
|
|
|
|
|
"data": {
|
|
|
|
|
"change": 1,
|
|
|
|
|
"status": "PREPARING"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|