Pakete
Verwende die REST-API, um mit GitHub Packages zu interagieren.
Informationen zu GitHub Packages
Du kannst die REST-API verwenden, um Pakete in deinen GitHub-Repositorys und -Organisationen zu verwalten. Weitere Informationen findest du unter Wiederherstellen und Löschen von Paketen.
Um zur Verwaltung von GitHub Packages die REST-API verwenden zu können, musst du dich mithilfe eines personal access token (classic) authentifizieren.
- Um auf Paketmetadaten zuzugreifen, muss dein Token den
read:packages-Bereich enthalten. - Zum Löschen von Paketen und Paketversionen muss dein Token die Bereiche
read:packagesunddelete:packagesenthalten. - Zum Wiederherstellen von Paketen und Paketversionen muss dein Token die Bereiche
read:packagesundwrite:packagesenthalten.
Wenn sich dein Paket in einer Registrierung befindet, die differenzierte Berechtigungen unterstützt, benötigt dein Token nicht den Bereich repo, um auf dieses Paket zuzugreifen oder es zu verwalten. Wenn sich dein Paket in einer Registrierung befindet, die nur repositorybezogene Berechtigungen unterstützt, dann muss dein Token ebenfalls den repo-Bereich enthalten, da dein Paket Berechtigungen von einem GitHub-Repository erbt. Eine Liste mit Registrierungen, die nur repositorybezogene Berechtigungen unterstützen, findest du unter Informationen zu Berechtigungen für GitHub Packages.
Um auf Ressourcen in einer Organisation mit aktiviertem einmaligem Anmelden zuzugreifen, musst du einmaliges Anmelden für dein personal access token (classic) aktivieren. Weitere Informationen findest du unter Autorisieren eines personal access token für die Verwendung mit SAML Single Sign-On in der GitHub Enterprise Cloud-Dokumentation.
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 read:packages 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."
Parameters
| Headers |
|---|
| Name, Type, BESCHREIBUNG |
acceptstringSetting to |
| Path parameters |
| Name, Type, BESCHREIBUNG |
orgstringRequiredThe organization name. The name is not case sensitive. |
| Query parameters |
| Name, Type, BESCHREIBUNG |
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 response status codes
| Status code | BESCHREIBUNG |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
Code samples
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/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 read:packages scope. If the package_type belongs to a GitHub Packages 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."
Parameters
| Headers |
|---|
| Name, Type, BESCHREIBUNG |
acceptstringSetting to |
| Path parameters |
| Name, Type, BESCHREIBUNG |
package_typestringRequiredThe type of supported package. Packages in GitHub's Gradle registry have the type Can be one of: |
package_namestringRequiredThe name of the package. |
orgstringRequiredThe organization name. The name is not case sensitive. |
HTTP response status codes
| Status code | BESCHREIBUNG |
|---|---|
200 | OK |
Code samples
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/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"
}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 read:packages and delete:packages scopes. In addition:
- If the
package_typebelongs to a GitHub Packages registry that only supports repository-scoped permissions, your token must also include thereposcope. For the list of these registries, see "About permissions for GitHub Packages." - If the
package_typebelongs to a GitHub Packages registry that supports granular permissions, you must have admin permissions to the package you want to delete. For the list of these registries, see "About permissions for GitHub Packages."
Parameters
| Headers |
|---|
| Name, Type, BESCHREIBUNG |
acceptstringSetting to |
| Path parameters |
| Name, Type, BESCHREIBUNG |
package_typestringRequiredThe type of supported package. Packages in GitHub's Gradle registry have the type Can be one of: |
package_namestringRequiredThe name of the package. |
orgstringRequiredThe organization name. The name is not case sensitive. |
HTTP response status codes
| Status code | BESCHREIBUNG |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Code samples
curl \
-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_NAMEResponse
Status: 204Restore 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 read:packages and write:packages scopes. In addition:
- If the
package_typebelongs to a GitHub Packages registry that only supports repository-scoped permissions, your token must also include thereposcope. For the list of these registries, see "About permissions for GitHub Packages." - If the
package_typebelongs to a GitHub Packages registry that supports granular permissions, you must have admin permissions to the package you want to restore. For the list of these registries, see "About permissions for GitHub Packages."
Parameters
| Headers |
|---|
| Name, Type, BESCHREIBUNG |
acceptstringSetting to |
| Path parameters |
| Name, Type, BESCHREIBUNG |
package_typestringRequiredThe type of supported package. Packages in GitHub's Gradle registry have the type Can be one of: |
package_namestringRequiredThe name of the package. |
orgstringRequiredThe organization name. The name is not case sensitive. |
| Query parameters |
| Name, Type, BESCHREIBUNG |
tokenstringpackage token |
HTTP response status codes
| Status code | BESCHREIBUNG |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Code samples
curl \
-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/restoreResponse
Status: 204List package versions for a package owned by an organization
Lists package versions for a package owned by an organization.
If the package_type belongs to a GitHub Packages 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."
Parameters
| Headers |
|---|
| Name, Type, BESCHREIBUNG |
acceptstringSetting to |
| Path parameters |
| Name, Type, BESCHREIBUNG |
package_typestringRequiredThe type of supported package. Packages in GitHub's Gradle registry have the type Can be one of: |
package_namestringRequiredThe name of the package. |
orgstringRequiredThe organization name. The name is not case sensitive. |
| Query parameters |
| Name, Type, BESCHREIBUNG |
pageintegerPage number of the results to fetch. Default: |
per_pageintegerThe number of results per page (max 100). Default: |
statestringThe state of the package, either active or deleted. Default: Can be one of: |
HTTP response status codes
| Status code | BESCHREIBUNG |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Code samples
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/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"
}
}
]Get a package version for an organization
Gets a specific package version in an organization.
You must authenticate using an access token with the read:packages scope. If the package_type belongs to a GitHub Packages 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."
Parameters
| Headers |
|---|
| Name, Type, BESCHREIBUNG |
acceptstringSetting to |
| Path parameters |
| Name, Type, BESCHREIBUNG |
package_typestringRequiredThe type of supported package. Packages in GitHub's Gradle registry have the type Can be one of: |
package_namestringRequiredThe name of the package. |
orgstringRequiredThe organization name. The name is not case sensitive. |
package_version_idintegerRequiredUnique identifier of the package version. |
HTTP response status codes
| Status code | BESCHREIBUNG |
|---|---|
200 | OK |
Code samples
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/PACKAGE_NAME/versions/PACKAGE_VERSION_I