Packages
Use the REST API to interact with GitHub Packages.
About GitHub Packages
You can use the REST API to manage packages in your GitHub repositories and organizations. For more information, see "Restoring and deleting packages."
To use the REST API to manage GitHub Packages, you must authenticate using a personal access token (classic).
- To access package metadata, your token must include the
read:packagesscope. - To delete packages and package versions, your token must include the
read:packagesanddelete:packagesscopes. - To restore packages and package versions, your token must include the
read:packagesandwrite:packagesscopes.
If your package is in a registry that supports granular permissions, then your token does not need the repo scope to access or manage this package. If your package is in a registry that only supports repository-scoped permissions, then your token must also include the repo scope since your package inherits permissions from a GitHub repository. For a list of registries that only support repository-scoped permissions, see "About permissions for GitHub Packages."
To access resources in an organization with SSO enabled, you must enable SSO for your personal access token (classic). 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 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, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
orgstringRequiredThe organization name. The name is not case sensitive. |
| Query parameters |
| Name, Type, Description |
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 | Description |
|---|---|
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 packages:read 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, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
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 | Description |
|---|---|
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 packages:read and packages:delete 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, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
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 | Description |
|---|---|
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 packages:read and packages:write 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, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
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, Description |
tokenstringpackage token |
HTTP response status codes
| Status code | Description |
|---|---|
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, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
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, Description |
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 | Description |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |