Skip to content
This repository was archived by the owner on May 30, 2020. It is now read-only.
This repository was archived by the owner on May 30, 2020. It is now read-only.

How to browse packages in json API? #768

Closed
@wimglenn

Description

@wimglenn

From https://wiki.python.org/moin/PyPIXmlRpc:

The XMLRPC interface for PyPI is considered legacy and should not be used.
Use the Simple and JSON APIs.

But how can you use json API to browse packages? Is the json API documented somewhere? This is the only thing I could find, for detail endpoint, it seems only useful if you already know the package name.

With xmlrpc interface I could browse categories like this:

import xmlrpc.client as xmlrpclib
pypi = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
packages = pypi.browse([
    "Programming Language :: Python :: 3.7",
    "Framework :: Django :: 2.0",
])
for pkg,_ in packages:
    print(pkg)

In the web UI, could find the same thing here:
https://pypi.python.org/pypi?:action=browse&c=640&c=645

But there are still issues:

  • How to know the mapping between the numbers 640, 645 and the classifier strings. Aren't those just primary keys?
  • The browse action always returns me html, even if I put application/json accept headers. How to browse in json?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions