Skip to content

Commit

Permalink
feat: 添加获取多用户信息接口,完善用户关系文档 (#1044)
Browse files Browse the repository at this point in the history
* feat: add get users info

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

* fix: typo
  • Loading branch information
wuziqian211 authored Jun 27, 2024
1 parent ce07d83 commit ea555af
Show file tree
Hide file tree
Showing 2 changed files with 291 additions and 37 deletions.
296 changes: 276 additions & 20 deletions docs/user/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -933,18 +933,279 @@ 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)
可以同时获取较多的用户信息(据测试可以一次性获取 2000 多个用户的信息;若获取更多用户信息可能会返回 -504 `服务调用超时`

**url参数:**

| 参数名 | 类型 | 内容 | 必要性 | 备注 |
| ------ | ---- | ----------------- | ------ | ------------------- |
| uids | nums | 目标用户的UID列表 | 必要 | 每个成员间用`,`分隔 |

**json回复:**

根对象:

| 字段 | 类型 | 内容 | 备注 |
| ------- | ----- | -------- | --------------------------- |
| code | num | 返回值 | 0:成功<br />-400:请求错误 |
| message | str | 错误信息 | 默认为0 |
| ttl | num | 1 | |
| data | obj | 信息本体 | 用户信息随机排序 |

`data`对象:

| 字段 | 类型 | 内容 | 备注 |
| --------- | ---- | ----------------------- | ---- |
| {用户mid} | obj | 该mid对应的用户信息 | |
| …… | obj | …… | …… |

`data`中的`{用户mid}`对象:

本接口较其他接口相比,只会返回非常有限的信息,但可以同时获取较多的用户信息(据测试可以同时获取 40000 多个用户的信息)
| 字段 | 类型 | 内容 | 备注 |
| ------------ | ---- | ------------------- | -------------------- |
| 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回复:**
Expand All @@ -954,8 +1215,8 @@ 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 | array | 信息本体 | 用户信息随机排序 |

`data`数组:
Expand All @@ -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 | 用户权限等级 | |
Expand All @@ -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>
Expand All @@ -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
}]
}
Expand Down
Loading

0 comments on commit ea555af

Please sign in to comment.