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

How to browse packages in json API? #768

Closed
wimglenn opened this issue Feb 6, 2018 · 2 comments
Closed

How to browse packages in json API? #768

wimglenn opened this issue Feb 6, 2018 · 2 comments

Comments

@wimglenn
Copy link

wimglenn commented Feb 6, 2018

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?
@berkerpeksag
Copy link
Collaborator

Thank you for the report. Looking at both legacy PyPI source code and https://github.com/pypa/warehouse/tree/master/warehouse/legacy, I don't think it's possible to do that with JSON API. I'd suggest discussing this with Warehouse maintainers as this codebase has been deprecated. Closing this issue for now but we can reopen if needed.

@brainwane
Copy link

@wimglenn Specifically I think you'd like to take a look at and subscribe to notifications for pypi/warehouse#2913 . Sorry for the delay in addressing this issue!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants