Skip to main content

パッケージ

GitHub Packages APIを使うと、GitHubの自分のリポジトリとOrganizationのパッケージの管理ができます。

GitHub Packages APIについて

GitHub Packages APIでは、REST APIを使ってパッケージを管理できます。 パッケージのリストアや削除についてさらに学ぶには、「パッケージのリストアと削除」を参照してください。

このAPIを使うには、個人アクセストークンを使って認証を受けなければなりません。

  • パッケージメタデータにアクセスするには、トークンにread:packagesスコープが含まれていなければなりません。
  • パッケージやパッケージのバージョンを削除するには、トークンにread:packages及びdelete:packagesスコープが含まれていなければなりません。
  • パッケージやパッケージのバージョンをリストアするには、トークンにread:packages及びwrite:packagesスコープが含まれていなければなりません。

package_typeがnpm、maven、rubygems、nugetのいずれかなら、パッケージはGitHubリポジトリからの権限を継承するので、トークンにはrepoスコープも含まれていなければなりません。 パッケージがコンテナレジストリ内にあるなら、package_typeはcontainerであり、このpackage_typeのアクセスあるいは管理のためにトークンにrepoスコープが含まれている必要はありません。 containerパッケージは、リポジトリは別に詳細な権限を提供します。 詳しい情報については「GitHub Packagesの権限について」を参照してください。

SSOが有効化されたOrganization内のリソースにアクセスするためにGitHub Packages APIを使いたい場合は、個人アクセストークンにSSOを有効化しなければなりません。 詳しい情報についてはGitHub Enterprise Cloudドキュメンテーションの「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 package_type is not container, your token must also include the repo scope.

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
名前, 種類, 説明
orgstring必須

The organization name. The name is not case sensitive.

クエリパラメータ
名前, 種類, 説明
package_typestring必須

The type of supported package. Packages in GitHub's Gradle registry have the type maven. Docker images pushed to GitHub's Container registry (ghcr.io) have the type container. You can use the type docker to find images that were pushed to GitHub's Docker registry (docker.pkg.github.com), even if these have now been migrated to the Container registry.

Can be one of: npm, maven, rubygems, docker, nuget, container

visibilitystring

The selected visibility of the packages. Only container package_types currently support internal visibility properly. For other ecosystems internal is synonymous with private. This parameter is optional and only filters an existing result set.

Can be one of: public, private, internal

HTTP response status codes

Status code説明
200

OK

401

Requires authentication

403

Forbidden

コードサンプル

get/orgs/{org}/packages
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://api.github.com/orgs/ORG/packages

Response

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/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" } ]

Get a package for an organization

Gets a specific package in an organization.

To use this endpoint, you must authenticate using an access token with the packages:read scope. If package_type is not container, your token must also include the repo scope.

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
名前, 種類, 説明
package_typestring必須

The type of supported package. Packages in GitHub's Gradle registry have the type maven. Docker images pushed to GitHub's Container registry (ghcr.io) have the type container. You can use the type docker to find images that were pushed to GitHub's Docker registry (docker.pkg.github.com), even if these have now been migrated to the Container registry.

Can be one of: npm, maven, rubygems, docker, nuget, container

package_namestring必須

The name of the package.

orgstring必須

The organization name. The name is not case sensitive.

HTTP response status codes

Status code説明
200

OK

コードサンプル

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

Response

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/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" }

Delete a package for an organization

Deletes an entire package in an organization. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario