跳转至

获取组织项目列表

GET /api/v5/orgs/{org}/repos

用户调用此接口,获取指定组织下的项目(仓库)列表。

访问令牌支持说明

  • AtomGit 用户访问令牌(AtomGit user access tokens)

是否允许匿名访问

此接口允许匿名访问

请求参数

参数名 位置 类型 必填 说明
org path string 是 组织的路径(path/login)
type query string 否 筛选公开/私有仓库的类型,枚举:all / public / private;默认 all
page query integer 否 当前页码,默认 1
per_page query integer 否 每页数量,最大 100,默认 20
repo_type query string 否 筛选仓库类型,枚举:code(代码仓)/ model(模型仓)/ dataset(数据集仓)/ space / all(所有仓库类型);默认 code

响应参数

响应体为数组(array),数组元素为仓库(Repository)对象,字段说明如下。

字段 类型 必返 可为空 说明
id integer 是 否 仓库 ID
full_name string 是 否 仓库完整名称(如 owner/name)
namespace object 是 否 命名空间信息
path string 是 否 仓库路径
name string 是 否 仓库名称
internal boolean 是 否 是否为内部仓库
fork boolean 是 否 是否为 Fork 仓库
html_url string 是 否 仓库的 HTML 访问地址
forks_count integer 是 否 Fork 数量
stargazers_count integer 是 否 Star 数量
watchers_count integer 是 否 关注(Watch)数量
default_branch string 是 否 默认分支名称
open_issues_count integer 是 否 打开的 Issue 数量
project_creator string 是 否 项目创建者
pushed_at string 是 否 最近推送时间
created_at string 是 否 创建时间
updated_at string 是 否 更新时间
status string 是 否 仓库状态,0:开始(仓库未归档),2:关闭(仓库已归档)
language string 是 否 主要编程语言
repo_type string 是 否 仓库类型
parent object 是 否 父仓库信息(Fork 来源)
private boolean 是 否 是否为私有仓库
public boolean 是 否 是否为公开仓库
description string 是 否 仓库描述
license string 否 是 开源许可证,可能为 null

namespace 对象

字段 类型 必返 可为空 说明
namespace.id integer 是 否 命名空间 ID
namespace.type string 是 否 命名空间类型(如 group)
namespace.name string 是 否 命名空间名称
namespace.path string 是 否 命名空间路径
namespace.html_url string 是 否 命名空间的 HTML 访问地址

parent 对象

字段 类型 必返 可为空 说明
parent.id integer 是 否 父仓库 ID
parent.full_name string 是 否 父仓库完整名称
parent.human_name string 是 否 父仓库可读名称
parent.namespace object 是 否 父仓库的命名空间信息
parent.path string 是 否 父仓库路径
parent.name string 是 否 父仓库名称
parent.description string 是 否 父仓库描述
parent.ssh_url_to_repo string 是 否 父仓库的 SSH 地址
parent.http_url_to_repo string 是 否 父仓库的 HTTP 地址
parent.web_url string 是 否 父仓库的 Web 地址
parent.created_at string 是 否 父仓库创建时间
parent.updated_at string 是 否 父仓库更新时间
parent.repo_type string 是 否 父仓库类型
parent.private boolean 是 否 父仓库是否为私有仓库
parent.public boolean 是 否 父仓库是否为公开仓库

parent.namespace 对象

字段 类型 必返 可为空 说明
parent.namespace.id integer 是 否 命名空间 ID
parent.namespace.type string 是 否 命名空间类型
parent.namespace.name string 是 否 命名空间名称
parent.namespace.path string 是 否 命名空间路径
parent.namespace.full_name string 是 否 命名空间完整名称
parent.namespace.full_path string 是 否 命名空间完整路径

失败响应

该接口在参数错误、认证失败或组织不存在等情况下可能返回失败响应。错误字段名以后端实际返回为准。

400 参数错误

{
  "message": "参数 type 取值不合法"
}

401 未认证

{
  "message": "缺少或无效的访问令牌"
}

404 组织不存在

{
  "message": "未找到该组织"
}

HTTP 响应状态码

状态码 说明
200 成功(OK)
304 未修改(Not modified)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
404 组织或资源不存在(Not found)

请求示例

参数说明

<org> 替换为组织的路径(path/login),如 openharmony; 本接口允许匿名访问,也可携带 AtomGit 用户访问令牌。

cURL

curl -X GET 'https://api.atomgit.com/api/v5/orgs/<org>/repos?type=all&page=1&per_page=20&repo_type=code' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/orgs/<org>/repos?type=all&page=1&per_page=20&repo_type=code", {
  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/orgs/<org>/repos",
    params={
        "type": "all",
        "page": 1,
        "per_page": 20,
        "repo_type": "code",
    },
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

[
  {
    "id": 29724198,
    "full_name": "openharmony/.gitee",
    "namespace": {
      "id": 6486504,
      "type": "group",
      "name": "OpenHarmony",
      "path": "openharmony",
      "html_url": "https://api.atomgit.com/openharmony"
    },
    "path": ".gitee",
    "name": ".gitee",
    "description": "",
    "private": false,
    "public": true,
    "internal": false,
    "fork": false,
    "html_url": "https://api.atomgit.com/openharmony/.gitee.git",
    "forks_count": 4,
    "stargazers_count": 0,
    "watchers_count": 1,
    "default_branch": "master",
    "open_issues_count": 0,
    "license": null,
    "project_creator": "landwind",
    "pushed_at": "2024-02-06T18:25:26+08:00",
    "created_at": "2023-06-16T10:55:42+08:00",
    "updated_at": "2024-03-29T14:59:46+08:00",
    "status": "0",
    "repo_type": "code"
  }
]

错误码

错误码 说明
401 未认证或凭证无效(缺少/无效的访问凭证)
400 参数错误或请求无法解析
404 请求路径不存在或组织不存在
405 请求方法不支持
429 请求过于频繁,触发限流
500 系统内部错误

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc