获取授权用户的资料¶
GET /api/v5/user
获取授权用户的资料,返回当前登录用户的详细信息。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
access_token |
query | string | 是 | 用户授权码 |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
avatar_url |
string | 是 | — | 用户头像地址 |
followers_url |
string | 是 | — | 关注者列表接口地址 |
html_url |
string | 是 | — | 用户主页地址 |
id |
string | 是 | — | 用户 ID |
login |
string | 是 | — | 登录名 |
name |
string | 是 | — | 用户昵称 |
type |
string | 是 | — | 用户类型,如 User |
url |
string | 是 | — | 用户 API 地址 |
bio |
string | 是 | — | 个人简介 |
blog |
string | 是 | — | 个人博客地址 |
company |
string | 是 | — | 所属公司 |
email |
string | 是 | — | 邮箱地址 |
followers |
integer | 是 | — | 关注者数量 |
following |
integer | 是 | — | 关注的用户数量 |
top_languages |
string[] | 是 | — | 常用语言列表 |
失败响应¶
401 未认证
Note: 以上失败响应体结构仅为示例,实际字段名以后端返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
请求路径不存在(Not found) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
<token>替换为你的 AtomGit 用户访问令牌,通过access_token查询参数传递。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/user?access_token=<token>' -H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/user?access_token=<token>", {
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/user",
params={"access_token": "<token>"},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"avatar_url": "https://api.atomgit.com/avatar.png",
"followers_url": "https://api.atomgit.com/api/v5/users/gitcode-xxm/followers",
"html_url": "https://api.atomgit.com/gitcode-xxm",
"id": "64e5ed8f7e20aa73efcbc302",
"login": "gitcode-xxm",
"name": "xxm",
"type": "User",
"url": "https://api.atomgit.com/api/v5/gitcode-xxm",
"bio": "a PM ",
"blog": "https://api.atomgit.com",
"company": "",
"email": "xiongjiamu@163.com",
"followers": 8,
"following": 35,
"top_languages": ["Python", "Markdown", "C++", "C", "HTML"]
}
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问 |
404 |
请求路径不存在 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc