获取仓库的最新的Release¶
GET /api/v5/repos/*/*/releases/latest
用户调用此接口,获取指定仓库的最新的 Release 信息(支持按 type 选择最新发布或最后更新的 Release)。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址path) |
repo |
path | string | 是 | 仓库路径(path) |
type |
query | string | 否 | 类型。updated(最后更新的),latest(最新的);默认 updated |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
tag_name |
string | 是 | 是 | Release 对应的标签名称 |
target_commitish |
string | 是 | 是 | Release 对应的目标提交(commit SHA),可能为 null |
prerelease |
boolean | 是 | 是 | 是否为预发布版本,可能为 null |
name |
string | 是 | 是 | Release 名称 |
body |
string | 是 | 是 | Release 描述内容 |
author |
object | 是 | 是 | Release 作者信息,可能为 null |
created_at |
string | 是 | 是 | Release 创建时间 |
assets |
object[] | 是 | 是 | Release 附件列表,可能为 null |
release_status |
string | 是 | 是 | Release 状态:pre 预发布版本,lasted 最新版本,可能为 null |
author 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
author.id |
string | 否 | 是 | 用户 ID |
author.login |
string | 否 | 是 | 登录名 |
author.name |
string | 否 | 是 | 用户昵称 |
author.avatar_url |
string | 否 | 是 | 头像地址 |
author.html_url |
string | 否 | 是 | 个人主页地址 |
author.type |
string | 否 | 是 | 用户类型(如 User) |
author.url |
string | 否 | 是 | 用户 API 地址 |
author.objectId |
string | 否 | 是 | 对象 ID,可能为 null |
author.email |
string | 否 | 是 | 邮箱,可能为 null |
assets[] 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
assets[].browser_download_url |
string | 否 | 是 | 附件的下载地址 |
assets[].name |
string | 否 | 是 | 附件名称 |
assets[].type |
string | 否 | 是 | 附件类型(SOURCE 源码包 / ATTACH_FILE 附件文件) |
assets[].temp_download_url |
string | 否 | 是 | 临时下载地址,可能为 null |
assets[].id |
integer | 否 | 是 | 附件 ID,可能为 null |
失败响应¶
400 参数错误
当 type 取值不支持,或未找到最新的 Release 时返回:
401 未认证
携带无效的访问令牌时返回:
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(如 type 取值不支持、未找到 Release) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
请求示例¶
参数说明¶
<owner>替换为仓库所属空间地址(企业、组织或个人的地址 path);<repo>替换为仓库路径(path);<token>替换为你的 AtomGit 用户访问令牌(可选,本接口允许匿名访问)。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/latest?type=latest' \
-H 'Accept: application/json'
携带访问令牌的调用方式:
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/latest?type=latest&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>/releases/latest?type=latest",
{
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>/releases/latest",
params={"type": "latest"},
headers={
"Accept": "application/json",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"tag_name": "V0.0.1",
"target_commitish": "b33d10690347a36ccbf7464fe16466c1409f9533",
"prerelease": false,
"name": "V0.0.1",
"body": "V0.0.1",
"author": {
"id": "645",
"login": "yanfan",
"name": "殿前都点检",
"avatar_url": "https://api.atomgit.com/avatar.png",
"html_url": "https://api.atomgit.com/yanfan",
"type": "User",
"url": "https://api.atomgit.com/api/v5/users/yanfan"
},
"created_at": "2024-04-15T20:43:35+08:00",
"assets": [
{
"browser_download_url": "https://api.atomgit.com/<owner>/<repo>/-/archive/V0.0.1/<repo>-V0.0.1.zip",
"name": "<repo>-V0.0.1.zip",
"type": "SOURCE"
},
{
"browser_download_url": "https://api.atomgit.com/<owner>/<repo>/-/archive/V0.0.1/<repo>-V0.0.1.tar.gz",
"name": "<repo>-V0.0.1.tar.gz",
"type": "SOURCE"
}
],
"release_status": "lasted"
}
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误(如 type 取值不支持、未找到 Release) |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问,权限不足 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc