获取仓库的单个Releases¶
GET /api/v5/repos/{owner}/{repo}/releases/{tag}
用户调用此接口,进行获取仓库的单个 Release 操作。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
tag |
path | string | 是 | Tag 名称 |
access_token |
query | string | 否 | 用户授权码 |
temp_download_url |
query | string | 否 | 是否返回源码包和附件临时下载地址,默认 false |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
tag_name |
string | 是 | 否 | Release 对应的 Tag 名称 |
target_commitish |
string | 是 | 否 | 目标提交(分支名或提交 SHA) |
prerelease |
boolean | 是 | 否 | 是否为预发布 |
name |
string | 是 | 否 | Release 名称 |
body |
string | 是 | 否 | Release 说明 |
author |
object | 是 | 否 | Release 作者信息 |
created_at |
string | 是 | 否 | 创建时间 |
assets |
object[] | 是 | 是 | 附件列表 |
release_status |
string | 是 | 否 | Release 状态 |
author 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
author.id |
string | 是 | 否 | 用户 ID |
author.login |
string | 是 | 否 | 登录名 |
author.name |
string | 是 | 否 | 用户名 |
author.avatar_url |
string | 是 | 否 | 头像地址 |
author.html_url |
string | 是 | 否 | 用户主页地址 |
author.type |
string | 是 | 否 | 用户类型 |
author.url |
string | 是 | 否 | 用户 API 地址 |
assets 数组元素
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
assets[].browser_download_url |
string | 是 | 否 | 浏览器下载地址 |
assets[].name |
string | 是 | 否 | 附件名称 |
assets[].type |
string | 是 | 否 | 附件类型 |
assets[].id |
integer | 否 | 是 | 附件 ID |
失败响应¶
400 参数错误
401 未认证
404 资源不存在
错误响应字段名以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not found) |
请求示例¶
参数说明¶
示例采用匿名访问方式,无需携带访问令牌;如需访问私有仓库资源,也可在 URL 中追加 access_token=<token>。
<owner>替换为仓库所属空间地址(企业、组织或个人的地址 path);<repo>替换为仓库路径(path);<tag>替换为要获取的 Release 的 Tag 名称。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>",
{
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/<tag>",
headers={
"Accept": "application/json",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"tag_name": "v1.0.0",
"target_commitish": "main",
"prerelease": false,
"name": "v1.0.0",
"body": "Initial release",
"author": {
"id": "123456",
"login": "octocat",
"name": "octocat",
"avatar_url": "https://api.atomgit.com/avatar.png",
"html_url": "https://api.atomgit.com/octocat",
"type": "user",
"url": "https://api.atomgit.com/octocat"
},
"created_at": "2024-01-01T00:00:00Z",
"assets": [
{
"browser_download_url": "https://api.atomgit.com/octocat/Hello-World/releases/download/v1.0.0/app.zip",
"name": "app.zip",
"type": "application/zip",
"id": 1
}
],
"release_status": "published"
}
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问 |
404 |
请求的 Release 不存在 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc