跳转至

下载指定 Artifact

GET /api/v8/repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}

用户调用此接口,进行下载指定 Artifact 操作。本接口返回制品 zip 的下载地址(302 跳转)。

访问令牌支持说明

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

是否允许匿名访问

此接口允许匿名访问

请求参数

参数名 位置 类型 必填 说明
owner path string 是 仓库所属空间地址(组织或个人的地址 path)
repo path string 是 仓库路径(path)
artifact_id path string 是 制品 ID
archive_format path string 是 归档格式,仅支持 zip

响应参数

该接口成功时返回 302 跳转到制品 zip 的下载地址,响应体为空对象 {},不包含业务字段。

失败响应

该接口通常以 302 跳转成功;失败时可能返回 404(仓库或制品不存在)。具体的错误响应字段以后端实际返回为准。

HTTP 响应状态码

状态码 说明
302 跳转到制品 zip 的下载地址(Found)
404 资源不存在(Not Found)
401 需要认证(Requires authentication)

请求示例

参数说明

该接口允许匿名访问,无需携带访问令牌;如需携带,可使用 AtomGit 用户访问令牌。

<owner> 替换为仓库所属空间地址(组织或个人的地址 path);<repo> 替换为仓库路径(path);<artifact_id> 替换为制品 ID;<archive_format> 替换为归档格式(仅支持 zip)。

cURL

curl -X GET 'https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/artifacts/<artifact_id>/<archive_format>' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/artifacts/<artifact_id>/<archive_format>", {
  headers: {
    "Accept": "application/json",
  },
});

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

console.log(response.status);

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/artifacts/<artifact_id>/<archive_format>",
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.url)

响应示例

状态码: 302

{}

错误码

错误码 说明
302 跳转到制品 zip 的下载地址
400 参数错误或请求无法解析
401 未认证或凭证无效
404 资源不存在
500 系统内部错误

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