跳转至

获取企业Issue列表

POST /api/v8/enterprises/{enterprise_id}/issues

获取指定企业下的 Issue 列表。

访问令牌支持说明

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

是否允许匿名访问

此接口不允许匿名访问

请求参数

参数名 位置 类型 必填 说明
enterprise_id path string 是 企业id
access_token query string 是 用户授权码

Request Body:

请求体为 JSON 对象,字段均为可选的过滤条件。

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "page": {
      "description": "当前的页码,默认 1",
      "type": "integer",
      "default": 1
    },
    "per_page": {
      "description": "每页的数量,最大为 100,默认 20",
      "type": "integer",
      "default": 20,
      "maximum": 100
    },
    "labels": {
      "description": "标签,多个按英文逗号隔开",
      "type": "string"
    },
    "sort": {
      "description": "排序依据:created(创建时间)、updated_at(更新时间),默认 created_at",
      "type": "string",
      "enum": ["created", "updated_at"],
      "default": "created_at"
    },
    "direction": {
      "description": "排序方式:asc(升序)、desc(降序),默认 desc",
      "type": "string",
      "enum": ["asc", "desc"],
      "default": "desc"
    },
    "since": {
      "description": "起始的更新时间,要求时间格式为 ISO 8601",
      "type": "string",
      "format": "date-time"
    },
    "assignees": {
      "description": "负责人的用户名",
      "type": "array",
      "items": {"type": "string"}
    },
    "milestone_ids": {
      "description": "企业里程碑id",
      "type": "array",
      "items": {"type": "integer"}
    },
    "project_ids": {
      "description": "项目id",
      "type": "array",
      "items": {"type": "integer"}
    },
    "create_at": {
      "description": "任务创建日期,格式 2024-11-09",
      "type": "string",
      "format": "date"
    },
    "created_before": {
      "description": "任务创建截止时间,格式 2024-11-09",
      "type": "string",
      "format": "date"
    },
    "search": {
      "description": "通过关键字搜索 issue 标题",
      "type": "string"
    },
    "issue_types": {
      "description": "issue 自定义类型",
      "type": "array",
      "items": {"type": "string"}
    },
    "issue_states": {
      "description": "issue 自定义状态",
      "type": "array",
      "items": {"type": "string"}
    },
    "custom_fields": {
      "description": "自定义字段过滤条件",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "field_name": {
            "description": "字段名",
            "type": "string"
          },
          "values": {
            "description": "字段值列表",
            "type": "array",
            "items": {"type": "string"}
          },
          "operation": {
            "description": "操作类型:search(模糊搜索)、greater_equal(大于等于)、less_equal(小于等于)、between(在什么之间)、in(精确匹配)",
            "type": "string",
            "enum": ["search", "greater_equal", "less_equal", "between", "in"]
          }
        },
        "required": ["operation"]
      }
    }
  },
  "required": []
}

响应参数

响应体为 issue 对象数组,每个元素的结构如下:

字段 类型 必返 可为空 说明
id integer 是 否 issue id
html_url string 是 否 issue 的 HTML 地址
number string 是 否 issue 编号
state string 是 否 状态
title string 是 否 标题
body string 是 否 内容
user object 是 否 作者
repository object 是 否 仓库信息
assigner object 是 是 负责人
paas string 是 否 paas 标识
created_at string 是 是 创建时间
updated_at string 是 是 更新时间
finished_at string 是 是 完成时间
deadline string 是 是 截止时间
labels object[] 是 是 标签列表
issue_state string 否 是 issue 自定义状态
comments integer 是 否 评论数
custom_fields object[] 否 是 issue 自定义字段
issue_type string 否 是 issue 类型
issue_priority string 否 是 issue 优先级
url string 是 否 issue 地址
repository_url string 是 否 仓库地址
visibility_reason string 否 是 可见性,public:公开可见;confidential:私密,项目成员可见;other:其他原因导致的仅项目成员可见
related_branches string[] 否 是 关联的分支列表
linked_pulls object[] 否 是 关联的 pull request 列表

user 对象

字段 类型 必返 可为空 说明
user.id string 是 否 用户 id
user.object_id string 是 否 用户 object id
user.login string 是 否 用户名
user.name string 是 否 用户名称

repository 对象

字段 类型 必返 可为空 说明
repository.id integer 是 否 仓库 id
repository.full_name string 是 否 仓库完整名称
repository.human_name string 是 否 仓库可读名称
repository.path string 是 否 仓库路径
repository.name string 是 否 仓库名称
repository.url string 是 否 仓库地址
repository.assigner object 是 是 负责人
repository.paas string 是 否 paas 标识

labels 数组元素

字段 类型 必返 可为空 说明
labels.id integer 是 否 标签 id
labels.name string 是 否 标签名称
labels.color string 是 否 标签颜色

custom_fields 数组元素

字段 类型 必返 可为空 说明
custom_fields.field_name string 是 否 字段名
custom_fields.field_values string[] 是 否 字段值列表

linked_pulls 数组元素

字段 类型 必返 可为空 说明
linked_pulls.number integer 是 否 pull request 编号
linked_pulls.html_url string 是 否 pull request 的 HTML 地址
linked_pulls.user object 是 否 pull request 作者
linked_pulls.id integer 是 否 pull request id
linked_pulls.project_id integer 是 否 项目 id
linked_pulls.title string 是 否 标题
linked_pulls.body string 是 否 内容
linked_pulls.state string 是 否 状态
linked_pulls.created_at string 是 否 创建时间
linked_pulls.updated_at string 是 否 更新时间
linked_pulls.merged_at string 是 否 合并时间
linked_pulls.merged_by object 是 否 合并人
linked_pulls.closed_at string 是 否 关闭时间
linked_pulls.target_branch string 是 否 目标分支
linked_pulls.source_branch string 是 否 源分支
linked_pulls.source_project_id integer 是 否 源项目 id
linked_pulls.target_project_id integer 是 否 目标项目 id

linked_pulls.user 对象

字段 类型 必返 可为空 说明
linked_pulls.user.id string 是 否 用户 id
linked_pulls.user.login string 是 否 用户名
linked_pulls.user.name string 是 否 用户名称
linked_pulls.user.avatar_url string 是 否 用户头像地址
linked_pulls.user.html_url string 是 否 用户主页地址

linked_pulls.merged_by 对象

字段 类型 必返 可为空 说明
linked_pulls.merged_by.id string 是 否 用户 id
linked_pulls.merged_by.login string 是 否 用户名
linked_pulls.merged_by.name string 是 否 用户名称
linked_pulls.merged_by.avatar_url string 是 否 用户头像地址
linked_pulls.merged_by.html_url string 是 否 用户主页地址

失败响应

该接口需要携带用户访问令牌,令牌缺失或无效时返回 401。错误字段名以后端实际返回为准。

401 未认证

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

403 禁止访问

{
  "error": "forbidden",
  "message": "没有权限访问该企业的 Issue 列表"
}

HTTP 响应状态码

状态码 说明
200 成功(OK)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)

请求示例

参数说明

<enterprise_id> 替换为企业 id;<token> 替换为你的 AtomGit 用户访问令牌。

cURL

curl -X POST 'https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/issues?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "page": 1,
    "per_page": 20,
    "labels": "bug,ui",
    "sort": "created",
    "direction": "desc",
    "search": "登录"
  }'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
  "https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/issues?access_token=<token>",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json"
    },
    body: JSON.stringify({
      page: 1,
      per_page: 20,
      labels: "bug,ui",
      sort: "created",
      direction: "desc",
      search: "登录"
    })
  }
);

if (!response.ok) {
  throw new Error(`请求失败: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.post(
    "https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/issues",
    params={"access_token": "<token>"},
    json={
        "page": 1,
        "per_page": 20,
        "labels": "bug,ui",
        "sort": "created",
        "direction": "desc",
        "search": "登录"
    },
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

[
  {
    "id": 12,
    "html_url": "https://api.atomgit.com/enterprises/example/issues/12",
    "number": "12",
    "state": "open",
    "title": "登录页样式优化",
    "body": "修复登录页在移动端下的样式问题",
    "user": {
      "id": "10001",
      "object_id": "a1b2c3d4",
      "login": "octocat",
      "name": "Octo Cat"
    },
    "repository": {
      "id": 100,
      "full_name": "example/repo",
      "human_name": "示例仓库",
      "path": "example/repo",
      "name": "repo",
      "url": "https://api.atomgit.com/example/repo",
      "assigner": {},
      "paas": "gitcode"
    },
    "created_at": "2026-10-01T10:00:00+08:00",
    "updated_at": "2026-10-05T10:00:00+08:00",
    "finished_at": null,
    "deadline": null,
    "labels": [
      {
        "id": 1,
        "name": "bug",
        "color": "#d73a4a"
      }
    ],
    "issue_state": "进行中",
    "comments": 3,
    "custom_fields": [
      {
        "field_name": "优先级",
        "field_values": ["高"]
      }
    ],
    "issue_type": "需求",
    "issue_priority": "高",
    "url": "https://api.atomgit.com/api/v8/enterprises/example/issues/12",
    "repository_url": "https://api.atomgit.com/example/repo",
    "visibility_reason": "public",
    "related_branches": ["feature/login"],
    "linked_pulls": [
      {
        "number": 88,
        "html_url": "https://api.atomgit.com/example/repo/pulls/88",
        "user": {
          "id": "10001",
          "login": "octocat",
          "name": "Octo Cat",
          "avatar_url": "https://api.atomgit.com/avatar.png",
          "html_url": "https://api.atomgit.com/octocat"
        },
        "id": 88,
        "project_id": 100,
        "title": "优化登录页样式",
        "body": "修复移动端样式",
        "state": "merged",
        "created_at": "2026-10-02T10:00:00+08:00",
        "updated_at": "2026-10-03T10:00:00+08:00",
        "merged_at": "2026-10-04T10:00:00+08:00",
        "merged_by": {
          "id": "10001",
          "login": "octocat",
          "name": "Octo Cat",
          "avatar_url": "https://api.atomgit.com/avatar.png",
          "html_url": "https://api.atomgit.com/octocat"
        },
        "closed_at": "2026-10-04T10:00:00+08:00",
        "target_branch": "main",
        "source_branch": "feature/login",
        "source_project_id": 100,
        "target_project_id": 100
      }
    ]
  }
]

错误码

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

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