pypiwrap¶
pypiwrap is an API wrapper for the Python Package Index (PyPI), providing interfaces for the JSON API, the Stats API, the Index API, and the PyPI RSS feeds.
For more information on supported features, see Features.
Installation¶
pypiwrap requires Python 3.10 or greater.
python3 -m pip install pypiwrap
py -3 -m pip install pypiwrap
Tip
If you plan to work with other packages along pypiwrap, we recommend you do so in a virtual environment so as to isolate it from other existing packages in the system.
Quickstart¶
pypiwrap provides three clients for interacting with PyPI:
SimpleRepoClientallows access to data from the Simple Repository API (also known as the Index API).PyPIClientallows access to data from the PyPI JSON API.PyPIFeedClientallows access to data from the PyPI RSS feeds.
Examples¶
Example 1: Fetching details about a project.
import pypiwrap
with pypiwrap.PyPIClient() as pypi:
project = pypi.get_project("requests")
print(f"{project.name} by {project.author}") # requests by Kenneth Reitz
Example 2: Getting the latest distribution file for a project.
import pypiwrap
with pypiwrap.SimpleRepoClient() as repo:
project = repo.get_project_page("requests")
print(project.files[-1].url) # https://files.pythonhosted.org/packages/63/70/[...]
Example 3: Fetching the latest releases feed for a package.
import pypiwrap
with pypiwrap.PyPIFeedClient() as rss:
feed = rss.get_latest_releases_for_project("Django")
for item in feed.items:
print(f"{item.title} was released on {item.published:%A, %B %d, %Y}")
print(item.link)
print()
More documentation can be found in the Client Reference.
Table of Contents¶
API Reference