pypi-json¶
PyPI JSON API client library
pypi-json
is a client library for the Python JSON API. With it, you can query the Python Package Index (PyPI), and other repositories using the same API, for project metadata, including available releases and downloadable package files.
Installation¶
python3 -m pip install pypi-json --user
First add the required channels
conda config --add channels https://conda.anaconda.org/conda-forge
conda config --add channels https://conda.anaconda.org/domdfcoding
Then install
conda install pypi-json
python3 -m pip install git+https://github.com/repo-helper/pypi-json@master --user
Example¶
>>> from pypi_json import PyPIJSON
>>> from pprint import pprint
>>> with PyPIJSON() as client:
... requests_metadata = client.get_metadata("requests")
>>> pkg = requests_metadata.urls[0]
>>> pprint(pkg)
{'comment_text': '',
'digests': {'md5': 'deb79adc50b8205783221cfff7075d1e',
'sha256': '6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24'},
'downloads': -1,
'filename': 'requests-2.26.0-py2.py3-none-any.whl',
'has_sig': False,
'md5_digest': 'deb79adc50b8205783221cfff7075d1e',
'packagetype': 'bdist_wheel',
'python_version': 'py2.py3',
'requires_python': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, '
'!=3.5.*',
'size': 62251,
'upload_time': '2021-07-13T14:55:06',
'upload_time_iso_8601': '2021-07-13T14:55:06.933494Z',
'url': 'https://files.pythonhosted.org/packages/92/96/144f70b972a9c0eabbd4391ef93ccd49d0f2747f4f6a2a2738e99e5adc65/requests-2.26.0-py2.py3-none-any.whl',
'yanked': False,
'yanked_reason': None}
>>> list(requests_metadata.releases.keys())[:10]
['0.0.1', '0.10.0', '0.10.1', '0.10.2', '0.10.3', '0.10.4', '0.10.6', '0.10.7', '0.10.8', '0.11.1']