Python interface to PyPI Stats API https://pypistats.org/api
Project description
pypistats
Python 3.6+ interface to PyPI Stats API.
Installation
From PyPI
pip install --upgrade pypistats
From source
git clone https://github.com/hugovk/pypistats
cd pypistats
pip install .
Example command-line use
Run pypistats
with a subcommand (corresponding to PyPI Stats endpoints),
then options for that subcommand.
Top-level help:
$ pypistats --help
usage: pypistats [-h] [-V]
{recent,overall,python_major,python_minor,system} ...
positional arguments:
{recent,overall,python_major,python_minor,system}
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
Help for a subcommand:
$ pypistats recent --help
usage: pypistats recent [-h] [-p {day,week,month}]
[-f {json,markdown,rst,html}] [-j] [-v]
package
Retrieve the aggregate download quantities for the last day/week/month
positional arguments:
package
optional arguments:
-h, --help show this help message and exit
-p {day,week,month}, --period {day,week,month}
-f {json,markdown,rst,html}, --format {json,markdown,rst,html}
The format of output (default: markdown)
-j, --json Shortcut for "-f json" (default: False)
-v, --verbose Print debug messages to stderr (default: False)
Get recent downloads:
$ pypistats recent pillow
| last_day | last_month | last_week |
|---------:|-----------:|----------:|
| 61877 | 3527341 | 865484 |
Help for another subcommand:
$ pypistats python_minor --help
usage: pypistats python_minor [-h] [-V VERSION] [-f {json,markdown,rst,html}]
[-j] [-sd yyyy-mm[-dd]] [-ed yyyy-mm[-dd]]
[-m yyyy-mm] [-l] [-t] [-d] [--monthly] [-v]
package
Retrieve the aggregate daily download time series by Python minor version
number
positional arguments:
package
optional arguments:
-h, --help show this help message and exit
-V VERSION, --version VERSION
eg. 2.7 or 3.6 (default: None)
-f {json,markdown,rst,html}, --format {json,markdown,rst,html}
The format of output (default: markdown)
-j, --json Shortcut for "-f json" (default: False)
-sd yyyy-mm[-dd], --start-date yyyy-mm[-dd]
Start date (default: None)
-ed yyyy-mm[-dd], --end-date yyyy-mm[-dd]
End date (default: None)
-m yyyy-mm, --month yyyy-mm
Shortcut for -sd & -ed for a single month (default:
None)
-l, --last-month Shortcut for -sd & -ed for last month (default: False)
-t, --this-month Shortcut for -sd for this month (default: False)
-d, --daily Show daily downloads (default: False)
--monthly Show monthly downloads (default: False)
-v, --verbose Print debug messages to stderr (default: False)
Get version downloads:
$ pypistats python_minor pillow --last-month
| category | percent | downloads |
|----------|--------:|----------:|
| 2.7 | 46.64% | 1,512,429 |
| 3.6 | 30.34% | 983,838 |
| 3.5 | 12.53% | 406,429 |
| 3.7 | 6.12% | 198,558 |
| 3.4 | 3.41% | 110,552 |
| null | 0.84% | 27,380 |
| 3.3 | 0.05% | 1,599 |
| 2.6 | 0.05% | 1,581 |
| 3.2 | 0.01% | 246 |
| 3.8 | 0.00% | 133 |
| 2.4 | 0.00% | 7 |
| Total | | 3,242,752 |
The table is Markdown, ready for pasting in GitHub issues and PRs:
category | percent | downloads |
---|---|---|
2.7 | 46.64% | 1,512,429 |
3.6 | 30.34% | 983,838 |
3.5 | 12.53% | 406,429 |
3.7 | 6.12% | 198,558 |
3.4 | 3.41% | 110,552 |
null | 0.84% | 27,380 |
3.3 | 0.05% | 1,599 |
2.6 | 0.05% | 1,581 |
3.2 | 0.01% | 246 |
3.8 | 0.00% | 133 |
2.4 | 0.00% | 7 |
Total | 3,242,752 |
Example programmatic use
Return values are from the JSON responses documented in the API: https://pypistats.org/api/
import pypistats
from pprint import pprint
# Call the API
print(pypistats.recent("pillow"))
print(pypistats.recent("pillow", "day", format="markdown"))
print(pypistats.recent("pillow", "week", format="rst"))
print(pypistats.recent("pillow", "month", format="html"))
pprint(pypistats.recent("pillow", "week", format="json"))
print(pypistats.recent("pillow", "day"))
print(pypistats.overall("pillow"))
print(pypistats.overall("pillow", mirrors=True, format="markdown"))
print(pypistats.overall("pillow", mirrors=False, format="rst"))
print(pypistats.overall("pillow", mirrors=True, format="html"))
pprint(pypistats.overall("pillow", mirrors=False, format="json"))
print(pypistats.python_major("pillow"))
print(pypistats.python_major("pillow", version=2, format="markdown"))
print(pypistats.python_major("pillow", version=3, format="rst"))
print(pypistats.python_major("pillow", version="2", format="html"))
pprint(pypistats.python_major("pillow", version="3", format="json"))
print(pypistats.python_minor("pillow"))
print(pypistats.python_minor("pillow", version=2.7, format="markdown"))
print(pypistats.python_minor("pillow", version="2.7", format="rst"))
print(pypistats.python_minor("pillow", version=3.7, format="html"))
pprint(pypistats.python_minor("pillow", version="3.7", format="json"))
print(pypistats.system("pillow"))
print(pypistats.system("pillow", os="darwin", format="markdown"))
print(pypistats.system("pillow", os="linux", format="rst"))
print(pypistats.system("pillow", os="darwin", format="html"))
pprint(pypistats.system("pillow", os="linux", format="json"))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pypistats-0.5.0.tar.gz
(22.4 kB
view details)
Built Distribution
File details
Details for the file pypistats-0.5.0.tar.gz
.
File metadata
- Download URL: pypistats-0.5.0.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02c485ce0e9a3628fc266919471e9c1056b473a5cb7534ab06ede863a8b5821b |
|
MD5 | c8370dad70cc42c7d06891400a61a6c1 |
|
BLAKE2b-256 | 9f5fe01214fd384fd391886214b4a33fffff0c9eb871f7d8e51d361259387869 |
Provenance
File details
Details for the file pypistats-0.5.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pypistats-0.5.0-py2.py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43355ec5d9e4e14181fe584b983a8607fddb89b267e2e53f1e62819bf6d125cc |
|
MD5 | 565fbdc26dee89951f2da8c653a05c3a |
|
BLAKE2b-256 | b288f90212c42d018d1d47ede422306acf81530f5dc638d1efc3fdd6580d624f |