跳转至

列出仓库的WebHooks

GET /api/v5/repos/{owner}/{repo}/hooks

该接口用于列出指定仓库已配置的 WebHooks,返回各 Webhook 的 ID、触发事件类型、激活状态及创建时间等信息,并支持分页查询。

访问令牌支持说明

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

是否允许匿名访问

此接口不允许匿名访问

请求参数

参数名 位置 类型 必填 说明
owner path string 是 仓库所属空间地址(企业、组织或个人的地址path)
repo path string 是 仓库路径(path)
access_token query string 是 用户授权码
page query integer 否 当前的页码,默认 1
per_page query integer 否 每页的数量,最大为 100,默认 20

响应参数

字段 类型 必返 可为空 说明
id integer 是 是 Webhook 的 ID
url string 是 是 Webhook 的 URL
password string 是 是 Webhook 的密码
result string 是 是 测试结果
project_id integer 是 是 所属仓库的 ID
result_code integer 是 是 测试结果的状态码
push_events boolean 是 是 是否触发 push 事件
tag_push_events boolean 是 是 是否触发标签 push 事件
issues_events boolean 是 是 是否触发 Issue 事件
note_events boolean 是 是 是否触发评论/备注事件
merge_requests_events boolean 是 是 是否触发合并请求事件
created_at string 是 是 创建时间
active boolean 是 是 是否激活

失败响应

401 未认证

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

错误字段名以后端实际返回为准。

HTTP 响应状态码

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

请求示例

参数说明

<owner> 替换为仓库所属空间地址(企业、组织或个人的地址 path); <repo> 替换为仓库路径(path); <token> 替换为你的 AtomGit 用户访问令牌。

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/hooks?access_token=<token>&page=1&per_page=20' \
  -H 'Accept: application/json'

JavaScript

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

print(resp.json())

响应示例

状态码: 200

[
  {
    "id": 9523,
    "url": "https://api.atomgit.com/webhook/example",
    "password": "123445",
    "result": "success",
    "project_id": 282463,
    "result_code": 200,
    "push_events": true,
    "tag_push_events": false,
    "issues_events": true,
    "note_events": false,
    "merge_requests_events": true,
    "created_at": "2024-09-18T17:51:44+08:00",
    "active": true
  }
]

错误码

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

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