跳转至

查询space可用的基础镜像列表

GET /api/v5/spaces/base-images

用于查询 AI 空间中可用的基础镜像列表,支持分页,并可按镜像中安装的 sdk 类型过滤。

访问令牌支持说明

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

是否允许匿名访问

此接口允许匿名访问

请求参数

参数名 位置 类型 必填 说明
page query integer 否 页码,默认 1
per_page query integer 否 每页数量,默认 20
sdk query string 否 镜像中安装的 sdk,枚举:gradio / static

响应参数

字段 类型 必返 可为空 说明
page_num integer 是 否 当前页码
page_size integer 是 否 每页数量
total integer 是 否 总记录数
page_count integer 是 否 总页数
content array<object> 是 否 基础镜像列表

content 数组元素

字段 类型 必返 可为空 说明
content[].id string 是 是 镜像唯一标识ID
content[].name string 是 是 镜像名称
content[].description string 是 是 镜像描述信息
content[].architecture string 是 是 镜像架构类型,比如 arm64 或 x86
content[].os string 是 是 镜像中的系统名称

失败响应

401 未认证

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

403 禁止访问

{
  "error": "forbidden",
  "message": "无权访问该资源"
}

HTTP 响应状态码

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

请求示例

参数说明

  • <token> 替换为你的 AtomGit 用户访问令牌(本接口允许匿名访问,也可不携带该请求头)。

cURL

curl -X GET 'https://api.atomgit.com/api/v5/spaces/base-images?page=1&per_page=20&sdk=gradio' \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/spaces/base-images?page=1&per_page=20&sdk=gradio", {
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <YOUR-TOKEN>",
  },
});

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/spaces/base-images",
    params={"page": 1, "per_page": 20, "sdk": "gradio"},
    headers={
        "Accept": "application/json",
        "Authorization": "Bearer <YOUR-TOKEN>",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "page_num": 1,
  "page_size": 20,
  "total": 1,
  "page_count": 1,
  "content": [
    {
      "id": "ad9a05a3ba3943a4a53708840a44beca",
      "name": "Ubuntu 22.04 + Python 3.10",
      "description": "预装 Python 3.10 的 Ubuntu 22.04 基础镜像",
      "architecture": "x86",
      "os": "Ubuntu"
    }
  ]
}

错误码

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

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