Python interface to PyPI Stats API to get aggregate
download statistics on Python packages on the Python Package Index without having to
execute queries directly against Google BigQuery.
Data is available for the last 180 days. (For longer
time periods, pypinfo can help, you'll need an API
key and get free quota.)
Installation
From PyPI
python3 -m pip install --upgrade pypistats
From source
git clone https://github.com/hugovk/pypistats
cd pypistats
python3 -m pip install .
Example command-line use
Run pypistats with a subcommand (corresponding to
), then options for that
subcommand.
$ pypistats --help
usage: pypistats [-h] [-V] {recent,overall,python_major,python_minor,system} ...
positional arguments:
{recent,overall,python_major,python_minor,system}
options:
-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 {html,json,pretty,md,markdown,rst,tsv}] [-j] [-v]
[package]
Retrieve the aggregate download quantities for the last 1/7/30 days, excluding
downloads from mirrors
positional arguments:
package package name, or dir to check pyproject.toml/setup.cfg
(default: .)
options:
-h, --help show this help message and exit
-p, --period {day,week,month}
-f, --format {html,json,pretty,md,markdown,rst,tsv}
The format of output (default: pretty)
-j, --json Shortcut for "-f json" (default: False)
-v, --verbose Print debug messages to stderr (default: False)
$ pypistats python_minor --help
usage: pypistats python_minor [-h] [-V VERSION]
[-f {html,json,pretty,md,markdown,rst,tsv}] [-j]
[-sd yyyy-mm[-dd]|name] [-ed yyyy-mm[-dd]|name]
[-m yyyy-mm|name] [-l] [-t] [-d] [--monthly] [-s SORT]
[-c {yes,no,auto}] [-v]
[package]
Retrieve the aggregate daily download time series by Python minor version number
positional arguments:
package package name, or dir to check pyproject.toml/setup.cfg
(default: .)
options:
-h, --help show this help message and exit
-V, --version VERSION
eg. 2.7 or 3.6 (default: None)
-f, --format {html,json,pretty,md,markdown,rst,tsv}
The format of output (default: pretty)
-j, --json Shortcut for "-f json" (default: False)
-sd, --start-date yyyy-mm[-dd]|name
Start date (default: None)
-ed, --end-date yyyy-mm[-dd]|name
End date (default: None)
-m, --month yyyy-mm|name
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)
-s, --sort SORT Column to sort by (for example: downloads, date, category)
(default: downloads)
-c, --color {yes,no,auto}
Color terminal output (default: auto)
-v, --verbose Print debug messages to stderr (default: False)