feat: 添加获取多用户信息接口,完善用户关系文档 (#1044)

* feat: add get users info

* 将 #983 中对此文件的更改合并到此 PR 中

* fix: typo
This commit is contained in:
wuziqian211 2024-06-27 21:59:22 +08:00 committed by GitHub
parent ce07d83125
commit ea555aff78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 292 additions and 38 deletions

View File

@ -933,18 +933,16 @@ curl -G 'https://api.bilibili.com/x/space/myinfo' \
## 多用户详细信息
> https://api.vc.bilibili.com/account/v1/user/cards
> https://api.bilibili.com/x/polymer/pc-electron/v1/user/cards
*请求方式GET*
认证方式Cookie(SESSDATA)
本接口较其他接口相比,只会返回非常有限的信息,但可以同时获取较多的用户信息(据测试可以同时获取 40000 多个用户的信息)
可以同时获取较多的用户信息(据测试可以一次性获取 2000 多个用户的信息;若获取更多用户信息可能会返回 -504 `服务调用超时`
**url参数**
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
| ------ | ---- | ----------------- | ------ | --------------------------------- |
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
| ------ | ---- | ----------------- | ------ | ------------------- |
| uids | nums | 目标用户的UID列表 | 必要 | 每个成员间用`,`分隔 |
**json回复**
@ -954,8 +952,271 @@ curl -G 'https://api.bilibili.com/x/space/myinfo' \
| 字段 | 类型 | 内容 | 备注 |
| ------- | ----- | -------- | --------------------------- |
| code | num | 返回值 | 0成功<br />-400请求错误 |
| msg | str | 错误信息 | 默认为空 |
| message | str | 错误信息 | 默认为空 |
| message | str | 错误信息 | 默认为0 |
| ttl | num | 1 | |
| data | obj | 信息本体 | 用户信息随机排序 |
`data`对象:
| 字段 | 类型 | 内容 | 备注 |
| --------- | ---- | ----------------------- | ---- |
| {用户mid} | obj | 该mid对应的用户信息 | |
| …… | obj | …… | …… |
`data`中的`{用户mid}`对象:
| 字段 | 类型 | 内容 | 备注 |
| ------------ | ---- | ------------------- | -------------------- |
| face | str | 头像链接 | |
| face_nft | num | 是否为 NFT 头像 | 0不是 NFT 头像<br />1是 NFT 头像 |
| face_nft_new | num | 是否为新版 NFT 头像 | |
| mid | str | mid | |
| name | str | 昵称 | |
| name_render | 有效时obj<br />无效时null | 昵称渲染信息 | |
| nameplate | 有效时obj<br />无效时null | 勋章信息 | 基本同「[用户空间详细信息](#用户空间详细信息)」中的 `data.nameplate` 对象 |
| official | obj | 认证信息 | 基本同「[用户空间详细信息](#用户空间详细信息)」中的 `data.official` 对象 |
| pendant | 有效时obj<br />无效时null| 头像框信息 | 基本同「[用户空间详细信息](#用户空间详细信息)」中的 `data.pendant` 对象,其中有些类型为 `num` 的字段在本接口中类型为 `str` |
| vip | obj | 会员信息 | 基本同「[用户空间详细信息](#用户空间详细信息)」中的 `data.vip` 对象,其中有些类型为 `num` 的字段在本接口中类型为 `str` |
`{用户mid}`中的`name_render`对象:
| 字段 | 类型 | 内容 | 备注 |
| ------------- | ---- | --------------------------- | ---------------- |
| colors_info | obj | 昵称颜色信息(?) | **作用尚不明确** |
| render_scheme | str | `"Default"``"Colorful"` | **作用尚不明确** |
`name_render`中的`colors_info`对象:
| 字段 | 类型 | 内容 | 备注 |
| --------- | ----- | -------------- | ---------------- |
| color | array | 昵称颜色(?) | **作用尚不明确** |
| color_ids | array | `["6"]` | **作用尚不明确** |
`color`数组:
| 项 | 类型 | 内容 | 备注 |
| ---- | ---- | --------- | ---- |
| 0 | obj | 颜色1 | |
| n | obj | 颜色(n+1) | |
| …… | obj | …… | …… |
`color`数组中的对象:
| 字段 | 类型 | 内容 | 备注 |
| ----------- | ---- | ---------------- | ---------------- |
| color_day | str | 浅色模式昵称颜色 | HEX颜色代码 |
| color_night | str | 深色模式昵称颜色 | HEX颜色代码 |
**示例:**
查询用户`uids=1,2,3`的详细信息
```shell
curl -G 'https://api.bilibili.com/x/polymer/pc-electron/v1/user/cards' \
--data-urlencode 'uids=1,2,3'
```
<details>
<summary>查看响应示例:</summary>
```json
{
"code": 0,
"message": "0",
"ttl": 1,
"data": {
"1": {
"face": "http://i1.hdslb.com/bfs/face/34c5b30a990c7ce4a809626d8153fa7895ec7b63.gif",
"face_nft": 0,
"face_nft_new": 0,
"mid": "1",
"name": "bishi",
"name_render": {
"colors_info": { "color": [], "color_ids": [ "6" ] },
"render_scheme": "Default"
},
"nameplate": null,
"official": { "desc": "", "role": 0, "title": "", "type": -1 },
"pendant": null,
"vip": {
"avatar_icon": {
"icon_resource": {
"type": "ICON_RES_TYPE_IMAGE",
"url": "https://i0.hdslb.com/bfs/bangumi/kt/aba51485c0d02940c89aeefcf6680510d9858472.png"
},
"icon_type": "ICON_TYPE_VIP_ACTIVITY"
},
"avatar_subscript": 1,
"avatar_subscript_url": "",
"due_date": "1883059200000",
"label": {
"bg_color": "#FB7299",
"bg_style": 1,
"border_color": "",
"img_label_uri_hans": "",
"img_label_uri_hans_static": "https://i0.hdslb.com/bfs/bangumi/kt/fb0a74b14d6a4e119ae301ba2693febeda051030.png",
"img_label_uri_hant": "",
"img_label_uri_hant_static": "https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/sGu57N6pgK.png",
"label_theme": "ten_annual_vip",
"path": "",
"text": "十年大会员",
"text_color": "#FFFFFF",
"use_img_label": true
},
"nickname_color": "#FB7299",
"role": "7",
"status": 1,
"theme_type": 0,
"tv_due_date": "1633622400",
"tv_vip_pay_type": 0,
"tv_vip_status": 0,
"type": 2,
"vip_pay_type": 1
}
},
"2": {
"face": "https://i2.hdslb.com/bfs/face/ef0457addb24141e15dfac6fbf45293ccf1e32ab.jpg",
"face_nft": 0,
"face_nft_new": 0,
"mid": "2",
"name": "碧诗",
"name_render": {
"colors_info": { "color": [], "color_ids": [ "6" ] },
"render_scheme": "Default"
},
"nameplate": {
"condition": "所有自制视频总播放数>=10万",
"image": "https://i1.hdslb.com/bfs/face/e93dd9edfa7b9e18bf46fd8d71862327a2350923.png",
"image_small": "https://i2.hdslb.com/bfs/face/275b468b043ec246737ab8580a2075bee0b1263b.png",
"level": "普通勋章",
"name": "见习偶像",
"nid": 10
},
"official": { "desc": "", "role": 2, "title": "bilibili创始人站长", "type": 0 },
"pendant": {
"expire": "0",
"image": "https://i2.hdslb.com/bfs/garb/item/488870931b1bba66da36d22848f0720480d3d79a.png",
"image_enhance": "https://i2.hdslb.com/bfs/garb/item/5974f17f9d96a88bafba2f6d18d647a486e88312.webp",
"image_enhance_frame": "https://i2.hdslb.com/bfs/garb/item/4316a3910bb0bd6f2f1c267a3e9187f0b9fe5bd0.png",
"n_pid": "32257",
"name": "EveOneCat2",
"pid": 32257
},
"vip": {
"avatar_icon": {
"icon_resource": {
"type": "ICON_RES_TYPE_IMAGE",
"url": "https://i0.hdslb.com/bfs/bangumi/kt/aba51485c0d02940c89aeefcf6680510d9858472.png"
},
"icon_type": "ICON_TYPE_VIP_ACTIVITY"
},
"avatar_subscript": 1,
"avatar_subscript_url": "",
"due_date": "3968841600000",
"label": {
"bg_color": "#FB7299",
"bg_style": 1,
"border_color": "",
"img_label_uri_hans": "",
"img_label_uri_hans_static": "https://i0.hdslb.com/bfs/bangumi/kt/53845a8ab8b226131c5d89b198d4b61de91d0aa2.png",
"img_label_uri_hant": "",
"img_label_uri_hant_static": "https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/8u7iRTPE7N.png",
"label_theme": "ten_annual_vip",
"path": "",
"text": "十年大会员",
"text_color": "#FFFFFF",
"use_img_label": true
},
"nickname_color": "#FB7299",
"role": "7",
"status": 1,
"theme_type": 0,
"tv_due_date": "2003500800",
"tv_vip_pay_type": 1,
"tv_vip_status": 1,
"type": 2,
"vip_pay_type": 0
}
},
"3": {
"face": "http://i0.hdslb.com/bfs/face/d4de6a84557eea8f18510a3f61115d96832aa071.jpg",
"face_nft": 0,
"face_nft_new": 0,
"mid": "3",
"name": "囧囧倉",
"name_render": {
"colors_info": {
"color": [
{ "color_day": "#CB7919", "color_night": "#E2963C" },
{ "color_day": "#E6A75B", "color_night": "#E6A75B" },
{ "color_day": "#E9BD67", "color_night": "#F8CE7E" }
],
"color_ids": [ "6" ]
},
"render_scheme": "Colorful"
},
"nameplate": null,
"official": { "desc": "", "role": 0, "title": "", "type": -1 },
"pendant": null,
"vip": {
"avatar_icon": null,
"avatar_subscript": 0,
"avatar_subscript_url": "",
"due_date": "0",
"label": {
"bg_color": "",
"bg_style": 0,
"border_color": "",
"img_label_uri_hans": "",
"img_label_uri_hans_static": "https://i0.hdslb.com/bfs/vip/d7b702ef65a976b20ed854cbd04cb9e27341bb79.png",
"img_label_uri_hant": "",
"img_label_uri_hant_static": "https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/KJunwh19T5.png",
"label_theme": "",
"path": "",
"text": "",
"text_color": "",
"use_img_label": true
},
"nickname_color": "",
"role": "0",
"status": 0,
"theme_type": 0,
"tv_due_date": "0",
"tv_vip_pay_type": 0,
"tv_vip_status": 0,
"type": 0,
"vip_pay_type": 0
}
}
}
}
```
</details>
## 多用户详细信息2
> https://api.vc.bilibili.com/account/v1/user/cards
*请求方式GET*
本接口较其他接口相比,只会返回非常有限的信息,但可以同时获取较多的用户信息(据测试可以一次性获取 40000 多个用户的信息)
**url参数**
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
| ------ | ---- | ----------------- | ------ | ------------------- |
| uids | nums | 目标用户的UID列表 | 必要 | 每个成员间用`,`分隔 |
**json回复**
根对象:
| 字段 | 类型 | 内容 | 备注 |
| ------- | ----- | -------- | --------------------------- |
| code | num | 返回值 | 0成功<br />-400请求错误 |
| message | str | 错误信息 | 默认为0 |
| ttl | num | 1 | |
| data | array | 信息本体 | 用户信息随机排序 |
`data`数组:
@ -972,7 +1233,6 @@ curl -G 'https://api.bilibili.com/x/space/myinfo' \
| ------- | ---- | ------------ | -------------------- |
| mid | num | mid | |
| name | str | 昵称 | |
| sex | str | 性别 | 男/女/保密 |
| face | str | 头像链接 | |
| sign | str | 签名 | |
| rank | num | 用户权限等级 | |
@ -985,8 +1245,7 @@ curl -G 'https://api.bilibili.com/x/space/myinfo' \
```shell
curl -G 'https://api.vc.bilibili.com/account/v1/user/cards' \
--data-urlencode 'uids=1,2,3' \
-b 'SESSDATA=xxx'
--data-urlencode 'uids=1,2,3'
```
<details>
@ -995,34 +1254,31 @@ curl -G 'https://api.vc.bilibili.com/account/v1/user/cards' \
```json
{
"code": 0,
"msg": "",
"message": "",
"ttl": 1,
"data": [{
"mid": 1,
"name": "bishi",
"sex": "男",
"face": "https://i1.hdslb.com/bfs/face/34c5b30a990c7ce4a809626d8153fa7895ec7b63.gif",
"face": "http://i1.hdslb.com/bfs/face/34c5b30a990c7ce4a809626d8153fa7895ec7b63.gif",
"sign": "",
"rank": 10000,
"level": 4,
"level": 6,
"silence": 0
}, {
"mid": 2,
"name": "碧诗",
"sex": "男",
"face": "https://i2.hdslb.com/bfs/face/ef0457addb24141e15dfac6fbf45293ccf1e32ab.jpg",
"sign": "https://kami.im 直男过气网红 # av362830 “We Are Star Dust”",
"face": "http://i2.hdslb.com/bfs/face/ef0457addb24141e15dfac6fbf45293ccf1e32ab.jpg",
"sign": "https://kami.im 直男过气网红 # We Are Star Dust",
"rank": 20000,
"level": 6,
"silence": 0
}, {
"mid": 3,
"name": "囧囧倉",
"sex": "男",
"face": "https://i0.hdslb.com/bfs/face/d4de6a84557eea8f18510a3f61115d96832aa071.jpg",
"face": "http://i0.hdslb.com/bfs/face/d4de6a84557eea8f18510a3f61115d96832aa071.jpg",
"sign": "富强、民主、文明、和谐、自由、平等、公正、法治、爱国、敬业、诚信、友善。",
"rank": 10000,
"level": 5,
"level": 6,
"silence": 0
}]
}

View File

@ -11,7 +11,7 @@
| 字段 | 类型 | 内容 | 备注 |
| --------------- | ------------------------------------------- | -------------------------- | ------------------------------------------------------------ |
| mid | num | 用户 mid | |
| attribute | num | 对方对于**自己**的关系属性 | 0未关注<br />1悄悄关注现已下线<br />2已关注<br />6已互粉<br />128已拉黑 |
| attribute | num | 对方对于**自己**的关系属性 | 0未关注<br />~~1悄悄关注现已下线~~<br />2已关注<br />6已互粉<br />128已拉黑 |
| mtime | num | 对方关注目标用户时间 | 秒级时间戳<br />互关后刷新 |
| tag | 默认分组null<br />存在至少一个分组array | 目标用户将对方分组到的 id | |
| special | num | 目标用户特别关注对方标识 | 0<br />1是 |
@ -97,7 +97,7 @@
| 字段 | 类型 | 内容 | 备注 |
| ------- | ---- | -------- | ----------------------------------------------------- |
| code | num | 返回值 | 0成功<br />-101账号未登录<br />-352请求被拦截<br />-400请求错误<br />22007访问超过 5 页 |
| code | num | 返回值 | 0成功<br />-101账号未登录<br />-352请求被拦截<br />-400请求错误<br />22118由于该用户隐私设置粉丝列表不可见 |
| message | str | 错误信息 | 默认为 0 |
| ttl | num | 1 | |
| data | obj | 信息本体 | |
@ -368,7 +368,7 @@ curl -G 'https://api.bilibili.com/x/relation/followings' \
| 项 | 类型 | 内容 | 备注 |
| ---- | ---- | ----------- | --------------------------------------------- |
| 0 | obj | 关注 1 | 与 [关系列表对象](#关系列表对象) 数据结构不同 |
| 0 | obj | 关注 1 | 与 [关系列表对象](#关系列表对象) 数据结构**不同** |
| n | obj | 关注n+1 | 按照添加顺序排列 |
| …… | obj | …… | …… |
@ -501,9 +501,7 @@ curl -G 'https://app.biliapi.net/x/v2/relation/followings' \
</details>
## 查询用户关注明细3
<img src="../../assets/img/relation.svg" width="100" height="100" />
### 查询用户关注明细3
> https://line3-h5-mobile-api.biligame.com/game/center/h5/user/relationship/following_list
@ -1289,15 +1287,15 @@ curl -G 'https://api.bilibili.com/x/relation/blacks' \
操作代码`act`
| 代码 | 含义 |
| ---- | ------------ |
| 1 | 关注 |
| 2 | 取关 |
| 3 | 悄悄关注 |
| 4 | 取消悄悄关注 |
| 5 | 拉黑 |
| 6 | 取消拉黑 |
| 7 | 踢出粉丝 |
| 代码 | 含义 | 备注 |
| ---- | ------------ | ------------------------------------------------ |
| 1 | 关注 | 无法对已注销或不存在的用户进行此操作 |
| 2 | 取关 | |
| 3 | 悄悄关注 | 现已下线,使用本操作代码请求接口会提示“请求错误” |
| 4 | 取消悄悄关注 | |
| 5 | 拉黑 | 无法对已注销或不存在的用户进行此操作 |
| 6 | 取消拉黑 | |
| 7 | 踢出粉丝 | |
**json回复**
@ -1305,7 +1303,7 @@ curl -G 'https://api.bilibili.com/x/relation/blacks' \
| 字段 | 类型 | 内容 | 备注 |
| ------- | ---- | -------- | ------------------------------------------------------------ |
| code | num | 返回值 | 0成功<br />-101账号未登录<br />-102账号被封停<br />-111csrf校验失败<br />-400请求错误<br />22001不能对自己进行此操作<br />22003用户位于黑名单 |
| code | num | 返回值 | 0成功<br />-101账号未登录<br />-102账号被封停<br />-111csrf校验失败<br />-400请求错误<br />22001不能对自己进行此操作<br />22002因对方隐私设置你还不能关注<br />22003关注失败请将该用户移除黑名单之后再试<br />22013账号已注销无法完成操作<br />22014已经关注用户无法重复关注<br />22120重复加入黑名单<br />40061用户不存在 |
| message | str | 错误信息 | 默认为0 |
| ttl | num | 1 | |
@ -1684,7 +1682,7 @@ curl -G 'https://api.bilibili.com/x/relation/relations' \
| 项 | 类型 | 内容 | 备注 |
| ---- | ---- | ----------- | ---- |
| 1 | obj | 分组 1 | |
| 0 | obj | 分组 1 | |
| n | obj | 分组n+1 | |
| …… | num | …… | …… |