用户搜索接口

  • 权限: viewUserList
  • 接口说明: 用户搜索接口
  • 接口地址: /api/users
  • 请求方式: GET

请求参数

参数名称类型是否必须描述
filter[id]int用户 id
filter[username]string用户名:多个用户名用半角逗号隔开
用户名前或后加星号可使用模糊搜索
filter[mobile]string用户手机号
filter[status]int状态:normal 正常 ban 禁用 mod 审核中 through 审核通过 refuse 审核拒绝 ignore 审核忽略
filter[group_id][]array用户组
filter[isReal]string是否实名认证(yes/no)
filter[wechat]string是否绑定微信(yes/no)
page[limit]int分页数据条数
page[number]int页码
sortstring排序:固定值 正序 createdAt 倒序 -createdAt
includestring关联数据,默认 groups

请求示例

  1. /api/users?filter[username]=*d*

返回说明

  • 成功,http 状态码: 200
  • 失败,http 状态码: 404

返回结果

参数名称类型描述
linksobject接口链接
dataobject基础数据
typestring数据类型
idint数据 id
attributesobject数据属性
idint用户 id
usernamestring用户名
mobilestring脱敏手机号
avatarUrlstring头像地址
threadCountint主题数
registerIpstring注册 ip
lastLoginIpstring最后登录 IP
statusint用户状态:
0 正常
1 禁用
joinedAtdatetime加入时间
expiredAtdatetime到期时间
createdAtdatetime注册时间
updatedAtdatetime最后活动时间
originalMobilestring完整手机号(管理员可见)

返回示例

  1. {
  2. "links": {
  3. "first": "https://discuz.chat/api/users?filter%5Busername%5D=a%2A%2C%2Ad&page%5Blimit%5D=2",
  4. "next": "https://discuz.chat/api/users?filter%5Busername%5D=a%2A%2C%2Ad&page%5Blimit%5D=2&page%5Boffset%5D=2",
  5. "last": "https://discuz.chat/api/users?filter%5Busername%5D=a%2A%2C%2Ad&page%5Blimit%5D=2&page%5Boffset%5D=6"
  6. },
  7. "data": [
  8. {
  9. "type": "users",
  10. "id": "1",
  11. "attributes": {
  12. "id": 1,
  13. "username": "username",
  14. "mobile": "mobile",
  15. "avatarUrl": "",
  16. "threadCount": 17,
  17. "registerIp": "127.0.0.1",
  18. "lastLoginIp": "127.0.0.1",
  19. "status": 1,
  20. "joinedAt": null,
  21. "expiredAt": null,
  22. "createdAt": "2019-12-25T17:22:52+08:00",
  23. "updatedAt": "2019-12-27T16:15:20+08:00",
  24. "originalMobile": "mobilez"
  25. },
  26. "relationships": {
  27. "groups": {
  28. "data": [
  29. {
  30. "type": "groups",
  31. "id": "1"
  32. }
  33. ]
  34. }
  35. }
  36. },
  37. {
  38. "type": "users",
  39. "id": "2",
  40. "attributes": {
  41. "id": 2,
  42. "username": "username",
  43. "mobile": "mobile",
  44. "avatarUrl": "https://discuz.chat/storage/avatars/Le0Ixb2CErymqpkB.png",
  45. "threadCount": 0,
  46. "registerIp": "127.0.0.1",
  47. "lastLoginIp": "",
  48. "status": 0,
  49. "joinedAt": "2019-12-25T17:26:59+08:00",
  50. "expiredAt": null,
  51. "createdAt": "2019-12-25T17:27:00+08:00",
  52. "updatedAt": "2019-12-27T15:20:11+08:00",
  53. "originalMobile": "mobile"
  54. },
  55. "relationships": {
  56. "groups": {
  57. "data": [
  58. {
  59. "type": "groups",
  60. "id": "10"
  61. }
  62. ]
  63. }
  64. }
  65. }
  66. ],
  67. "included": [
  68. {
  69. "type": "groups",
  70. "id": "1",
  71. "attributes": {
  72. "name": "管理员",
  73. "type": "",
  74. "color": "",
  75. "icon": "",
  76. "default": 0
  77. }
  78. },
  79. {
  80. "type": "groups",
  81. "id": "10",
  82. "attributes": {
  83. "name": "普通会员",
  84. "type": "",
  85. "color": "",
  86. "icon": "",
  87. "default": 1
  88. }
  89. }
  90. ],
  91. "meta": {
  92. "total": 7,
  93. "size": 2
  94. }
  95. }