跳转至

分页查询企业标签

GET /api/v8/enterprises/{enterprise_id}/label

用户调用此接口,分页查询企业下的标签列表。

访问令牌支持说明

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

是否允许匿名访问

此接口允许匿名访问

请求参数

参数名 位置 类型 必填 说明
enterprise_id path integer 是 企业 ID
order_by query string 否 排序字段,默认 created
sort query string 否 排序方向 asc/desc,默认 desc
include_expired query boolean 否 是否包含已过期项,默认 true
label_ids query integer[] 否 标签 ID 列表
search query string 否 搜索关键词,最长 100 个字符
page query integer 否 当前的页码,默认 1
per_page query integer 否 每页的数量,默认 20

响应参数

字段 类型 必返 可为空 说明
id integer 是 是 标签 ID
name string 是 是 标签名称
color string 是 是 标签颜色,如 #2865E0
description string 否 是 标签描述
repository_id integer 否 是 仓库 ID(本接口不填充,可能为 null)
url string 否 是 标签 URL(本接口不填充,可能为 null)
created_at string 否 是 创建时间(本接口不填充,可能为 null)
updated_at string 否 是 更新时间(本接口不填充,可能为 null)

Note: 响应体为标签对象数组;id、name、color、description 为本接口实际返回字段,其余字段虽然声明在响应 DTO 中,但本接口不填充,通常为 null(若序列化配置忽略 null 则不会出现在响应中)。

失败响应

接口在参数不合法或鉴权失败时会返回失败响应,错误字段名以后端实际返回为准。

400 参数错误

{
  "error": "invalid_request",
  "message": "参数不合法"
}

401 未认证

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

HTTP 响应状态码

状态码 说明
200 成功(OK)
400 参数错误(Bad Request)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
404 请求路径不存在(Not Found)

请求示例

参数说明

接口允许匿名访问,请求示例中可不携带访问令牌;如需携带,将<token> 替换为你的 AtomGit 用户访问令牌。 <enterprise_id> 替换为企业 ID

<token> 替换为你的 AtomGit 用户访问令牌(可选)。

cURL

curl -X GET 'https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/label?page=1&per_page=20' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/label?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/v8/enterprises/<enterprise_id>/label",
    params={"page": 1, "per_page": 20},
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

[
  {
    "id": 382218,
    "name": "bug",
    "color": "#e03529",
    "description": "缺陷类问题标签"
  }
]

错误码

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

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