--- stage: Package group: Package info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments --- # PyPI API This is the API documentation for [PyPI Packages](../../user/packages/pypi_repository/index.md). WARNING: This API is used by the [PyPI package manager client](https://pypi.apache.org/) and is generally not meant for manual consumption. For instructions on how to upload and install PyPI packages from the GitLab package registry, see the [PyPI package registry documentation](../../user/packages/pypi_repository/index.md). NOTE: These endpoints do not adhere to the standard API authentication methods. See the [PyPI package registry documentation](../../user/packages/pypi_repository/index.md) for details on which headers and token types are supported. ## Download a package file > Introduced in GitLab 12.10. Download a PyPI package file. The [simple API](#simple-api-entry-point) normally supplies this URL. ```plaintext GET projects/:id/packages/pypi/files/:sha256/:file_identifier ``` | Attribute | Type | Required | Description | | --------- | ---- | -------- | ----------- | | `id` | string | yes | The ID or full path of the project. | | `sha256` | string | yes | PyPI package file sha256 check sum. | | `file_identifier` | string | yes | The PyPI package file name. | ```shell curl --user : "https://gitlab.example.com/api/v4/projects/1/packages/pypi/files/5y57017232013c8ac80647f4ca153k3726f6cba62d055cd747844ed95b3c65ff/my.pypi.package-0.0.1.tar.gz" ``` To write the output to a file: ```shell curl --user : "https://gitlab.example.com/api/v4/projects/1/packages/pypi/files/5y57017232013c8ac80647f4ca153k3726f6cba62d055cd747844ed95b3c65ff/my.pypi.package-0.0.1.tar.gz" >> my.pypi.package-0.0.1.tar.gz ``` This writes the downloaded file to `my.pypi.package-0.0.1.tar.gz` in the current directory. ## Simple API entry point > Introduced in GitLab 12.10. Returns the package descriptor as an HTML file: ```plaintext GET projects/:id/packages/pypi/simple/:package_name ``` | Attribute | Type | Required | Description | | --------- | ---- | -------- | ----------- | | `id` | string | yes | The ID or full path of the project. | | `package_name` | string | yes | The name of the package. | ```shell curl --user : "https://gitlab.example.com/api/v4/projects/1/packages/pypi/simple/my.pypi.package" ``` Example response: ```html Links for my.pypi.package

Links for my.pypi.package

my.pypi.package-0.0.1-py3-none-any.whl
my.pypi.package-0.0.1.tar.gz
``` To write the output to a file: ```shell curl --user : "https://gitlab.example.com/api/v4/projects/1/packages/pypi/simple/my.pypi.package" >> simple.html ``` This writes the downloaded file to `simple.html` in the current directory. ## Upload a package > Introduced in GitLab 11.3. Upload a PyPI package: ```plaintext PUT projects/:id/packages/pypi ``` | Attribute | Type | Required | Description | | --------- | ---- | -------- | ----------- | | `id` | string | yes | The ID or full path of the project. | ```shell curl --request PUT \ --upload-file path/to/my.pypi.package-0.0.1.tar.gz \ --user : \ "https://gitlab.example.com/api/v4/projects/1/packages/pypi" ```