列出用户 watch 了的仓库¶
GET /api/v5/users/{username}/subscriptions
用户调用此接口,列出指定用户 watch 了的仓库(即该用户订阅的仓库列表)。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
username |
path | string | 是 | 用户名(用户空间地址 path) |
access_token |
query | string | 否 | 用户授权码 |
sort |
query | string | 否 | 排序方式:created 按创建时间、last_push 按最后推送时间;默认 created |
direction |
query | string | 否 | 排序方向:asc / desc;默认 desc |
page |
query | integer | 否 | 当前的页码 |
per_page |
query | integer | 否 | 每页的数量,最大为 100,默认 20 |
响应参数¶
响应体为「用户 watch 了的仓库」对象数组,数组元素的字段如下:
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | 仓库 Id |
full_name |
string | 是 | 否 | 仓库全路径 |
human_name |
string | 是 | 否 | 仓库全名称 |
url |
string | 是 | 否 | 仓库详情访问地址 |
namespace |
object | 是 | 否 | 仓库所属命名空间 |
path |
string | 是 | 否 | 仓库路径 |
name |
string | 是 | 否 | 仓库名称 |
parentfull_name |
string | 否 | 是 | 父仓库名称 |
description |
string | 是 | 是 | 仓库描述 |
status |
string | 是 | 否 | 仓库状态:0 开始(表示仓库未归档),2 关闭(表示仓库已归档) |
ssh_url_to_repo |
string | 是 | 否 | 仓库 ssh git 地址 |
http_url_to_repo |
string | 是 | 否 | 仓库 http git 地址 |
web_url |
string | 是 | 否 | 仓库 web 访问地址 |
created_at |
string | 是 | 否 | 创建时间 |
updated_at |
string | 是 | 否 | 更新时间 |
homepage |
string | 否 | 是 | 仓库主页 |
members |
string[] | 是 | 是 | 仓库成员列表 |
parent |
object | 否 | 是 | 父仓库信息 |
forks_count |
integer | 是 | 否 | fork 数量 |
stargazers_count |
integer | 是 | 否 | star 数量 |
relation |
string | 是 | 否 | 当前用户相对于仓库的角色 |
permission |
object | 是 | 否 | 当前用户对仓库的权限 |
internal |
integer | 是 | 否 | 是否内部开源 |
open_issues_count |
integer | 是 | 否 | 开启的 issue 数量 |
has_issue |
integer | 是 | 否 | 是否开启 issue 功能 |
has_issues |
integer | 是 | 否 | 是否开启 issue 功能 |
watchers_count |
integer | 是 | 否 | watch 数量 |
enterprise |
object | 是 | 是 | 所属企业/空间信息 |
default_branch |
string | 是 | 否 | 默认分支 |
fork |
integer | 是 | 否 | 是否 fork 仓库 |
pushed_at |
string | 是 | 否 | 最近一次代码推送时间 |
owner |
object | 是 | 否 | 仓库所有者信息 |
issue_template_source |
string | 是 | 否 | Issue 模版来源:project 使用仓库 Issue Template 作为模版;enterprise 使用企业工作项作为模版 |
project_creator |
string | 是 | 否 | 仓库创建人 |
private |
integer | 是 | 否 | 是否私有仓库 |
public |
integer | 是 | 否 | 是否公开仓库 |
namespace 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
namespace.id |
integer | 是 | 否 | 命名空间 Id |
namespace.type |
string | 是 | 否 | 命名空间类型(如 user) |
namespace.name |
string | 是 | 否 | 命名空间名称 |
namespace.path |
string | 是 | 否 | 命名空间路径 |
namespace.html_url |
string | 是 | 否 | 命名空间访问地址 |
parent 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
parent.full_name |
string | 是 | 否 | 父仓库全路径 |
parent.human_name |
string | 是 | 否 | 父仓库全名称 |
permission 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
permission.pull |
integer | 是 | 否 | 拉取权限 |
permission.push |
integer | 是 | 否 | 推送权限 |
permission.admin |
integer | 是 | 否 | 管理权限 |
enterprise 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
enterprise.id |
integer | 是 | 否 | 企业/空间 Id |
enterprise.path |
string | 是 | 否 | 企业/空间路径 |
enterprise.html_url |
string | 是 | 否 | 企业/空间访问地址 |
enterprise.type |
string | 是 | 否 | 企业/空间类型 |
owner 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
owner.id |
string | 是 | 否 | 所有者 Id |
owner.login |
string | 是 | 否 | 所有者登录名 |
owner.name |
string | 是 | 否 | 所有者名称 |
owner.type |
string | 是 | 否 | 所有者类型(如 User) |
失败响应¶
400 参数错误
401 未认证
错误字段名以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
304 |
未修改(Not modified) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
请求示例¶
参数说明¶
<username>替换为用户名(用户空间地址 path);本接口允许匿名访问,也可携带<token>(AtomGit 用户访问令牌)访问私有 watch 列表;sort可取created/last_push,direction可取asc/desc。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/users/<username>/subscriptions?sort=created&direction=desc&page=1&per_page=20' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
"https://api.atomgit.com/api/v5/users/<username>/subscriptions?sort=created&direction=desc&page=1&per_page=20",
{
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>/subscriptions",
params={"sort": "created", "direction": "desc", "page": 1, "per_page": 20},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
[
{
"id": 777621,
"full_name": "xiaogang/private-new2",
"human_name": "xiaogang / private-new2",
"url": "https://api.atomgit.com/api/v5/repos/xiaogang/private-new2",
"namespace": {
"id": 137117,
"type": "user",
"name": "xiaogang",
"path": "xiaogang",
"html_url": "https://api.atomgit.com/xiaogang"
},
"path": "private-new2",
"name": "private-new2",
"parentfull_name": "xiaogang_test/private-new",
"description": "示例仓库",
"status": "0",
"ssh_url_to_repo": "ssh://git@atomgit.com:2222/xiaogang/private-new2.git",
"http_url_to_repo": "https://api.atomgit.com/xiaogang/private-new2.git",
"web_url": "https://api.atomgit.com/xiaogang/private-new2",
"created_at": "2024-12-11T17:41:14.536+08:00",
"updated_at": "2024-12-11T17:41:14.536+08:00",
"homepage": "https://api.atomgit.com/xiaogang/private-new2",
"members": ["xiaogang"],
"parent": {
"full_name": "xiaogang_test/private-new",
"human_name": "xiaogang_test / private-new"
},
"forks_count": 0,
"stargazers_count": 1,
"relation": "master",
"permission": {
"pull": 1,
"push": 1,
"admin": 1
},
"internal": 0,
"open_issues_count": 0,
"has_issue": 0,
"has_issues": 0,
"watchers_count": 0,
"enterprise": {
"id": 137117,
"path": "xiaogang",
"html_url": "https://api.atomgit.com/xiaogang",
"type": "user"
},
"default_branch": "main",
"fork": 1,
"pushed_at": "2024-12-20T19:14:34.979+08:00",
"owner": {
"id": "496",
"login": "xiaogang",
"name": "肖刚",
"type": "User"
},
"issue_template_source": "project",
"project_creator": "xiaogang",
"private": 0,
"public": 1
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc