列出用户 star 了的仓库¶
GET /api/v5/users/{username}/starred
列出指定用户 star 了的仓库,返回仓库信息数组(分页)。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
username |
path | string | 是 | 用户名(username/login,即用户的地址 path) |
access_token |
query | string | 是 | 用户授权码 |
sort |
query | string | 否 | 排序字段,枚举:created / last_push;按仓库创建时间(created)或最后推送时间(last_push)排序,默认 created(创建时间) |
direction |
query | string | 否 | 排序方向,枚举:asc / desc,默认 desc(降序) |
page |
query | integer | 否 | 当前页码,默认 1 |
per_page |
query | integer | 否 | 每页数量,最大 100,默认 30 |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
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 | 是 | 是 | 父仓库信息(fork 来源仓库) |
forks_count |
integer | 是 | 是 | fork 数量 |
stargazers_count |
integer | 是 | 是 | star 数量 |
relation |
string | 是 | 是 | 当前用户相对于仓库的角色 |
permission |
object | 是 | 是 | 当前用户对仓库的权限 |
internal |
boolean | 是 | 是 | 是否内部开源 |
open_issues_count |
integer | 是 | 是 | 开启的 issue 数量 |
has_issue |
boolean | 是 | 是 | 是否开启 issue 功能 |
has_issues |
boolean | 是 | 是 | 是否存在 issue |
watchers_count |
integer | 是 | 是 | watch 数量 |
enterprise |
object | 是 | 是 | 所属企业/空间信息 |
default_branch |
string | 是 | 是 | 默认分支 |
fork |
boolean | 是 | 是 | 是否为 fork 仓库 |
pushed_at |
string | 是 | 是 | 最近一次代码推送时间 |
owner |
object | 是 | 是 | 仓库所有者信息 |
issue_template_source |
string | 是 | 是 | Issue 模板来源,枚举:project(使用仓库 Issue Template 作为模板)/ enterprise(使用企业工作项作为模板) |
project_creator |
string | 是 | 是 | 仓库创建人 |
private |
boolean | 是 | 是 | 是否私有仓库 |
public |
boolean | 是 | 是 | 是否公开仓库 |
Note: 响应体为仓库对象数组,上表描述每个数组元素(ProjectResp)的字段结构。
namespace 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
namespace.id |
integer | 是 | 是 | 命名空间 ID |
namespace.type |
string | 是 | 是 | 命名空间类型(如 user) |
namespace.name |
string | 是 | 是 | 命名空间名称 |
namespace.path |
string | 是 | 是 | 命名空间路径 |
namespace.html_url |
string | 是 | 是 | 命名空间 HTML 访问地址 |
parent 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
parent.full_name |
string | 是 | 是 | 父仓库全路径 |
parent.human_name |
string | 是 | 是 | 父仓库全名称 |
permission 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
permission.pull |
boolean | 是 | 是 | 是否具有拉取(pull)权限 |
permission.push |
boolean | 是 | 是 | 是否具有推送(push)权限 |
permission.admin |
boolean | 是 | 是 | 是否具有管理员(admin)权限 |
enterprise 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
enterprise.id |
integer | 是 | 否 | 企业/空间 ID |
enterprise.path |
string | 是 | 是 | 企业/空间路径 |
enterprise.html_url |
string | 是 | 是 | 企业/空间 HTML 访问地址 |
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) |
请求示例¶
参数说明¶
本接口允许匿名访问,示例未携带访问令牌;如需访问私有数据,可携带 access_token 查询参数或认证头。
<username>替换为用户名(username/login,即用户的地址 path)。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/users/<username>/starred?access_token=<token>&sort=created&direction=desc&page=1&per_page=30' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const username = "octocat";
const response = await fetch(
`https://api.atomgit.com/api/v5/users/${username}/starred?access_token=<token>&sort=created&direction=desc&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>/starred",
params={
"access_token": "<token>"
"sort": "created",
"direction": "desc",
"page": 1,
"per_page": 30,
},
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": "开始",
"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": true,
"push": true,
"admin": true
},
"internal": false,
"open_issues_count": 0,
"has_issue": false,
"has_issues": false,
"watchers_count": 0,
"enterprise": {
"id": 137117,
"path": "xiaogang",
"html_url": "https://api.atomgit.com/xiaogang",
"type": "user"
},
"default_branch": "main",
"fork": true,
"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": false,
"public": true
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc