Skip to main content

package_versions

Creates, updates, deletes, gets or lists a package_versions resource.

Overview

Namepackage_versions
TypeResource
Idgithub.packages.package_versions

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idintegerUnique identifier of the package version.
namestringThe name of the package version. (example: latest)
created_atstring (date-time) (example: 2011-04-10T20:09:31Z)
deleted_atstring (date-time) (example: 2014-03-03T18:58:10Z)
descriptionstring
html_urlstring (example: https://github.com/orgs/github/packages/container/super-linter/786068)
licensestring (example: MIT)
metadataobject (title: Package Version Metadata)
package_html_urlstring (example: https://github.com/orgs/github/packages/container/package/super-linter)
updated_atstring (date-time) (example: 2014-03-03T18:58:10Z)
urlstring (example: https://api.github.com/orgs/github/packages/container/super-linter/versions/786068)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_package_version_for_organizationselectpackage_type, package_name, org, package_version_idGets a specific package version in an organization.

OAuth app tokens and personal access tokens (classic) need the read:packages scope to use this endpoint. For more information, see "About permissions for GitHub Packages."
get_package_version_for_userselectpackage_type, package_name, package_version_id, usernameGets a specific package version for a public package owned by a specified user.

OAuth app tokens and personal access tokens (classic) need the read:packages scope to use this endpoint. For more information, see "About permissions for GitHub Packages."
get_all_package_versions_for_package_owned_by_orgselectpackage_type, package_name, orgpage, per_page, stateLists package versions for a package owned by an organization.

OAuth app tokens and personal access tokens (classic) need the read:packages scope to use this endpoint. For more information, see "About permissions for GitHub Packages."
get_package_version_for_authenticated_userselectpackage_type, package_name, package_version_idGets a specific package version for a package owned by the authenticated user.

OAuth app tokens and personal access tokens (classic) need the read:packages scope to use this endpoint. For more information, see "About permissions for GitHub Packages."
get_all_package_versions_for_package_owned_by_userselectpackage_type, package_name, usernameLists package versions for a public package owned by a specified user.

OAuth app tokens and personal access tokens (classic) need the read:packages scope to use this endpoint. For more information, see "About permissions for GitHub Packages."
get_all_package_versions_for_package_owned_by_authenticated_userselectpackage_type, package_namepage, per_page, stateLists package versions for a package owned by the authenticated user.

OAuth app tokens and personal access tokens (classic) need the read:packages scope to use this endpoint. For more information, see "About permissions for GitHub Packages."
delete_package_version_for_orgdeletepackage_type, package_name, org, package_version_idDeletes 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.

The authenticated user must have admin permissions in the organization to use this endpoint. If the package_type belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "About permissions for GitHub Packages."

OAuth app tokens and personal access tokens (classic) need the read:packages and delete:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."
delete_package_version_for_userdeletepackage_type, package_name, username, package_version_idDeletes 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.

If the package_type belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "About permissions for GitHub Packages."

OAuth app tokens and personal access tokens (classic) need the read:packages and delete:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."
delete_package_version_for_authenticated_userdeletepackage_type, package_name, package_version_idDeletes 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.

The authenticated user must have admin permissions in the organization to use this endpoint.

OAuth app tokens and personal access tokens (classic) need the read:packages and delete:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."
restore_package_version_for_orgexecpackage_type, package_name, org, package_version_idRestores 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.

The authenticated user must have admin permissions in the organization to use this endpoint. If the package_type belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "About permissions for GitHub Packages."

OAuth app tokens and personal access tokens (classic) need the read:packages and write:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."
restore_package_version_for_authenticated_userexecpackage_type, package_name, package_version_idRestores 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.

OAuth app tokens and personal access tokens (classic) need the read:packages and write:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."
restore_package_version_for_userexecpackage_type, package_name, username, package_version_idRestores 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.

If the package_type belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must have admin permissions to the package. For the list of these registries, see "About permissions for GitHub Packages."

OAuth app tokens and personal access tokens (classic) need the read:packages and write:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
orgstringThe organization name. The name is not case sensitive.
package_namestringThe name of the package.
package_typestringThe 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.
package_version_idintegerUnique identifier of the package version.
usernamestringThe handle for the GitHub user account.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
statestringThe state of the package, either active or deleted.

SELECT examples

Gets a specific package version in an organization.

OAuth app tokens and personal access tokens (classic) need the read:packages scope to use this endpoint. For more information, see "About permissions for GitHub Packages."

SELECT
id,
name,
created_at,
deleted_at,
description,
html_url,
license,
metadata,
package_html_url,
updated_at,
url
FROM github.packages.package_versions
WHERE package_type = '{{ package_type }}' -- required
AND package_name = '{{ package_name }}' -- required
AND org = '{{ org }}' -- required
AND package_version_id = '{{ package_version_id }}' -- required
;

DELETE examples

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.

The authenticated user must have admin permissions in the organization to use this endpoint. If the package_type belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "About permissions for GitHub Packages."

OAuth app tokens and personal access tokens (classic) need the read:packages and delete:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."

DELETE FROM github.packages.package_versions
WHERE package_type = '{{ package_type }}' --required
AND package_name = '{{ package_name }}' --required
AND org = '{{ org }}' --required
AND package_version_id = '{{ package_version_id }}' --required
;

Lifecycle Methods

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.

The authenticated user must have admin permissions in the organization to use this endpoint. If the package_type belongs to a GitHub Packages registry that supports granular permissions, the authenticated user must also have admin permissions to the package. For the list of these registries, see "About permissions for GitHub Packages."

OAuth app tokens and personal access tokens (classic) need the read:packages and write:packages scopes to use this endpoint. For more information, see "About permissions for GitHub Packages."

EXEC github.packages.package_versions.restore_package_version_for_org 
@package_type='{{ package_type }}' --required,
@package_name='{{ package_name }}' --required,
@org='{{ org }}' --required,
@package_version_id='{{ package_version_id }}' --required
;