列出授权用户 star 了的仓库¶
GET /api/v5/user/starred
用户调用此接口,进行列出授权用户 star 了的仓库操作。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
access_token |
query | string | 是 | 用户授权码 |
sort |
query | string | 否 | 排序方式,枚举:created / last_push;根据仓库创建时间(created)或最后推送时间(last_push)进行排序,默认:创建时间 |
direction |
query | string | 否 | 排序方向,枚举:asc / desc;默认:降序 |
page |
query | integer | 否 | 当前的页码 |
per_page |
query | integer | 否 | 每页的数量,最大为 100,默认 20 |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
| (响应体) | array<object> |
是 | 否 | 授权用户 star 的仓库列表,数组元素为仓库对象,结构见下 |
仓库对象(数组元素)
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | — | — | 仓库 ID |
full_name |
string | — | — | 仓库完整名称(owner/name) |
human_name |
string | — | — | 仓库可读名称 |
url |
string | — | — | 仓库 API 地址 |
namespace |
object | — | — | 命名空间信息,见下 |
path |
string | — | — | 仓库路径 |
name |
string | — | — | 仓库名称 |
parentfull_name |
string | — | — | 父仓库完整名称 |
description |
string | — | — | 仓库描述 |
status |
string | — | — | 仓库状态 |
ssh_url_to_repo |
string | — | — | SSH 克隆地址 |
http_url_to_repo |
string | — | — | HTTP 克隆地址 |
web_url |
string | — | — | 仓库网页地址 |
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 | — | — | 是否有 issues |
watchers_count |
integer | — | — | 关注者数量 |
enterprise |
object | — | — | 所属企业信息,见下 |
default_branch |
string | — | — | 默认分支 |
fork |
integer | — | — | 是否为 fork 仓库 |
pushed_at |
string | — | — | 最近推送时间 |
owner |
object | — | — | 仓库所有者信息,见下 |
issue_template_source |
string | — | — | issue 模板来源 |
project_creator |
string | — | — | 项目创建者 |
private |
integer | — | — | 是否私有仓库 |
public |
integer | — | — | 是否公开仓库 |
namespace 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
namespace.id |
integer | — | — | 命名空间 ID |
namespace.type |
string | — | — | 命名空间类型 |
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 | — | — | 所有者类型 |
失败响应¶
该接口需要用户认证。未认证或访问令牌缺失/无效时返回 401;参数校验失败时返回 400。以下示例中的错误字段名以后端实际返回为准。
400 参数错误
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad request) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
请求示例¶
参数说明¶
以下示例调用均需携带用户访问令牌。
<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/user/starred?access_token=<token>&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/user/starred?access_token=<YOUR-TOKEN>&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/user/starred",
params={
"access_token": "<YOUR-TOKEN>",
"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": "开始",
"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