Packages
GitHub Packages APIを使うと、GitHubの自分のリポジトリとOrganizationのパッケージの管理ができます。
The GitHub Packages API enables you to manage packages using the REST API. To learn more about restoring or deleting packages, see "Restoring and deleting packages."
この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を有効化しなければなりません。 For more information, see "Authorizing a personal access token for use with SAML single sign-on" in the GitHub Enterprise Cloud documentation.
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.
get /orgs/{org}/packagesパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | query | The type of supported package. Can be one of |
org | string | path | |
visibility | string | query | The selected visibility of the packages. Can be one of |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packagesawait octokit.request('GET /orgs/{org}/packages', {
org: 'ORG'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/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"
}
]Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
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.
get /orgs/{org}/packages/{package_type}/{package_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
org | string | path |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAMEawait octokit.request('GET /orgs/{org}/packages/{package_type}/{package_name}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
org: 'ORG'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/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"
}Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
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, contact GitHub support for further assistance.
To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the packages:read and packages:delete scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container you want to delete.
delete /orgs/{org}/packages/{package_type}/{package_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
org | string | path |
コードサンプル
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAMEawait octokit.request('DELETE /orgs/{org}/packages/{package_type}/{package_name}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
org: 'ORG'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAMEResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Restore a package for an organization
Restores an entire package in an organization.
You can restore a deleted package under the following conditions:
- The package was deleted within the last 30 days.
- The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the packages:read and packages:write scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container that you want to restore.
post /orgs/{org}/packages/{package_type}/{package_name}/restoreパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
org | string | path | |
token | string | query | package token |
コードサンプル
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/restoreawait octokit.request('POST /orgs/{org}/packages/{package_type}/{package_name}/restore{?token}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
org: 'ORG'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/restoreResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Get all package versions for a package owned by an organization
Returns all package versions for a package owned by 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.
get /orgs/{org}/packages/{package_type}/{package_name}/versionsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
org | string | path | |
page | integer | query | Page number of the results to fetch. デフォルト: |
per_page | integer | query | Results per page (max 100) デフォルト: |
state | string | query | The state of the package, either active or deleted. デフォルト: |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versionsawait octokit.request('GET /orgs/{org}/packages/{package_type}/{package_name}/versions', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
org: 'ORG'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versionsResponse
Status: 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"
}
}
]Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Get a package version for an organization
Gets a specific package version in an organization.
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.
get /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
org | string | path | |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDawait octokit.request('GET /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
org: 'ORG',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDResponse
Status: 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"
]
}
}
}Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
Delete package version for an organization
Deletes a specific package version in an organization. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the packages:read and packages:delete scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container you want to delete.
delete /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
org | string | path | |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDawait octokit.request('DELETE /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
org: 'ORG',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Restore package version for an organization
Restores a specific package version in an organization.
You can restore a deleted package under the following conditions:
- The package was deleted within the last 30 days.
- The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the packages:read and packages:write scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container that you want to restore.
post /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restoreパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
org | string | path | |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restoreawait octokit.request('POST /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
org: 'ORG',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restoreResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
List packages for the authenticated user's namespace
Lists packages owned by the authenticated user within the user's namespace.
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.
get /user/packagesパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | query | The type of supported package. Can be one of |
visibility | string | query | The selected visibility of the packages. Can be one of |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packagesawait octokit.request('GET /user/packages', {})gh api \
-H "Accept: application/vnd.github.v3+json" \
/user/packagesResponse
Status: 200[
{
"id": 197,
"name": "hello_docker",
"package_type": "container",
"owner": {
"login": "monalisa",
"id": 9919,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
"avatar_url": "https://avatars.monalisausercontent.com/u/9919?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"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/monalisa",
"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/monalisa/packages/container/goodbye_docker",
"created_at": "2020-05-20T22:19:11Z",
"updated_at": "2020-05-20T22:19:11Z",
"html_url": "https://github.com/user/monalisa/packages/container/package/goodbye_docker"
}
]Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
Get a package for the authenticated user
Gets a specific package for a package owned by the authenticated 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.
get /user/packages/{package_type}/{package_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAMEawait octokit.request('GET /user/packages/{package_type}/{package_name}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/user/packages/PACKAGE_TYPE/PACKAGE_NAMEResponse
Status: 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"
}Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
Delete a package for the authenticated user
Deletes a package owned by the authenticated user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
To use this endpoint, you must authenticate using an access token with the packages:read and packages:delete scopes.
If package_type is not container, your token must also include the repo scope.
delete /user/packages/{package_type}/{package_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
コードサンプル
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAMEawait octokit.request('DELETE /user/packages/{package_type}/{package_name}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/user/packages/PACKAGE_TYPE/PACKAGE_NAMEResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Restore a package for the authenticated user
Restores a package owned by the authenticated user.
You can restore a deleted package under the following conditions:
- The package was deleted within the last 30 days.
- The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
To use this endpoint, you must authenticate using an access token with the packages:read and packages:write scopes. If package_type is not container, your token must also include the repo scope.
post /user/packages/{package_type}/{package_name}/restoreパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
token | string | query | package token |
コードサンプル
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/restoreawait octokit.request('POST /user/packages/{package_type}/{package_name}/restore{?token}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/user/packages/PACKAGE_TYPE/PACKAGE_NAME/restoreResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Get all package versions for a package owned by the authenticated user
Returns all package versions for a package owned by the authenticated 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.
get /user/packages/{package_type}/{package_name}/versionsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
page | integer | query | Page number of the results to fetch. デフォルト: |
per_page | integer | query | Results per page (max 100) デフォルト: |
state | string | query | The state of the package, either active or deleted. デフォルト: |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versionsawait octokit.request('GET /user/packages/{package_type}/{package_name}/versions', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versionsResponse
Status: 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": []
}
}
}
]Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Get a package version for the authenticated user
Gets a specific package version for a package owned by the authenticated 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.
get /user/packages/{package_type}/{package_name}/versions/{package_version_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDawait octokit.request('GET /user/packages/{package_type}/{package_name}/versions/{package_version_id}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDResponse
Status: 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"
]
}
}
}Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
Delete a package version for the authenticated user
Deletes a specific package version for a package owned by the authenticated user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the packages:read and packages:delete scopes.
If package_type is not container, your token must also include the repo scope.
delete /user/packages/{package_type}/{package_name}/versions/{package_version_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDawait octokit.request('DELETE /user/packages/{package_type}/{package_name}/versions/{package_version_id}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Restore a package version for the authenticated user
Restores a package version owned by the authenticated user.
You can restore a deleted package version under the following conditions:
- The package was deleted within the last 30 days.
- The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
To use this endpoint, you must authenticate using an access token with the packages:read and packages:write scopes. If package_type is not container, your token must also include the repo scope.
post /user/packages/{package_type}/{package_name}/versions/{package_version_id}/restoreパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restoreawait octokit.request('POST /user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/user/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restoreResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
List packages for a user
Lists all packages in a user's namespace for which the requesting user has access.
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.
get /users/{username}/packagesパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | query | The type of supported package. Can be one of |
visibility | string | query | The selected visibility of the packages. Can be one of |
username | string | path |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packagesawait octokit.request('GET /users/{username}/packages', {
username: 'USERNAME'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packagesResponse
Status: 200[
{
"id": 197,
"name": "hello_docker",
"package_type": "container",
"owner": {
"login": "monalisa",
"id": 9919,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
"avatar_url": "https://avatars.monalisausercontent.com/u/9919?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/monalisa",
"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/monalisa",
"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/monalisa/packages/container/goodbye_docker",
"created_at": "2020-05-20T22:19:11Z",
"updated_at": "2020-05-20T22:19:11Z",
"html_url": "https://github.com/user/monalisa/packages/container/package/goodbye_docker"
}
]Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
Get a package for a user
Gets a specific package metadata for a public package owned by a 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.
get /users/{username}/packages/{package_type}/{package_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
username | string | path |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAMEawait octokit.request('GET /users/{username}/packages/{package_type}/{package_name}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
username: 'USERNAME'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAMEResponse
Status: 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"
}Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
Delete a package for a user
Deletes an entire package for a user. You cannot delete a public package if any version of the package has more than 5,000 downloads. In this scenario, contact GitHub support for further assistance.
To use this endpoint, you must authenticate using an access token with the packages:read and packages:delete scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container you want to delete.
delete /users/{username}/packages/{package_type}/{package_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
username | string | path |
コードサンプル
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAMEawait octokit.request('DELETE /users/{username}/packages/{package_type}/{package_name}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
username: 'USERNAME'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAMEResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Restore a package for a user
Restores an entire package for a user.
You can restore a deleted package under the following conditions:
- The package was deleted within the last 30 days.
- The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
To use this endpoint, you must authenticate using an access token with the packages:read and packages:write scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container that you want to restore.
post /users/{username}/packages/{package_type}/{package_name}/restoreパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
username | string | path | |
token | string | query | package token |
コードサンプル
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/restoreawait octokit.request('POST /users/{username}/packages/{package_type}/{package_name}/restore{?token}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
username: 'USERNAME'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/restoreResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Get all package versions for a package owned by a user
Returns all package versions for a public package owned by a specified 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.
get /users/{username}/packages/{package_type}/{package_name}/versionsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
username | string | path |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versionsawait octokit.request('GET /users/{username}/packages/{package_type}/{package_name}/versions', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
username: 'USERNAME'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versionsResponse
Status: 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"
}
}
]Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Get a package version for a user
Gets a specific package version for a public package owned by a specified user.
At this time, 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.
get /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
package_version_id | integer | path | Unique identifier of the package version. |
username | string | path |
コードサンプル
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDawait octokit.request('GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
package_version_id: 'PACKAGE_VERSION_ID',
username: 'USERNAME'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDResponse
Status: 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"
}
}Status codes
| HTTP Status Code | 説明 |
|---|---|
200 | OK |
Delete package version for a user
Deletes a specific package version for a user. If the package is public and the package version has more than 5,000 downloads, you cannot delete the package version. In this scenario, contact GitHub support for further assistance.
To use this endpoint, you must authenticate using an access token with the packages:read and packages:delete scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container you want to delete.
delete /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
username | string | path | |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDawait octokit.request('DELETE /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
username: 'USERNAME',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_IDResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Restore package version for a user
Restores a specific package version for a user.
You can restore a deleted package under the following conditions:
- The package was deleted within the last 30 days.
- The same package namespace and version is still available and not reused for a new package. If the same package namespace is not available, you will not be able to restore your package. In this scenario, to restore the deleted package, you must delete the new package that uses the deleted package's namespace first.
To use this endpoint, you must authenticate using an access token with the packages:read and packages:write scopes. In addition:
- If
package_typeis notcontainer, your token must also include thereposcope. - If
package_typeiscontainer, you must also have admin permissions to the container that you want to restore.
post /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restoreパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
package_type | string | path | The type of supported package. Can be one of |
package_name | string | path | The name of the package. |
username | string | path | |
package_version_id | integer | path | Unique identifier of the package version. |
コードサンプル
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restoreawait octokit.request('POST /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore', {
package_type: 'PACKAGE_TYPE',
package_name: 'PACKAGE_NAME',
username: 'USERNAME',
package_version_id: 'PACKAGE_VERSION_ID'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions/PACKAGE_VERSION_ID/restoreResponse
Status: 204Status codes
| HTTP Status Code | 説明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |