获取仓库所有任务标签¶
GET /api/v5/repos/{owner}/{repo}/labels
该接口用于获取指定仓库中的所有任务标签,返回标签的 ID、名称、颜色及所属仓库 ID 等信息,并支持通过分页参数控制返回的标签数量。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
page |
query | string | 否 | 当前的页码 |
per_page |
query | string | 否 | 每页的数量,最大为 100,默认 100 |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | 标签 ID |
name |
string | 是 | 否 | 标签名称 |
color |
string | 是 | 否 | 标签颜色 |
repository_id |
integer | 是 | 否 | 仓库 ID |
Note: 响应体为标签(label)对象数组,数组元素为单个标签对象。
失败响应¶
该接口可能返回如下失败响应:
400 参数错误
404 资源不存在
错误字段名以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad request) |
404 |
资源不存在(Not found) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
<owner> 替换为仓库所属空间地址(企业、组织或个人的地址 path);<repo> 替换为仓库路径(path)。本接口允许匿名访问,也可通过 access_token 查询参数携带 AtomGit 用户访问令牌进行认证。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/labels' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/labels", {
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/repos/<owner>/<repo>/labels",
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
[
{
"id": 12738107,
"name": "wontfix",
"color": "#CCCCCC",
"repository_id": 4066481
},
{
"id": 12738106,
"name": "question",
"color": "#D876E3",
"repository_id": 4066481
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
404 |
请求路径或资源不存在 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc