Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON API for PyPi - how to list packages?

Tags:

There is a JSON API for PyPI which allows getting data for packages:

http://pypi.python.org/pypi/<package_name>/json http://pypi.python.org/pypi/<package_name>/<version>/json 

However, is it possible to get a list of all PyPI packages (or, for example, recent ones) with a GET call?

like image 466
Piotr Migdal Avatar asked Jan 28 '14 23:01

Piotr Migdal


People also ask

Does PyPI have an API?

We're further increasing the security of the Python Package Index with another new beta feature: scoped API tokens for package upload.

How many packages are on PyPI?

As of 17 January 2022, more than 350,000 Python packages can be accessed through PyPI. PyPI primarily hosts Python packages in the form of archives called sdists (source distributions) or precompiled "wheels."

How do I search for pip packages?

pip search Looking for a package, pip is there to help you out. pip search allows you to search PyPI for any package using the pip search <package> command. The result of the command returns the name and description of all the matching packages.

How can I get PyPI API token?

To make an API token: Verify your email address (check your account settings) In your account settings, go to the API tokens section and select "Add API token"


2 Answers

The easiest way to do this is to use the simple index at PyPI which lists all packages without overhead. You can then request the JSON of each package individually by performing a GET request to the URLs mentioned in your question.

like image 67
Simeon Visser Avatar answered Sep 21 '22 06:09

Simeon Visser


I know that you asked for a way to do this from the JSON API, but you can use the XML-RPC api to get this info very easily, without having to parse HTML.

try:      import xmlrpclib except ImportError:      import xmlrpc.client as xmlrpclib  client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi') # get a list of package names packages = client.list_packages() 
like image 40
Gourneau Avatar answered Sep 24 '22 06:09

Gourneau