How to browse packages in json API?
Closed this issue · 2 comments
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?
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.
@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!