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 -U 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}] [-j] 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}
-j, --json Output JSON
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] [-sd START_DATE]
[-ed END_DATE] [-m MONTH] [-l] [-j] [-d]
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
-sd START_DATE, --start-date START_DATE
yyyy-mm-dd
-ed END_DATE, --end-date END_DATE
yyyy-mm-dd
-m MONTH, --month MONTH
Shortcut for -sd & -ed for a yyyy-mm
-l, --last-month Shortcut for -sd & -ed for last month
-j, --json Output JSON
-d, --daily Show daily downloads
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 API 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", output="table"))
pprint(pypistats.recent("pillow", "week", output="json"))
print(pypistats.recent("pillow", "month"))
print(pypistats.overall("pillow"))
print(pypistats.overall("pillow", mirrors=True, output="table"))
pprint(pypistats.overall("pillow", mirrors=False, output="json"))
print(pypistats.python_major("pillow"))
print(pypistats.python_major("pillow", version=2, output="table"))
pprint(pypistats.python_major("pillow", version="3", output="json"))
print(pypistats.python_minor("pillow"))
print(pypistats.python_minor("pillow", version=2.7, output="table"))
pprint(pypistats.python_minor("pillow", version="3.7", output="json"))
print(pypistats.system("pillow"))
print(pypistats.system("pillow", os="darwin", output="table"))
pprint(pypistats.system("pillow", os="linux", output="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.1.0.tar.gz
(6.3 kB
view details)
Built Distribution
File details
Details for the file pypistats-0.1.0.tar.gz
.
File metadata
- Download URL: pypistats-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ae6370917225bed0d529cd0ed61d6095d1fa9bec96f6b7df59fd58a2843031 |
|
MD5 | d7eda0b9537178d16e6809f47b78266b |
|
BLAKE2b-256 | 64bd7a4f43d27ba0f18404393779a1e6ceb7addc520073430cd1a4173b509ab4 |
Provenance
File details
Details for the file pypistats-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pypistats-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 115bbfe3b5b6b61f5629eba2e37910babc44b3d920953a6796cccf130e9b3d70 |
|
MD5 | 1462a2148bf2e8bcd931dd8820cfb0b1 |
|
BLAKE2b-256 | b7234b07632fbeb910ad22b6d86e108e2fa29f9640752b350237dd33dccc5cbd |