PyPI (Python Package Index) API
The official Python package repository serving pip and other Python package managers. Provides a JSON API for package metadata lookup, version enumeration, release file download URLs, and project statistics. Also implements the PEP 503 Simple Repository API used by pip, uv, and Poetry to discover and install packages. The separate PyPI Stats API (pypistats.org) provides download analytics.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Trusted Publisher (OIDC) eliminates long-lived API tokens from CI/CD systems, significantly improving supply chain security. Project-scoped API tokens limit blast radius if a token is leaked. PyPI supports PEP 740 attestations for provenance verification. The public index has experienced typosquatting attacks — consumers should use hash pinning in requirements files.
⚡ Reliability
Best When
You need programmatic access to Python package metadata, version history, or release files — especially for dependency scanning, upgrade tooling, or building Python-aware developer tools.
Avoid When
You need SLA guarantees, private package hosting, or are performing bulk operations that could be interpreted as scraping — PyPI actively rate-limits and bans abusive clients.
Use Cases
- • Fetching package metadata (author, license, dependencies, classifiers, release history) for dependency analysis and security scanning
- • Building Python environment management tools that need to resolve package versions without running pip
- • Checking latest stable version of a package or discovering all available versions for upgrade advisory tools
- • Automating package publication workflows using the PyPI upload API (Twine-compatible XMLRPC or Trusted Publisher OIDC flow)
- • Building internal mirrors or caches of the Python package index using the Simple Repository Protocol
Not For
- • Private Python package hosting — use PyPI's private index feature (Trusted Publishing), Artifactory, or a self-hosted devpi server
- • High-volume parallel download of package files without caching — use a mirror or CDN layer
- • Non-Python package ecosystems — use npm, crates.io, or Maven for other languages
Interface
Authentication
Reading package data (JSON API, Simple API) requires no authentication. Publishing requires either a PyPI API token (scoped to all projects or a specific project) or the preferred Trusted Publisher flow (OIDC from GitHub Actions, GitLab CI, or Google Cloud). Username/password auth for uploads was deprecated in 2023. API tokens start with `pypi-` prefix.
Pricing
PyPI is a non-profit operated by the Python Software Foundation. There are no charges for reads or uploads. However, aggressive automated clients will be blocked. TestPyPI (test.pypi.org) is available for testing publish workflows without polluting the real index.
Agent Metadata
Known Gotchas
- ⚠ The PyPI JSON API endpoint is `https://pypi.org/pypi/{package}/json` — not the Simple API at `/simple/` — and these two APIs serve completely different data; the JSON API has rich metadata while Simple API only has download URLs per PEP 503
- ⚠ Package names are normalized per PEP 503 (lowercase, hyphens and underscores interchangeable, dots collapsed) — `my-package`, `my_package`, and `My.Package` all resolve to the same project; always normalize before lookups using the PEP 503 normalization rules
- ⚠ The `requires_dist` field in the JSON API contains raw PEP 508 dependency strings with environment markers — agents that try to parse these as plain package names will miss conditional dependencies and extras
- ⚠ Yanked releases still appear in the Simple API (they are not deleted) but have a `data-yanked` attribute on their `<a>` tags — pip will skip them unless the user specifies the exact version; agents scanning for latest safe versions must check for yanked status
- ⚠ The JSON API caches aggressively at the CDN — immediately after publishing a new version, the `/pypi/{package}/json` endpoint may return the previous version for up to 10 minutes; use `/pypi/{package}/{version}/json` for the specific new version which bypasses some caches
- ⚠ Trusted Publisher (OIDC) uploads require the GitHub Actions workflow to call `sigstore/gh-action-sigstore-python` and the PyPI project to pre-configure the trusted publisher — both sides must be configured before the first upload attempt or it will fall back to token auth with a confusing error
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for PyPI (Python Package Index) API.
Scores are editorial opinions as of 2026-03-06.