包
使用 REST API 与 GitHub Packages 交互。
关于 GitHub Packages
可以使用 REST API 管理 GitHub 存储库和组织中的包。 有关详细信息,请参阅“还原和删除包”。
若要使用 REST API 管理 GitHub Packages,必须使用 personal access token (classic) 进行身份验证。
- 要访问包元数据,令牌必须包含
read:packages范围。 - 要删除包和包版本,令牌必须包含
read:packages和delete:packages范围。 - 要还原包和包版本,令牌必须包含
read:packages和write:packages范围。
如果包位于支持精细权限的注册表中,则令牌不需要 repo 范围即可访问或管理此包。 如果包位于仅支持存储库范围权限的注册表中,则令牌还必须包括 repo 范围,因为包继承了 GitHub 存储库的权限。 有关仅支持存储库范围权限的注册表列表,请参阅“关于 GitHub Packages 的权限”。
若要访问启用了 SSO 的组织中的资源,必须为 personal access token (classic) 启用 SSO。 有关详细信息,请参阅 GitHub Enterprise Cloud 文档中的“授权 personal access token 以用于 SAML 单一登录”。
List packages for an organization
Lists all packages in an organization readable by the user.
To use this endpoint, you must authenticate using an access token with the packages:read scope. If the package_type belongs to a registry that only supports repository-scoped permissions, your token must also include the repo scope. For the list of GitHub Packages registries that only support repository-scoped permissions, see "About permissions for GitHub Packages."
参数
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
orgstringRequiredThe organization name. The name is not case sensitive. |
| Query parameters |
| Name, Type, Description |
package_typestringRequiredThe type of supported package. Packages in GitHub's Gradle registry have the type Can be one of: |
visibilitystringThe selected visibility of the packages. This parameter is optional and only filters an existing result set. The Can be one of: |
HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
代码示例
curl \
-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=containerResponse
Status: 200[
{
"id": 197,
"name": "hello_docker",
"package_type": "container",
"owner": {
"login": "github",
"id": 9919,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
"avatar_url": "https://avatars.githubusercontent.com/u/