パッケージ
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 |
|---|
| 名前, 種類, 説明 |
acceptstringSetting to |
| 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 Can be one of: |
visibilitystringThe selected visibility of the packages. Only Can be one of: |
HTTP response status codes
| Status code | 説明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
コードサンプル
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/orgs/ORG/packagesResponse
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 |
|---|
| 名前, 種類, 説明 |
acceptstringSetting to |
| Path parameters |
| 名前, 種類, 説明 |
package_typestring必須The type of supported package. Packages in GitHub's Gradle registry have the type Can be one of: |
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 |
コードサンプル
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAMEResponse
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"
}