获取用户的某个仓库¶
GET /api/v5/repos/{owner}/{repo}
该接口用于获取指定用户的某个仓库的详细信息,包括仓库基本属性、所属空间、创建者、克隆地址、Star 与 Fork 数量、默认分支及私有状态等信息。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
access_token |
query | string | 是 | 用户授权码 |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | 仓库 id |
full_name |
string | 是 | 否 | 仓库完整名称(namespace/path) |
human_name |
string | 是 | 否 | 仓库人类可读名称 |
url |
string | 是 | 否 | 仓库 API 地址 |
namespace |
object | 是 | 否 | 仓库所属空间(namespace)信息 |
path |
string | 是 | 否 | 仓库路径(path) |
name |
string | 是 | 否 | 仓库名称 |
description |
string | 是 | 是 | 仓库描述 |
status |
string | 是 | 否 | 仓库状态:0 表示开始(仓库未归档),2 表示关闭(仓库已归档) |
ssh_url_to_repo |
string | 是 | 否 | SSH 克隆地址 |
http_url_to_repo |
string | 是 | 否 | HTTP 克隆地址 |
web_url |
string | 是 | 否 | 仓库网页地址 |
readme_url |
string | 是 | 否 | README 地址 |
created_at |
string | 是 | 否 | 创建时间 |
updated_at |
string | 是 | 否 | 更新时间 |
creator |
object | 是 | 否 | 创建者信息 |
members |
string[] | 是 | 否 | 成员列表 |
forks_count |
integer | 是 | 否 | Fork 数量 |
stargazers_count |
integer | 是 | 否 | Star 数量 |
project_labels |
object[] | 是 | 是 | 仓库标签列表 |
license |
string | 是 | 是 | 开源许可证 |
internal |
integer | 是 | 否 | 是否为内部仓库 |
open_issues_count |
integer | 是 | 否 | 打开的 Issue 数量 |
watchers_count |
integer | 是 | 否 | 关注者数量 |
assignees_number |
integer | 是 | 否 | 指派人数 |
enterprise |
object | 是 | 是 | 所属企业信息 |
default_branch |
string | 是 | 否 | 默认分支 |
fork |
integer | 是 | 否 | 是否为 Fork 仓库 |
owner |
object | 是 | 否 | 仓库属主信息 |
assigner |
object | 是 | 是 | 指派者信息 |
issue_template_source |
string | 是 | 是 | Issue 模板来源 |
private |
integer | 是 | 否 | 是否为私有仓库 |
public |
integer | 是 | 否 | 是否为公开仓库 |
namespace 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
namespace.id |
integer | 是 | 否 | 空间 id |
namespace.name |
string | 是 | 否 | 空间名称 |
namespace.path |
string | 是 | 否 | 空间路径(path) |
namespace.html_url |
string | 是 | 否 | 空间网页地址 |
creator 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
creator.id |
string | 是 | 否 | 创建者 id |
creator.arts_id |
string | 是 | 否 | 创建者 arts id |
creator.username |
string | 是 | 否 | 创建者用户名 |
creator.nickname |
string | 是 | 否 | 创建者昵称 |
creator.email |
string | 是 | 否 | 创建者邮箱 |
creator.photo |
string | 是 | 否 | 创建者头像地址 |
enterprise 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
enterprise.id |
integer | 是 | 否 | 企业 id |
enterprise.path |
string | 是 | 否 | 企业路径(path) |
enterprise.html_url |
string | 是 | 否 | 企业网页地址 |
enterprise.type |
string | 是 | 否 | 企业类型 |
owner 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
owner.id |
string | 是 | 否 | 属主 id |
owner.login |
string | 是 | 否 | 属主登录名 |
owner.name |
string | 是 | 否 | 属主名称 |
owner.type |
string | 是 | 否 | 属主类型 |
assigner 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
assigner.id |
string | 是 | 否 | 指派者 id |
assigner.login |
string | 是 | 否 | 指派者登录名 |
assigner.name |
string | 是 | 否 | 指派者名称 |
assigner.type |
string | 是 | 否 | 指派者类型 |
project_labels 数组元素
数组元素为对象,具体结构以实际返回为准。
失败响应¶
除成功响应外,调用方还需要了解失败时的返回形态。该接口需要认证,且请求的仓库不存在时也会返回失败。
401 未认证
404 资源不存在
错误字段名以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
304 |
未修改(Not modified) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not found) |
请求示例¶
参数说明¶
示例与本文档其余部分自洽,照抄即可调用成功。占位符含义如下:
<owner>替换为仓库所属空间地址 path(组织或个人的地址 path);<repo>替换为仓库路径(path);<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>?access_token=<token>' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const owner = "<owner>";
const repo = "<repo>";
const token = "<token>";
const response = await fetch(`https://api.atomgit.com/api/v5/repos/${owner}/${repo}?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
owner = "<owner>"
repo = "<repo>"
token = "<token>"
resp = requests.get(
f"https://api.atomgit.com/api/v5/repos/{owner}/{repo}",
params={"access_token": token},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"id": 4250980,
"full_name": "aron1/Model10123001",
"human_name": "aron1 / Model10123001",
"url": "https://api.atomgit.com/api/v5/repos/aron1/Model10123001",
"namespace": {
"id": 1364544,
"name": "aron1",
"path": "aron1",
"html_url": "https://api.atomgit.com/aron1"
},
"path": "Model10123001",
"name": "Model10123001",
"description": "",
"status": "关闭",
"ssh_url_to_repo": "git@atomgit.com:aron1/Model10123001.git",
"http_url_to_repo": "https://api.atomgit.com/aron1/Model10123001.git",
"web_url": "https://api.atomgit.com/aron1/Model10123001",
"readme_url": "https://api.atomgit.com/aron1/Model10123001/blob/main/README.md",
"created_at": "2024-10-22T22:14:06.922+08:00",
"updated_at": "2024-12-02T18:37:23.426+08:00",
"creator": {
"id": "660ba866683c570b25be06c8",
"arts_id": "332008",
"username": "aron1",
"nickname": "yanfan",
"email": "aron1@noreply.atomgit.com",
"photo": "https://api.atomgit.com/images/avatar.png"
},
"members": ["aron1"],
"forks_count": 0,
"stargazers_count": 1,
"project_labels": [],
"license": "Apache_License_v2.0",
"internal": 0,
"open_issues_count": 0,
"watchers_count": 0,
"assignees_number": 0,
"enterprise": {
"id": 1364544,
"path": "aron1",
"html_url": "https://api.atomgit.com/aron1",
"type": "user"
},
"default_branch": "main",
"fork": 0,
"owner": {
"id": "332008",
"login": "aron1",
"name": "yanfan",
"type": "User"
},
"assigner": {
"id": "332008",
"login": "aron1",
"name": "yanfan",
"type": "User"
},
"issue_template_source": "project",
"private": 1,
"public": 0
}
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
403 |
无权限访问该资源 |
404 |
请求的仓库不存在 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc