2020-06-21 13:16:31 +08:00
|
|
|
|
# 视频观看数据上报
|
|
|
|
|
|
2020-11-20 20:13:12 +08:00
|
|
|
|
- [上报观看进度(双端)](#上报观看进度(双端))
|
|
|
|
|
- [上报视频播放心跳(web端)](#上报视频播放心跳(web端))
|
|
|
|
|
|
|
|
|
|
---
|
2020-06-21 13:16:31 +08:00
|
|
|
|
|
2020-07-19 21:56:58 +08:00
|
|
|
|
## 上报观看进度(双端)
|
2020-06-21 13:16:31 +08:00
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/v2/history/report
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-06-21 13:16:31 +08:00
|
|
|
|
|
2020-07-17 23:50:28 +08:00
|
|
|
|
认证方式:APP或Cookie(SESSDATA)
|
|
|
|
|
|
2020-06-21 13:16:31 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
|
|
|
|
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ---------- | ---- | ------------------------ | -------------- | --------------------- |
|
|
|
|
|
| access_key | str | APP登录Token | APP方式必要 | |
|
2020-10-11 15:41:50 +08:00
|
|
|
|
| aid | num | 稿件avID | 必要 | |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| cid | num | 视频CID | 必要 | 用于识别分P |
|
|
|
|
|
| progress | num | 观看进度 | 非必要 | 单位为秒<br />默认为0 |
|
|
|
|
|
| platform | str | 平台标识 | 非必要 | 可为android |
|
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | Cookie方式必要 | |
|
2020-06-21 13:16:31 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
|
|
|
|
| code | num | 返回值 | 0:成功 <br />-101:账号未登录<br />-111:csrf校验失败<br />-400:请求错误 |
|
|
|
|
|
| message | str | 错误信息 | 默认为0 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-06-21 13:16:31 +08:00
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
|
|
|
|
记录视频`av13662970`(`CID=126654047`)的观看记录位于`1248`秒
|
|
|
|
|
|
2020-07-17 23:50:28 +08:00
|
|
|
|
Cookie方式:
|
|
|
|
|
|
|
|
|
|
```shell
|
2020-10-16 19:31:41 +08:00
|
|
|
|
curl 'http://api.bilibili.com/x/v2/history/report' \
|
|
|
|
|
--data-urlencode 'aid=13662970' \
|
|
|
|
|
--data-urlencode 'cid=126654047' \
|
|
|
|
|
--data-urlencode 'progress=1248' \
|
|
|
|
|
--data-urlencode 'platform=android' \
|
|
|
|
|
--data-urlencode 'csrf=xxx' \
|
2020-07-17 23:50:28 +08:00
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
APP方式:
|
|
|
|
|
|
|
|
|
|
```shell
|
2020-10-16 19:31:41 +08:00
|
|
|
|
curl 'http://api.bilibili.com/x/v2/history/report' \
|
|
|
|
|
--data-urlencode 'access_key=xxx' \
|
|
|
|
|
--data-urlencode 'aid=13662970' \
|
|
|
|
|
--data-urlencode 'cid=126654047' \
|
|
|
|
|
--data-urlencode 'progress=1248' \
|
2020-07-17 23:50:28 +08:00
|
|
|
|
--data-urlencode 'platform=android'
|
|
|
|
|
```
|
|
|
|
|
|
2020-06-21 13:16:31 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-06-21 13:16:31 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"message": "0",
|
|
|
|
|
"ttl": 1
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-06-21 15:38:08 +08:00
|
|
|
|
## 上报视频播放心跳(web端)
|
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/click-interface/web/heartbeat
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-06-21 15:38:08 +08:00
|
|
|
|
|
2020-07-17 23:50:28 +08:00
|
|
|
|
认证方式:仅可Cookie(SESSDATA)
|
|
|
|
|
|
2020-06-21 15:38:08 +08:00
|
|
|
|
默认间隔15秒一次
|
|
|
|
|
|
|
|
|
|
亦可记录播放历史
|
|
|
|
|
|
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
|
|
|
|
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ----------- | ---- | ------------------------ | ------------ | ------------------------------------------------------------ |
|
2020-10-11 15:41:50 +08:00
|
|
|
|
| aid | num | 稿件avID | 必要(可选) | avID与bvID任选一个 |
|
|
|
|
|
| bvid | str | 稿件bvID | 必要(可选) | avID与bvID任选一个 |
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| cid | num | 视频CID | 非必要 | 用于识别分P |
|
|
|
|
|
| epid | num | 番剧epID | 非必要 | |
|
|
|
|
|
| sid | num | 番剧ssID | 非必要 | |
|
|
|
|
|
| mid | num | 当前用户UID | 非必要 | |
|
|
|
|
|
| played_time | num | 视频播放进度 | 非必要 | 单位为秒<br />默认为0 |
|
|
|
|
|
| realtime | num | 总计播放时间 | 非必要 | 单位为秒 |
|
|
|
|
|
| start_ts | num | 开始播放时刻 | 非必要 | 时间戳 |
|
|
|
|
|
| type | num | 视频类型 | 非必要 | 3:投稿视频<br />4:剧集<br />10:课程 |
|
|
|
|
|
| sub_type | num | 剧集副类型 | 非必要 | 当`type=4`时本参数有效<br />1:番剧<br />2:电影<br />3:纪录片<br />4:国创<br />5:电视剧<br />7:综艺 |
|
|
|
|
|
| dt | num | 2 | 非必要 | |
|
|
|
|
|
| play_type | num | 播放动作 | 非必要 | 0:播放中<br />1:开始播放<br />2:暂停<br />3:继续播放 |
|
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 非必要 | |
|
2020-06-21 15:38:08 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | --------------------------- |
|
|
|
|
|
| code | num | 返回值 | 0:成功<br />-400:请求错误 |
|
|
|
|
|
| message | str | 错误信息 | 默认为0 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-06-21 15:38:08 +08:00
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
|
|
|
|
上报一次视频`av2`/`BV1xx411c7mD`的心跳数据
|
|
|
|
|
|
2020-07-17 23:50:28 +08:00
|
|
|
|
```shell
|
2020-10-16 19:31:41 +08:00
|
|
|
|
curl 'api.bilibili.com/x/click-interface/web/heartbeat' \
|
|
|
|
|
--data-urlencode 'aid=2' \
|
|
|
|
|
--data-urlencode 'bvid=BV1xx411c7mD' \
|
|
|
|
|
--data-urlencode 'cid=62131' \
|
|
|
|
|
--data-urlencode 'played_time=60' \
|
|
|
|
|
--data-urlencode 'realtime=60' \
|
|
|
|
|
--data-urlencode 'start_ts=1592720840' \
|
|
|
|
|
--data-urlencode 'type=3' \
|
|
|
|
|
--data-urlencode 'dt=2' \
|
|
|
|
|
--data-urlencode 'play_type=0' \
|
|
|
|
|
--data-urlencode 'csrf=xxx' \
|
2020-07-17 23:50:28 +08:00
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-06-21 15:38:08 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-06-21 15:38:08 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"message": "0",
|
|
|
|
|
"ttl": 1
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|