Skip to main content

Paquetes

Con la API del GitHub Packages, puedes administrar paquetes para tus repositorios y organizaciones de GitHub.

Acerca de la API de GitHub Packages

La API de GitHub Packages te permite administrar paquetes utilizando la API de REST. Para obtener más información sobre cómo restaurar o eliminar paquetes, consulta "Restauración y eliminación de paquetes".

Para utilizar esta API, primero tienes que autenticarte utilizando un token de acceso personal.

  • Para acceder a los metadatos del paquete, el token debe incluir el ámbito read:packages.
  • Para eliminar paquetes y versiones de paquete, el token debe incluir los ámbitos read:packages y delete:packages.
  • Para restaurar paquetes y versiones de paquete, el token debe incluir los ámbitos read:packages y write:packages.

Si package_type es npm, maven, rubygems o nuget, el token también debe incluir el ámbito repo, ya que el paquete hereda permisos de un repositorio de GitHub. Si el paquete está en Container registry, el valor package_type es container y el token no necesita el ámbito repo para acceder a package_type ni administrarlo. Los paquetes container ofrecen permisos pormenorizados independientes de un repositorio. Para más información, vea "Acerca de los permisos para GitHub Packages".

Si quieres utilizar la API del GitHub Packages para acceder a los recursos de una organización con el SSO habilitado, entonces debes habilitar el SSO para tu token de acceso personal. Para más información, vea "Autorización de un token de acceso personal para usarlo con el inicio de sesión único de SAML" en la documentación de GitHub Enterprise Cloud.

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.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
orgstringRequired

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
package_typestringRequired

The 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.

Can be one of: npm, maven, rubygems, docker, nuget, container

visibilitystring

The selected visibility of the packages. Only container package_types currently support internal visibility properly. For other ecosystems internal is synonymous with private. This parameter is optional and only filters an existing result set.

Can be one of: public, private, internal

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

401

Requires authentication

403

Forbidden

Ejemplos de código

get/orgs/{org}/packages
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://api.github.com/orgs/ORG/packages

Response

Status: 200
[ { "id": 197, "name": "hello_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "version_count": 1, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/hello_docker", "created_at": "2020-05-19T22:19:11Z", "updated_at": "2020-05-19T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/hello_docker" }, { "id": 198, "name": "goodbye_docker", "package_type": "container", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "site_admin": false }, "version_count": 2, "visibility": "private", "url": "https://api.github.com/orgs/github/packages/container/goodbye_docker", "created_at": "2020-05-20T22:19:11Z", "updated_at": "2020-05-20T22:19:11Z", "html_url": "https://github.com/orgs/github/packages/container/package/goodbye_docker" } ]

Get a package for an organization

Gets a specific package in an organization.

To use this endpoint, you must authenticate using an access token with the packages:read scope. If package_type is not container, your token must also include the repo scope.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
package_typestringRequired

The 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.

Can be one of: npm, maven, rubygems, docker, nuget, container

package_namestringRequired

The name of the package.

orgstringRequired

The organization name. The name is not case sensitive.

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

Ejemplos de código

get/orgs/{org}/packages/{package_type}/{package_name}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME

Response

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 package_type is not container, your token must also include the repo scope.
  • If package_type is container, you must also have admin permissions to the container you want to delete.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
package_typestringRequired

The 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.

Can be one of: npm, maven, rubygems, docker, nuget, container

package_namestringRequired

The name of the package.

orgstringRequired

The organization name. The name is not case sensitive.

Códigos de estado de respuesta HTTP

status codeDescripción
204

No Content

401

Requires authentication

403

Forbidden

404

Resource not found

Ejemplos de código

delete/orgs/{org}/packages/{package_type}/{package_name}
curl \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME

Response

Status: 204

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_type is not container, your token must also include the repo scope.
  • If package_type is container, you must also have admin permissions to the container that you want to restore.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
package_typestringRequired

The 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.

Can be one of: npm, maven, rubygems, docker, nuget, container

package_namestringRequired

The name of the package.

orgstringRequired

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
tokenstring

package token

Códigos de estado de respuesta HTTP

status codeDescripción
204

No Content

401

Requires authentication

403

Forbidden

404

Resource not found

Ejemplos de código

post/orgs/{org}/packages/{package_type}/{package_name}/restore
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/restore

Response

Status: 204

List package versions for a package owned by an organization

Lists 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.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
package_typestringRequired

The 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.

Can be one of: npm, maven, rubygems, docker, nuget, container

package_namestringRequired

The name of the package.

orgstringRequired

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
pageinteger

Page number of the results to fetch.

Default: 1

per_pageinteger

The number of results per page (max 100).

Default: 30

statestring

The state of the package, either active or deleted.

Default: active

Can be one of: active, deleted

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

401

Requires authentication

403

Forbidden

404

Resource not found

Ejemplos de código

get/orgs/{org}/packages/{package_type}/{package_name}/versions
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions

Response

Status: 200
[ { "id": 245301, "name": "1.0.4", "url": "https://api.github.com/orgs/octo-org/packages/npm/hello-world