Open uranusjr opened 5 years ago
Thanks for the report. Yes, we can definitely improve the API. However, the API v1 is sort of deprecated. There is a new API at https://staging.python.org/api/v2/ (not deployed on production yet) but I don't think its behavior is any better than the current one (my goal was to make it backwards compatible with v1) We can definitely add a name__startswith
filter at https://github.com/python/pythondotorg/blob/master/downloads/api.py#L73 and make getting files for a specific release easier.
On a related note, v2’s ALL_WITH_RELATIONS
filters don’t seem to work correctly (probably because of some Tastypie-DRF implementation details). I could do
/api/v1/downloads/release_file/?os=1&release__name=Python%203.6.4
but not
/api/v2/downloads/release_file/?os=1&release__name=Python%203.6.4
Interestingly once you have found the release
it appears you can use the ID from its resource_uri
e.g. https://www.python.org/api/v2/downloads/release/?slug=python-3115 finds a release with resource_uri
= https://www.python.org/api/v2/downloads/release/827/
Then filtering release_file
using the ID from the end of the release resource_uri like this:
https://www.python.org/api/v2/downloads/release_file/?release=827
seems to work, returning only relevant files for that release.
The question I want to answer is e.g. “what is the latest release for a given Python version X.Y”?
This can be answered by the API for https://endoflife.date/python, which is updated by automation, not immediately, but quite soon after each release:
https://endoflife.date/api/python.json
Currently it looks like:
Is your feature request related to a problem? Please describe.
The question I want to answer is e.g. “what is the latest release for a given Python version X.Y”?
I build a CPython installation automation tool for Windows. It can be used to install a Python directly from the command line, e.g.
pythonup install 3.6
. Currently I maintain a hard-coded mapping file to point3.6
to3.6.7
, but this means I need to release a new version every time CPython does.I wish to automate the process by asking the python.org API for this information, but the current API design makes it very awkward. From what I can tell, I need to
/downloads/release/
to get a long list of available releases.3.6.
, and choose the latest./downloads/release_file/
with the request ID to get a list of files for that release.Describe the solution you'd like
There are several things I would like to have to make the process more robust, but things that would benefit my workflow most would be
/downloads/release/
. The most ideal is likeversion_xy=3.6
, but even something likeslug__startswith=python-36
would be tremendously helpful./downloads/release/
’s returned payload, or allow/downloads/release_file/
to be filtered on slug or resource URI. Currentlyrelease
only hasslug
andresource_uri
, but neither of them can be used to filterrelease_file
.