列出指定用户的粉丝列表¶
GET /api/v5/users/*/followers
分页列出指定用户的粉丝列表,返回包含用户基础信息的数组。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
username |
path | string | 是 | 用户名(username/login) |
page |
query | integer | 否 | 当前页码,必须大于 0,默认为 1 |
per_page |
query | integer | 否 | 每页的项目数,必须大于 0,最大为 100,默认 30 |
响应参数¶
返回粉丝用户对象的数组,数组中每个元素的字段如下。
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
[] |
array | 是 | 否 | 粉丝用户列表 |
[].avatar_url |
string | 是 | 是 | 头像地址 |
[].events_url |
string | 是 | 是 | 动态列表 API 地址 |
[].followers_url |
string | 是 | 是 | 粉丝列表 API 地址 |
[].following_url |
string | 是 | 是 | 关注列表 API 地址 |
[].gists_url |
string | 是 | 是 | 代码片段 API 地址 |
[].html_url |
string | 是 | 是 | 用户或组织的页面地址 |
[].id |
string | 是 | 是 | 用户或组织的标识 |
[].object_id |
string | 是 | 是 | 用户对象标识 |
[].login |
string | 是 | 是 | 用户名或组织路径 |
[].member_role |
string | 是 | 是 | 成员角色 |
[].name |
string | 是 | 是 | 用户昵称或组织名称 |
[].organizations_url |
string | 是 | 是 | 所属组织列表 API 地址 |
[].received_events_url |
string | 是 | 是 | 接收动态列表 API 地址 |
[].remark |
string | 是 | 是 | 企业备注名 |
[].repos_url |
string | 是 | 是 | 仓库列表 API 地址 |
[].starred_url |
string | 是 | 是 | 收藏仓库列表 API 地址 |
[].subscriptions_url |
string | 是 | 是 | 订阅列表 API 地址 |
[].type |
string | 是 | 是 | 对象类型:User 表示用户,Organization 表示组织 |
[].url |
string | 是 | 是 | 用户或组织的详情 API 地址 |
失败响应¶
调用未通过鉴权或参数校验时,服务端返回相应错误状态码。
400 参数错误
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
请求参数错误(Bad Request) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
请求路径不存在(Not Found) |
429 |
请求过于频繁,触发限流(Too Many Requests) |
500 |
系统内部错误(Internal Server Error) |
请求示例¶
参数说明¶
<username>替换为用户名(username/login); 本接口允许匿名访问,也可携带access_token=<token>传入 AtomGit 用户访问令牌。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/users/<username>/followers?page=1&per_page=30' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
"https://api.atomgit.com/api/v5/users/<username>/followers?page=1&per_page=30",
{
headers: {
"Accept": "application/json",
},
},
);
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/users/<username>/followers",
params={"page": 1, "per_page": 30},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
[
{
"id": "496",
"login": "xiaogang",
"name": "xiaogang",
"avatar_url": "https://api.atomgit.com/avatar.png",
"html_url": "https://atomgit.com/xiaogang",
"type": "User",
"followers_url": "https://api.atomgit.com/api/v5/users/xiaogang/followers",
"following_url": "https://api.atomgit.com/api/v5/users/xiaogang/following",
"repos_url": "https://api.atomgit.com/api/v5/users/xiaogang/repos",
"url": "https://api.atomgit.com/api/v5/users/xiaogang"
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc