跳转至

列出仓库里的通知

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

该接口用于列出指定仓库中的通知,支持按是否未读、通知类型及时间范围进行筛选,也可通过通知 ID 精确查询,返回内容包括通知内容、触发用户信息及关联仓库等。

访问令牌支持说明

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

是否允许匿名访问

此接口不允许匿名访问

请求参数

参数名 位置 类型 必填 说明
owner path string 是 仓库所属空间地址(企业、组织或个人的地址 path)
repo path string 是 仓库路径(path)
access_token query string 是 用户授权码
unread query boolean 否 是否未读,默认 true
type query string 否 筛选指定类型的通知,枚举:all(所有)、event(事件通知)、referer(@ 通知)
since query string 否 只获取在给定时间前更新后的消息,要求时间格式为 ISO 8601
before query string 否 只获取在给定时间前更新的消息,要求时间格式为 ISO 8601
ids query string 否 指定一组通知 ID,以 , 分隔

响应参数

字段 类型 必返 可为空 说明
list array 是 否 通知列表

list 对象

字段 类型 必返 可为空 说明
list.id string 是 否 通知 ID
list.content string 是 否 通知内容
list.type string 是 否 通知类型
list.unread boolean 是 否 是否未读
list.update_at string 是 否 更新时间
list.html_url string 是 否 触发消息的资源访问地址
list.actor object 是 否 触发消息的用户信息
list.repository object 是 否 关联的仓库信息

list.actor 对象

字段 类型 必返 可为空 说明
list.actor.id integer 是 否 用户 ID
list.actor.login string 是 否 登录名
list.actor.name string 是 否 用户名称

list.repository 对象

字段 类型 必返 可为空 说明
list.repository.id integer 是 否 仓库 ID
list.repository.full_name string 是 否 仓库完整名称
list.repository.human_name string 是 否 仓库展示名称
list.repository.url string 是 否 仓库访问地址

失败响应

401 未认证

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

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

HTTP 响应状态码

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

请求示例

参数说明

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

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/notifications?access_token=<token>' \
  -H 'Accept: application/json'

JavaScript

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

print(resp.json())

响应示例

状态码: 200

{
  "list": [
    {
      "id": "string",
      "content": "string",
      "type": "string",
      "unread": true,
      "update_at": "string",
      "html_url": "string",
      "actor": {
        "id": 0,
        "login": "string",
        "name": "string"
      },
      "repository": {
        "id": 0,
        "full_name": "string",
        "human_name": "string",
        "url": "string"
      }
    }
  ]
}

错误码

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

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