跳到主要内容
REST API 现在已版本化。 更多信息,请参阅“关于 API 版本控制”。

软件包的 REST API 端点

使用 REST API 与 GitHub Packages 交互。

关于 GitHub Packages

GitHub Packages 支持一系列用于发布软件包的包管理器。更多信息,请参阅“GitHub Packages 简介”。

发布软件包后,您可以使用 REST API 管理 GitHub 代码库和组织中的软件包。更多信息,请参阅“删除和恢复软件包”。

要使用 REST API 管理 GitHub Packages,必须使用个人访问令牌(经典)进行身份验证。

  • 要访问软件包元数据,您的令牌必须包含 `read:packages` 作用域。
  • 要删除软件包和软件包版本,您的令牌必须包含 `read:packages` 和 `delete:packages` 作用域。
  • 要恢复软件包和软件包版本,您的令牌必须包含 `read:packages` 和 `write:packages` 作用域。

如果您的软件包位于支持细粒度权限的注册表中,则您的令牌不需要 `repo` 作用域即可访问或管理此软件包。如果您的软件包位于仅支持代码库范围权限的注册表中,则您的令牌还必须包含 `repo` 作用域,因为您的软件包继承自 GitHub 代码库的权限。有关仅支持代码库范围权限的注册表列表,请参阅“关于 GitHub Packages 的权限”。

获取组织 Docker 迁移期间冲突的软件包列表

列出特定组织中、请求用户可读且在 Docker 迁移期间遇到冲突的所有软件包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。

“获取组织 Docker 迁移期间冲突的软件包列表”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

如果仅请求公共资源,则此端点无需身份验证即可使用。

“获取组织 Docker 迁移期间冲突的软件包列表”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
org 字符串 必需

组织名称。名称不区分大小写。

“获取组织 Docker 迁移期间冲突的软件包列表”的 HTTP 响应状态代码

状态代码描述
200

OK

401

需要身份验证

403

禁止

“获取组织 Docker 迁移期间冲突的软件包列表”的代码示例

请求示例

get/orgs/{org}/docker/conflicts
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/docker/conflicts

响应

状态:200
[ { "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }, { "id": 198, "name": "goodbye_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "version_count": 2, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/goodbye_docker", "created_at": "2020-05-20T22:19:11Z", "updated_at": "2020-05-20T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/goodbye_docker" } ]

列出组织的软件包

列出用户可读的组织中的软件包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“列出组织的软件包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“列出组织的软件包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
org 字符串 必需

组织名称。名称不区分大小写。

查询参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

visibility 字符串

所选软件包的可见性。此参数是可选的,仅过滤现有结果集。

`internal` 可见性仅适用于允许细粒度权限的 GitHub Packages 注册表。对于其他生态系统,`internal` 与 `private` 同义。有关支持细粒度权限的 GitHub Packages 注册表列表,请参阅“关于 GitHub Packages 的权限”。

可以是以下之一:publicprivateinternal

page 整数

要获取的结果的页码。更多信息,请参见“REST API 中使用分页”。

默认值:1

per_page 整数

每页结果数(最大 100)。更多信息,请参见“REST API 中使用分页”。

默认值:30

“列出组织的包”的 HTTP 响应状态码

状态代码描述
200

OK

400

per_page 的值乘以 page 不能大于 10000。

401

需要身份验证

403

禁止

“列出组织的包”的代码示例

请求示例

get/orgs/{org}/packages
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ "https://api.github.com/orgs/ORG/packages?package_type=container"

响应

状态:200
[ { "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }, { "id": 198, "name": "goodbye_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "version_count": 2, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/goodbye_docker", "created_at": "2020-05-20T22:19:11Z", "updated_at": "2020-05-20T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/goodbye_docker" } ]

获取组织的包

获取组织中的特定包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“获取组织的包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“获取组织的包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

org 字符串 必需

组织名称。名称不区分大小写。

“获取组织的包”的 HTTP 响应状态码

状态代码描述
200

OK

“获取组织的包”的代码示例

请求示例

get/orgs/{org}/packages/{package_type}/{package_name}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME

响应

状态:200
{ "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }

删除组织的包

删除组织中的整个包。如果任何版本的包下载次数超过 5000 次,则无法删除公共包。在这种情况下,请联系 GitHub 支持寻求进一步帮助。

经过身份验证的用户必须具有组织中的管理员权限才能使用此端点。如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则经过身份验证的用户还必须对该包具有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packagesdelete:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

“删除组织的包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“删除组织的包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

org 字符串 必需

组织名称。名称不区分大小写。

“删除组织的包”的 HTTP 响应状态码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“删除组织的包”的代码示例

请求示例

delete/orgs/{org}/packages/{package_type}/{package_name}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME

响应

状态:204

恢复组织的包

恢复组织中的整个包。

您可以在以下情况下恢复已删除的包

  • 该包是在过去 30 天内删除的。
  • 相同的包命名空间和版本仍然可用,并且没有被重复用于新的包。如果相同的包命名空间不可用,则您将无法恢复您的包。在这种情况下,要恢复已删除的包,您必须先删除使用已删除包的命名空间的新包。

经过身份验证的用户必须具有组织中的管理员权限才能使用此端点。如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则经过身份验证的用户还必须对该包具有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packageswrite:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

“恢复组织的包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“恢复组织的包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

org 字符串 必需

组织名称。名称不区分大小写。

查询参数
名称,类型,描述
token 字符串

包令牌

“恢复组织的包”的 HTTP 响应状态码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“恢复组织的包”的代码示例

请求示例

post/orgs/{org}/packages/{package_type}/{package_name}/restore
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/restore

响应

状态:204

列出组织拥有的包的包版本

列出组织拥有的包的包版本。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“列出组织拥有的包的包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“列出组织拥有的包的包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

org 字符串 必需

组织名称。名称不区分大小写。

查询参数
名称,类型,描述
page 整数

要获取的结果的页码。更多信息,请参见“REST API 中使用分页”。

默认值:1

per_page 整数

每页结果数(最大 100)。更多信息,请参见“REST API 中使用分页”。

默认值:30

state 字符串

包的状态,active 或 deleted。

默认值:active

可以是:active, deleted

“列出组织拥有的包的包版本”的 HTTP 响应状态码

状态代码描述
200

OK

401

需要身份验证

403

禁止

404

资源未找到

“列出组织拥有的包的包版本”的代码示例

请求示例

get/orgs/{org}/packages/{package_type}/{package_name}/versions
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions

响应

状态:200
[ { "id": 245301, "name": "1.0.4", "url": "https://api.github.com/orgs/octo-org/packages/npm/hello-world-npm/versions/245301", "package_html_url": "https://github.com/octo-org/hello-world-npm/packages/43752", "created_at": "2019-11-05T22:49:04Z", "updated_at": "2019-11-05T22:49:04Z", "html_url": "https://github.com/octo-org/hello-world-npm/packages/43752?version=1.0.4", "metadata": { "package_type": "npm" } }, { "id": 209672, "name": "1.0.3", "url": "https://api.github.com/orgs/octo-org/packages/npm/hello-world-npm/versions/209672", "package_html_url": "https://github.com/octo-org/hello-world-npm/packages/43752", "created_at": "2019-10-29T15:42:11Z", "updated_at": "2019-10-29T15:42:12Z", "html_url": "https://github.com/octo-org/hello-world-npm/packages/43752?version=1.0.3", "metadata": { "package_type": "npm" } } ]

获取组织的包版本

获取组织中的特定包版本。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“获取组织的包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“获取组织的包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

org 字符串 必需

组织名称。名称不区分大小写。

package_version_id 整数 必填

包版本的唯一标识符。

“获取组织的包版本”的 HTTP 响应状态码

状态代码描述
200

OK

“获取组织的包版本”的代码示例

请求示例

get/orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID

响应

状态:200
{ "id": 836, "name": "sha256:b3d3e366b55f9a54599220198b3db5da8f53592acbbb7dc7e4e9878762fc5344", "url": "https://api.github.com/orgs/github/packages/container/hello_docker/versions/836", "package_html_url": "https://github.com/orgs/github/packages/container/package/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/hello_docker/836", "metadata": { "package_type": "container", "container": { "tags": [ "latest" ] } } }

删除组织的包版本

删除组织中的特定包版本。如果包是公共的并且包版本下载次数超过 5000 次,则无法删除包版本。在这种情况下,请联系 GitHub 支持寻求进一步帮助。

经过身份验证的用户必须具有组织中的管理员权限才能使用此端点。如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则经过身份验证的用户还必须对该包具有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packagesdelete:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

“删除组织的包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“删除组织的包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

org 字符串 必需

组织名称。名称不区分大小写。

package_version_id 整数 必填

包版本的唯一标识符。

“删除组织的包版本”的 HTTP 响应状态码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“删除组织的包版本”的代码示例

请求示例

delete/orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID

响应

状态:204

恢复组织的包版本

恢复组织中的特定包版本。

您可以在以下情况下恢复已删除的包

  • 该包是在过去 30 天内删除的。
  • 相同的包命名空间和版本仍然可用,并且没有被重复用于新的包。如果相同的包命名空间不可用,则您将无法恢复您的包。在这种情况下,要恢复已删除的包,您必须先删除使用已删除包的命名空间的新包。

经过身份验证的用户必须具有组织中的管理员权限才能使用此端点。如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则经过身份验证的用户还必须对该包具有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packageswrite:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

“恢复组织的包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“恢复组织的包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

org 字符串 必需

组织名称。名称不区分大小写。

package_version_id 整数 必填

包版本的唯一标识符。

“恢复组织的包版本”的 HTTP 响应状态码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“恢复组织的包版本”的代码示例

请求示例

post/orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restore

响应

状态:204

获取经过身份验证的用户在 Docker 迁移期间发生冲突的包列表

列出在用户命名空间中由经过身份验证的用户拥有的所有包,以及在 Docker 迁移期间遇到冲突的包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。

“获取经过身份验证的用户在 Docker 迁移期间发生冲突的包列表”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“获取经过身份验证的用户在 Docker 迁移期间发生冲突的包列表”的 HTTP 响应状态码

状态代码描述
200

OK

“获取经过身份验证的用户在 Docker 迁移期间发生冲突的包列表”的代码示例

请求示例

get/user/docker/conflicts
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/docker/conflicts

响应

状态:200
[( { "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "octocat", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.octocatusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }, { "id": 198, "name": "goodbye_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 2, "visibility": "private", "url": "https://api.github.com/user/octocat/packages/container/goodbye_docker", "created_at": "2020-05-20T22:19:11Z", "updated_at": "2020-05-20T22:19:11Z", "html_url": "https://github.com/user/octocat/packages/container/package/goodbye_docker" } ]

列出认证用户的命名空间中的包

列出认证用户在其命名空间中拥有的包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“列出认证用户的命名空间中的包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“列出认证用户的命名空间中的包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

查询参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

visibility 字符串

所选软件包的可见性。此参数是可选的,仅过滤现有结果集。

`internal` 可见性仅适用于允许细粒度权限的 GitHub Packages 注册表。对于其他生态系统,`internal` 与 `private` 同义。有关支持细粒度权限的 GitHub Packages 注册表列表,请参阅“关于 GitHub Packages 的权限”。

可以是以下之一:publicprivateinternal

page 整数

要获取的结果的页码。更多信息,请参见“REST API 中使用分页”。

默认值:1

per_page 整数

每页结果数(最大 100)。更多信息,请参见“REST API 中使用分页”。

默认值:30

“列出认证用户的命名空间中的包”的HTTP响应状态码

状态代码描述
200

OK

400

per_page 的值乘以 page 不能大于 10000。

“列出认证用户的命名空间中的包”的代码示例

请求示例

get/user/packages
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ "https://api.github.com/user/packages?package_type=container"

响应

状态:200
[( { "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "octocat", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.octocatusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }, { "id": 198, "name": "goodbye_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 2, "visibility": "private", "url": "https://api.github.com/user/octocat/packages/container/goodbye_docker", "created_at": "2020-05-20T22:19:11Z", "updated_at": "2020-05-20T22:19:11Z", "html_url": "https://github.com/user/octocat/packages/container/package/goodbye_docker" } ]

获取认证用户的包

获取认证用户拥有的特定包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“获取认证用户的包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“获取认证用户的包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

“获取认证用户的包”的HTTP响应状态码

状态代码描述
200

OK

“获取认证用户的包”的代码示例

请求示例

get/user/packages/{package_type}/{package_name}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME

响应

状态:200
{ "id": 40201, "name": "octo-name", "package_type": "rubygems", "owner": { "login": "octocat", "id": 209477, "node_id": "MDQ6VXNlcjIwOTQ3Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/209477?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": true }, "version_count": 3, "visibility": "public", "url": "https://api.github.com/users/octocat/packages/rubygems/octo-name", "created_at": "2019-10-20T14:17:14Z", "updated_at": "2019-10-20T14:17:14Z", "repository": { "id": 216219492, "node_id": "MDEwOlJlcG9zaXRvcnkyMTYyMTk0OTI=", "name": "octo-name-repo", "full_name": "octocat/octo-name-repo", "private": false, "owner": { "login": "octocat", "id": 209477, "node_id": "MDQ6VXNlcjIwOTQ3Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/209477?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": true }, "html_url": "https://github.com/octocat/octo-name-repo", "description": "Project for octocats", "fork": false, "url": "https://api.github.com/repos/octocat/octo-name-repo", "forks_url": "https://api.github.com/repos/octocat/octo-name-repo/forks", "keys_url": "https://api.github.com/repos/octocat/octo-name-repo/keys{/key_id}", "collaborators_url": "https://api.github.com/repos/octocat/octo-name-repo/collaborators{/collaborator}", "teams_url": "https://api.github.com/repos/octocat/octo-name-repo/teams", "hooks_url": "https://api.github.com/repos/octocat/octo-name-repo/hooks", "issue_events_url": "https://api.github.com/repos/octocat/octo-name-repo/issues/events{/number}", "events_url": "https://api.github.com/repos/octocat/octo-name-repo/events", "assignees_url": "https://api.github.com/repos/octocat/octo-name-repo/assignees{/user}", "branches_url": "https://api.github.com/repos/octocat/octo-name-repo/branches{/branch}", "tags_url": "https://api.github.com/repos/octocat/octo-name-repo/tags", "blobs_url": "https://api.github.com/repos/octocat/octo-name-repo/git/blobs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/octo-name-repo/git/tags{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/octo-name-repo/git/refs{/sha}", "trees_url": "https://api.github.com/repos/octocat/octo-name-repo/git/trees{/sha}", "statuses_url": "https://api.github.com/repos/octocat/octo-name-repo/statuses/{sha}", "languages_url": "https://api.github.com/repos/octocat/octo-name-repo/languages", "stargazers_url": "https://api.github.com/repos/octocat/octo-name-repo/stargazers", "contributors_url": "https://api.github.com/repos/octocat/octo-name-repo/contributors", "subscribers_url": "https://api.github.com/repos/octocat/octo-name-repo/subscribers", "subscription_url": "https://api.github.com/repos/octocat/octo-name-repo/subscription", "commits_url": "https://api.github.com/repos/octocat/octo-name-repo/commits{/sha}", "git_commits_url": "https://api.github.com/repos/octocat/octo-name-repo/git/commits{/sha}", "comments_url": "https://api.github.com/repos/octocat/octo-name-repo/comments{/number}", "issue_comment_url": "https://api.github.com/repos/octocat/octo-name-repo/issues/comments{/number}", "contents_url": "https://api.github.com/repos/octocat/octo-name-repo/contents/{+path}", "compare_url": "https://api.github.com/repos/octocat/octo-name-repo/compare/{base}...{head}", "merges_url": "https://api.github.com/repos/octocat/octo-name-repo/merges", "archive_url": "https://api.github.com/repos/octocat/octo-name-repo/{archive_format}{/ref}", "downloads_url": "https://api.github.com/repos/octocat/octo-name-repo/downloads", "issues_url": "https://api.github.com/repos/octocat/octo-name-repo/issues{/number}", "pulls_url": "https://api.github.com/repos/octocat/octo-name-repo/pulls{/number}", "milestones_url": "https://api.github.com/repos/octocat/octo-name-repo/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/octo-name-repo/notifications{?since,all,participating}", "labels_url": "https://api.github.com/repos/octocat/octo-name-repo/labels{/name}", "releases_url": "https://api.github.com/repos/octocat/octo-name-repo/releases{/id}", "deployments_url": "https://api.github.com/repos/octocat/octo-name-repo/deployments" }, "html_url": "https://github.com/octocat/octo-name-repo/packages/40201" }

删除认证用户的包

删除认证用户拥有的包。如果任何版本的包下载量超过 5,000 次,则无法删除公共包。在这种情况下,请联系 GitHub 支持寻求进一步帮助。

OAuth 应用令牌和个人访问令牌(经典)需要read:packagesdelete:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

“删除认证用户的包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“删除认证用户的包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

“删除认证用户的包”的HTTP响应状态码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“删除认证用户的包”的代码示例

请求示例

delete/user/packages/{package_type}/{package_name}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME

响应

状态:204

恢复认证用户的包

恢复认证用户拥有的包。

您可以在以下情况下恢复已删除的包

  • 该包是在过去 30 天内删除的。
  • 相同的包命名空间和版本仍然可用,并且没有被重复用于新的包。如果相同的包命名空间不可用,则您将无法恢复您的包。在这种情况下,要恢复已删除的包,您必须先删除使用已删除包的命名空间的新包。

OAuth 应用令牌和个人访问令牌(经典)需要read:packageswrite:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

“恢复认证用户的包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“恢复认证用户的包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

查询参数
名称,类型,描述
token 字符串

包令牌

“恢复认证用户的包”的HTTP响应状态码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“恢复认证用户的包”的代码示例

请求示例

post/user/packages/{package_type}/{package_name}/restore
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/restore

响应

状态:204

列出认证用户拥有的包的版本

列出认证用户拥有的包的版本。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“列出认证用户拥有的包的版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“列出认证用户拥有的包的版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

查询参数
名称,类型,描述
page 整数

要获取的结果的页码。更多信息,请参见“REST API 中使用分页”。

默认值:1

per_page 整数

每页结果数(最大 100)。更多信息,请参见“REST API 中使用分页”。

默认值:30

state 字符串

包的状态,active 或 deleted。

默认值:active

可以是:active, deleted

“列出认证用户拥有的包的版本”的HTTP响应状态码

状态代码描述
200

OK

401

需要身份验证

403

禁止

404

资源未找到

“列出认证用户拥有的包的版本”的代码示例

请求示例

get/user/packages/{package_type}/{package_name}/versions
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions

响应

状态:200
[( { "id": 45763, "name": "sha256:08a44bab0bddaddd8837a8b381aebc2e4b933768b981685a9e088360af0d3dd9", "url": "https://api.github.com/users/octocat/packages/container/hello_docker/versions/45763", "package_html_url": "https://github.com/users/octocat/packages/container/package/hello_docker", "created_at": "2020-09-11T21:56:40Z", "updated_at": "2021-02-05T21:32:32Z", "html_url": "https://github.com/users/octocat/packages/container/hello_docker/45763", "metadata": { "package_type": "container", "container": { "tags": [ "latest" ] } } }, { "id": 881, "name": "sha256:b3d3e366b55f9a54599220198b3db5da8f53592acbbb7dc7e4e9878762fc5344", "url": "https://api.github.com/users/octocat/packages/container/hello_docker/versions/881", "package_html_url": "https://github.com/users/octocat/packages/container/package/hello_docker", "created_at": "2020-05-21T22:22:20Z", "updated_at": "2021-02-05T21:32:32Z", "html_url": "https://github.com/users/octocat/packages/container/hello_docker/881", "metadata": { "package_type": "container", "container": { "tags": [] } } } ]

获取认证用户的包版本

获取认证用户拥有的特定包版本。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

“获取认证用户的包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“获取认证用户的包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

package_version_id 整数 必填

包版本的唯一标识符。

“获取认证用户的包版本”的HTTP响应状态码

状态代码描述
200

OK

“获取认证用户的包版本”的代码示例

请求示例

get/user/packages/{package_type}/{package_name}/versions/{package_version_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID

响应

状态:200
{ "id": 214, "name": "sha256:3561f0cff06caccddb99c93bd26e712fcc56a811de0f8ea7a17bb865f30b176a", "url": "https://api.github.com/users/octocat/packages/container/hello_docker/versions/214", "package_html_url": "https://github.com/users/octocat/packages/container/package/hello_docker", "created_at": "2020-05-15T03:46:45Z", "updated_at": "2020-05-15T03:46:45Z", "html_url": "https://github.com/users/octocat/packages/container/hello_docker/214", "metadata": { "package_type": "container", "container": { "tags": [ "1.13.6" ] } } }

删除已认证用户的软件包版本

删除已认证用户拥有的软件包的特定版本。如果软件包是公开的,并且软件包版本下载量超过 5,000 次,则无法删除该软件包版本。在这种情况下,请联系 GitHub 支持寻求进一步帮助。

已认证用户必须在组织中拥有管理员权限才能使用此端点。

OAuth 应用令牌和个人访问令牌(经典)需要read:packagesdelete:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

用于“删除已认证用户的软件包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“删除已认证用户的软件包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

package_version_id 整数 必填

包版本的唯一标识符。

“删除已认证用户的软件包版本”的 HTTP 响应状态代码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“删除已认证用户的软件包版本”的代码示例

请求示例

delete/user/packages/{package_type}/{package_name}/versions/{package_version_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID

响应

状态:204

恢复已认证用户的软件包版本

恢复已认证用户拥有的软件包版本。

在以下情况下,您可以恢复已删除的软件包版本

  • 该包是在过去 30 天内删除的。
  • 相同的包命名空间和版本仍然可用,并且没有被重复用于新的包。如果相同的包命名空间不可用,则您将无法恢复您的包。在这种情况下,要恢复已删除的包,您必须先删除使用已删除包的命名空间的新包。

OAuth 应用令牌和个人访问令牌(经典)需要read:packageswrite:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

用于“恢复已认证用户的软件包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“恢复已认证用户的软件包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

package_version_id 整数 必填

包版本的唯一标识符。

“恢复已认证用户的软件包版本”的 HTTP 响应状态代码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“恢复已认证用户的软件包版本”的代码示例

请求示例

post/user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restore

响应

状态:204

获取用户 Docker 迁移期间冲突的软件包列表

列出特定用户命名空间中、请求用户有权访问并在 Docker 迁移期间遇到冲突的所有软件包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。

用于“获取用户 Docker 迁移期间冲突的软件包列表”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

如果仅请求公共资源,则此端点无需身份验证即可使用。

“获取用户 Docker 迁移期间冲突的软件包列表”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
username string 必填

GitHub 用户帐户的句柄。

“获取用户 Docker 迁移期间冲突的软件包列表”的 HTTP 响应状态代码

状态代码描述
200

OK

401

需要身份验证

403

禁止

“获取用户 Docker 迁移期间冲突的软件包列表”的代码示例

请求示例

get/users/{username}/docker/conflicts
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/docker/conflicts

响应

状态:200
[( { "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "octocat", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.octocatusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }, { "id": 198, "name": "goodbye_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 2, "visibility": "private", "url": "https://api.github.com/user/octocat/packages/container/goodbye_docker", "created_at": "2020-05-20T22:19:11Z", "updated_at": "2020-05-20T22:19:11Z", "html_url": "https://github.com/user/octocat/packages/container/package/goodbye_docker" } ]

列出用户的软件包

列出用户命名空间中请求用户有权访问的所有软件包。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

用于“列出用户的软件包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“列出用户的软件包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
username string 必填

GitHub 用户帐户的句柄。

查询参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

visibility 字符串

所选软件包的可见性。此参数是可选的,仅过滤现有结果集。

`internal` 可见性仅适用于允许细粒度权限的 GitHub Packages 注册表。对于其他生态系统,`internal` 与 `private` 同义。有关支持细粒度权限的 GitHub Packages 注册表列表,请参阅“关于 GitHub Packages 的权限”。

可以是以下之一:publicprivateinternal

page 整数

要获取的结果的页码。更多信息,请参见“REST API 中使用分页”。

默认值:1

per_page 整数

每页结果数(最大 100)。更多信息,请参见“REST API 中使用分页”。

默认值:30

“列出用户的软件包”的 HTTP 响应状态代码

状态代码描述
200

OK

400

per_page 的值乘以 page 不能大于 10000。

401

需要身份验证

403

禁止

“列出用户的软件包”的代码示例

请求示例

get/users/{username}/packages
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ "https://api.github.com/users/USERNAME/packages?package_type=container"

响应

状态:200
[( { "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "octocat", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.octocatusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }, { "id": 198, "name": "goodbye_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "User", "site_admin": false }, "version_count": 2, "visibility": "private", "url": "https://api.github.com/user/octocat/packages/container/goodbye_docker", "created_at": "2020-05-20T22:19:11Z", "updated_at": "2020-05-20T22:19:11Z", "html_url": "https://github.com/user/octocat/packages/container/package/goodbye_docker" } ]

获取用户的软件包

获取用户拥有的公共软件包的特定软件包元数据。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

用于“获取用户的软件包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“获取用户的软件包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

username string 必填

GitHub 用户帐户的句柄。

“获取用户的软件包”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取用户的软件包”的代码示例

请求示例

get/users/{username}/packages/{package_type}/{package_name}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME

响应

状态:200
{ "id": 40201, "name": "octo-name", "package_type": "rubygems", "owner": { "login": "octocat", "id": 209477, "node_id": "MDQ6VXNlcjIwOTQ3Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/209477?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": true }, "version_count": 3, "visibility": "public", "url": "https://api.github.com/users/octocat/packages/rubygems/octo-name", "created_at": "2019-10-20T14:17:14Z", "updated_at": "2019-10-20T14:17:14Z", "repository": { "id": 216219492, "node_id": "MDEwOlJlcG9zaXRvcnkyMTYyMTk0OTI=", "name": "octo-name-repo", "full_name": "octocat/octo-name-repo", "private": false, "owner": { "login": "octocat", "id": 209477, "node_id": "MDQ6VXNlcjIwOTQ3Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/209477?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": true }, "html_url": "https://github.com/octocat/octo-name-repo", "description": "Project for octocats", "fork": false, "url": "https://api.github.com/repos/octocat/octo-name-repo", "forks_url": "https://api.github.com/repos/octocat/octo-name-repo/forks", "keys_url": "https://api.github.com/repos/octocat/octo-name-repo/keys{/key_id}", "collaborators_url": "https://api.github.com/repos/octocat/octo-name-repo/collaborators{/collaborator}", "teams_url": "https://api.github.com/repos/octocat/octo-name-repo/teams", "hooks_url": "https://api.github.com/repos/octocat/octo-name-repo/hooks", "issue_events_url": "https://api.github.com/repos/octocat/octo-name-repo/issues/events{/number}", "events_url": "https://api.github.com/repos/octocat/octo-name-repo/events", "assignees_url": "https://api.github.com/repos/octocat/octo-name-repo/assignees{/user}", "branches_url": "https://api.github.com/repos/octocat/octo-name-repo/branches{/branch}", "tags_url": "https://api.github.com/repos/octocat/octo-name-repo/tags", "blobs_url": "https://api.github.com/repos/octocat/octo-name-repo/git/blobs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/octo-name-repo/git/tags{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/octo-name-repo/git/refs{/sha}", "trees_url": "https://api.github.com/repos/octocat/octo-name-repo/git/trees{/sha}", "statuses_url": "https://api.github.com/repos/octocat/octo-name-repo/statuses/{sha}", "languages_url": "https://api.github.com/repos/octocat/octo-name-repo/languages", "stargazers_url": "https://api.github.com/repos/octocat/octo-name-repo/stargazers", "contributors_url": "https://api.github.com/repos/octocat/octo-name-repo/contributors", "subscribers_url": "https://api.github.com/repos/octocat/octo-name-repo/subscribers", "subscription_url": "https://api.github.com/repos/octocat/octo-name-repo/subscription", "commits_url": "https://api.github.com/repos/octocat/octo-name-repo/commits{/sha}", "git_commits_url": "https://api.github.com/repos/octocat/octo-name-repo/git/commits{/sha}", "comments_url": "https://api.github.com/repos/octocat/octo-name-repo/comments{/number}", "issue_comment_url": "https://api.github.com/repos/octocat/octo-name-repo/issues/comments{/number}", "contents_url": "https://api.github.com/repos/octocat/octo-name-repo/contents/{+path}", "compare_url": "https://api.github.com/repos/octocat/octo-name-repo/compare/{base}...{head}", "merges_url": "https://api.github.com/repos/octocat/octo-name-repo/merges", "archive_url": "https://api.github.com/repos/octocat/octo-name-repo/{archive_format}{/ref}", "downloads_url": "https://api.github.com/repos/octocat/octo-name-repo/downloads", "issues_url": "https://api.github.com/repos/octocat/octo-name-repo/issues{/number}", "pulls_url": "https://api.github.com/repos/octocat/octo-name-repo/pulls{/number}", "milestones_url": "https://api.github.com/repos/octocat/octo-name-repo/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/octo-name-repo/notifications{?since,all,participating}", "labels_url": "https://api.github.com/repos/octocat/octo-name-repo/labels{/name}", "releases_url": "https://api.github.com/repos/octocat/octo-name-repo/releases{/id}", "deployments_url": "https://api.github.com/repos/octocat/octo-name-repo/deployments" }, "html_url": "https://github.com/octocat/octo-name-repo/packages/40201" }

删除用户的软件包

删除用户的整个软件包。如果软件包的任何版本下载量超过 5,000 次,则无法删除公共软件包。在这种情况下,请联系 GitHub 支持寻求进一步帮助。

如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则已认证用户必须对该软件包拥有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packagesdelete:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

用于“删除用户的软件包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“删除用户的软件包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

username string 必填

GitHub 用户帐户的句柄。

“删除用户的软件包”的 HTTP 响应状态代码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“删除用户的软件包”的代码示例

请求示例

delete/users/{username}/packages/{package_type}/{package_name}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME

响应

状态:204

恢复用户的软件包

恢复用户的整个软件包。

您可以在以下情况下恢复已删除的包

  • 该包是在过去 30 天内删除的。
  • 相同的包命名空间和版本仍然可用,并且没有被重复用于新的包。如果相同的包命名空间不可用,则您将无法恢复您的包。在这种情况下,要恢复已删除的包,您必须先删除使用已删除包的命名空间的新包。

如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则已认证用户必须对该软件包拥有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packageswrite:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

用于“恢复用户的软件包”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“恢复用户的软件包”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

username string 必填

GitHub 用户帐户的句柄。

查询参数
名称,类型,描述
token 字符串

包令牌

“恢复用户的软件包”的 HTTP 响应状态代码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“恢复用户的软件包”的代码示例

请求示例

post/users/{username}/packages/{package_type}/{package_name}/restore
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/restore

响应

状态:204

列出用户拥有的软件包的软件包版本

列出指定用户拥有的公共软件包的软件包版本。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

用于“列出用户拥有的软件包的软件包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“列出用户拥有的软件包的软件包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

username string 必填

GitHub 用户帐户的句柄。

“列出用户拥有的软件包的软件包版本”的 HTTP 响应状态代码

状态代码描述
200

OK

401

需要身份验证

403

禁止

404

资源未找到

“列出用户拥有的软件包的软件包版本”的代码示例

请求示例

get/users/{username}/packages/{package_type}/{package_name}/versions
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions

响应

状态:200
[ { "id": 3497268, "name": "0.3.0", "url": "https://api.github.com/users/octocat/packages/rubygems/octo-name/versions/3497268", "package_html_url": "https://github.com/octocat/octo-name-repo/packages/40201", "license": "MIT", "created_at": "2020-08-31T15:22:11Z", "updated_at": "2020-08-31T15:22:12Z", "description": "Project for octocats", "html_url": "https://github.com/octocat/octo-name-repo/packages/40201?version=0.3.0", "metadata": { "package_type": "rubygems" } }, { "id": 387039, "name": "0.2.0", "url": "https://api.github.com/users/octocat/packages/rubygems/octo-name/versions/387039", "package_html_url": "https://github.com/octocat/octo-name-repo/packages/40201", "license": "MIT", "created_at": "2019-12-01T20:49:29Z", "updated_at": "2019-12-01T20:49:30Z", "description": "Project for octocats", "html_url": "https://github.com/octocat/octo-name-repo/packages/40201?version=0.2.0", "metadata": { "package_type": "rubygems" } }, { "id": 169770, "name": "0.1.0", "url": "https://api.github.com/users/octocat/packages/rubygems/octo-name/versions/169770", "package_html_url": "https://github.com/octocat/octo-name-repo/packages/40201", "license": "MIT", "created_at": "2019-10-20T14:17:14Z", "updated_at": "2019-10-20T14:17:15Z", "html_url": "https://github.com/octocat/octo-name-repo/packages/40201?version=0.1.0", "metadata": { "package_type": "rubygems" } } ]

获取用户的软件包版本

获取指定用户拥有的公共软件包的特定软件包版本。

OAuth 应用令牌和个人访问令牌(经典)需要 `read:packages` 作用域才能使用此端点。更多信息,请参阅“关于 GitHub Packages 的权限”。

用于“获取用户的软件包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“获取用户的软件包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

package_version_id 整数 必填

包版本的唯一标识符。

username string 必填

GitHub 用户帐户的句柄。

“获取用户的软件包版本”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取用户的软件包版本”的代码示例

请求示例

get/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID

响应

状态:200
{ "id": 387039, "name": "0.2.0", "url": "https://api.github.com/users/octocat/packages/rubygems/octo-name/versions/387039", "package_html_url": "https://github.com/octocat/octo-name-repo/packages/40201", "license": "MIT", "created_at": "2019-12-01T20:49:29Z", "updated_at": "2019-12-01T20:49:30Z", "description": "Octo-name client for Ruby", "html_url": "https://github.com/octocat/octo-name-repo/packages/40201?version=0.2.0", "metadata": { "package_type": "rubygems" } }

删除用户的软件包版本

删除用户的特定软件包版本。如果软件包是公开的,并且软件包版本下载量超过 5,000 次,则无法删除该软件包版本。在这种情况下,请联系 GitHub 支持寻求进一步帮助。

如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则已认证用户必须对该软件包拥有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packagesdelete:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

用于“删除用户的软件包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“删除用户的软件包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

username string 必填

GitHub 用户帐户的句柄。

package_version_id 整数 必填

包版本的唯一标识符。

“删除用户的软件包版本”的 HTTP 响应状态代码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

“删除用户的软件包版本”的代码示例

请求示例

delete/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID

响应

状态:204

恢复用户的软件包版本

恢复用户的特定软件包版本。

您可以在以下情况下恢复已删除的包

  • 该包是在过去 30 天内删除的。
  • 相同的包命名空间和版本仍然可用,并且没有被重复用于新的包。如果相同的包命名空间不可用,则您将无法恢复您的包。在这种情况下,要恢复已删除的包,您必须先删除使用已删除包的命名空间的新包。

如果package_type属于支持细粒度权限的 GitHub Packages 注册表,则已认证用户必须对该软件包拥有管理员权限。有关这些注册表的列表,请参阅“关于 GitHub Packages 的权限”。

OAuth 应用令牌和个人访问令牌(经典)需要read:packageswrite:packages作用域才能使用此端点。更多信息,请参见“关于 GitHub Packages 的权限”。

用于“恢复用户的软件包版本”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌不需要任何权限。

“恢复用户的软件包版本”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 `application/vnd.github+json`。

路径参数
名称,类型,描述
package_type 字符串 必需

支持的软件包类型。GitHub 的 Gradle 注册表中的软件包类型为 `maven`。推送到 GitHub 的容器注册表 ( `ghcr.io` ) 的 Docker 镜像类型为 `container`。您可以使用类型 `docker` 查找推送到 GitHub 的 Docker 注册表 ( `docker.pkg.github.com` ) 的镜像,即使这些镜像现在已迁移到容器注册表。

可以是以下之一:npmmavenrubygemsdockernugetcontainer

package_name 字符串 必填

包的名称。

username string 必填

GitHub 用户帐户的句柄。

package_version_id 整数 必填

包版本的唯一标识符。

为用户恢复包版本时的 HTTP 响应状态码

状态代码描述
204

无内容

401

需要身份验证

403

禁止

404

资源未找到

为用户恢复包版本的代码示例

请求示例

post/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restore

响应

状态:204