PyPI SDK
An unofficial, typed Python SDK for PyPI's documented public APIs. It provides one synchronous client for package metadata, the PEP 691 index, provenance, statistics, RSS feeds, and a Twine-backed distribution publisher.
The SDK requires Python 3.11 or later. It is not affiliated with or endorsed by the Python Software Foundation or the PyPI maintainers.
What this SDK covers
| PyPI feature | SDK interface |
|---|---|
| Project and release JSON | client.projects.get() / get_release() |
| PEP 691 JSON Simple Index | client.index.list_projects() / get_project() |
| PEP 740 file provenance | client.integrity.get_provenance() |
| Package storage statistics | client.stats.get() |
| New package and release RSS feeds | client.feeds |
| Legacy upload endpoint | client.publisher.upload() via Twine |
It intentionally does not wrap the deprecated XML-RPC API, the partner-only secret reporting API, or Google BigQuery datasets as if they were normal PyPI HTTP endpoints. PyPI also does not provide a public general-purpose REST API to manage accounts, collaborators, or edit an existing release. Add a new version to publish an update; an existing release cannot be overwritten.
Installation
Python 3.11 or later is required. From this checkout:
uv sync --group dev --group docs
After publishing, install the SDK from PyPI:
python -m pip install pypi-sdk
For uploads, install the optional Twine dependency:
python -m pip install "pypi-sdk[publish]"
Quick start
from pypi_sdk import PypiClient
with PypiClient() as client:
project = client.projects.get("sampleproject")
release = client.projects.get_release("sampleproject", project.info.version)
files = client.index.get_project("sampleproject").files
print(project.info.summary, len(files), len(release.urls))
Responses are Pydantic models that preserve additional fields returned by PyPI. The client uses anonymous GET requests by default, follows no redirects, and does not retry automatically.
Publish built distributions
Build and validate artifacts with the standard Python packaging tools, then explicitly choose TestPyPI or PyPI. TestPyPI is a separate service, useful for testing the release process before publishing to production.
from pathlib import Path
from pypi_sdk import PypiClient
artifacts = Path("dist").glob("*")
with PypiClient() as client:
result = client.publisher.upload(artifacts, repository="testpypi")
print(result.files)
Twine reads TWINE_USERNAME and TWINE_PASSWORD from the environment, or can
receive a token explicitly without placing it in process arguments:
import os
from pathlib import Path
from pypi_sdk import PypiClient
token = os.environ["PYPI_API_TOKEN"]
with PypiClient() as client:
client.publisher.upload(
Path("dist").glob("*"),
repository="pypi",
token=token,
)
The equivalent CLI command is:
pypi-sdk upload --repository testpypi dist\your_package-1.0.0-py3-none-any.whl
The publisher delegates metadata handling and the upload protocol to Twine.
It does not build distributions; use python -m build or your project's
existing build backend first.
Automated publishing with Trusted Publishing
For CI, prefer PyPI Trusted Publishing over long-lived API tokens. Configure
the GitHub repository and workflow as a trusted publisher in the PyPI project
settings using the GitHub repository owner, repository name, publish.yml, and
the pypi environment. Configure the matching GitHub Environment (add
protection rules if desired), then copy
examples/publish.yml to
.github/workflows/publish.yml in the package being released. The workflow
builds and validates distributions, then publishes them through PyPI's official
GitHub Action using OIDC.
See the Trusted Publishing guide.
API policies and boundaries
- The SDK identifies itself with a
User-Agentand honors PyPI's JSON representations. The Simple Index HTML representation is not wrapped; the docs recommend its JSON form for new integrations. - If polling for updates, prefer RSS feeds and avoid bursts of thousands of requests. The current client does not yet expose conditional ETag requests.
- Use the Simple Index for distribution files and verify their advertised hashes after downloading.
- File upload creates releases one file at a time. The first file for a version creates that release and fixes its metadata. To correct a release, publish a new version.
- Project administration and Trusted Publisher setup happen in PyPI's web interface; this SDK does not claim unsupported account-management endpoints.
See the PyPI API documentation and the Python Packaging User Guide.
Development
uv sync --group dev --group docs
uv run ruff check .
uv run ruff format --check .
uv run mypy src
uv run basedpyright
uv run pytest
uv run --group docs mkdocs build --strict
uv build
Tests use mocked HTTP and do not upload packages or contact PyPI. Optional CPU benchmarks are available with pytest-benchmark:
uv run --group benchmark pytest benchmarks --no-cov --benchmark-only
BenchCore measurements require Python 3.12 or later:
uv run --group benchcore pytest benchmarks/benchcore_cases.py --no-cov --benchcore-save=.benchcore
See Getting started, API reference, publishing guide, development guide, contributing, and the changelog.
Metadata
Release files for pypi-sdk 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypi_sdk-1.0.0.tar.gz | 27.6 kB | With provenance | Details for pypi_sdk-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypi_sdk-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pypi_sdk-1.0.0-py3-none-any.whl |
Total release size: 41.4 kB
Release files / pypi_sdk-1.0.0.tar.gz
| Download URL | pypi_sdk-1.0.0.tar.gz |
|---|---|
| Size | 27.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb32169041182a5c90ba9c0f9a6041979e301dcf38b10b84fd0ae6c0e27b546f
|
|
BLAKE2b-256 checksum How to use checksums |
a72831aba1130aa836f534c56be242d359bd4d837feccd3f51e9096b2b7c2cc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logRelease files / pypi_sdk-1.0.0-py3-none-any.whl
| Download URL | pypi_sdk-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c294da3034d84704d513aa5c905ea25d6e4a979ece1bb43b2d6932dcc091fd8
|
|
BLAKE2b-256 checksum How to use checksums |
58c285c53f0170b008b53e902555d11e516f90b8cd946162d4c195a8daaed887
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logSecurity for pypi-sdk 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pypi_sdk-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.