All Projects → hugovk → Pypistats

hugovk / Pypistats

Licence: mit
Command-line interface to PyPI Stats API to get download stats for Python packages

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Pypistats

Starcli
✨ Browse GitHub trending projects from your command line
Stars: ✭ 269 (+212.79%)
Mutual labels:  command-line-tool, cli, command-line, hacktoberfest, pypi
Terjira
Terjira is a very interactive and easy to use CLI tool for Jira.
Stars: ✭ 713 (+729.07%)
Mutual labels:  command-line-tool, cli, command-line, hacktoberfest
Laminas Cli
Console command runner, exposing commands written in Laminas MVC and Mezzio components and applications
Stars: ✭ 25 (-70.93%)
Mutual labels:  command-line-tool, cli, command-line, hacktoberfest
Freenom Dns Updater
A tool to update freenom's dns records
Stars: ✭ 117 (+36.05%)
Mutual labels:  api, command-line-tool, cli, pypi
Executor
Watch for file changes and then execute command. Very nice for test driven development.
Stars: ✭ 14 (-83.72%)
Mutual labels:  cli, command-line, hacktoberfest
Clifx
Declarative framework for building command line interfaces
Stars: ✭ 900 (+946.51%)
Mutual labels:  cli, command-line, hacktoberfest
Github Traffic
Get the Github traffic for the specified repository
Stars: ✭ 77 (-10.47%)
Mutual labels:  api, statistics, stats
Cliwrap
Library for running command line processes
Stars: ✭ 1,057 (+1129.07%)
Mutual labels:  cli, command-line, hacktoberfest
Ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Stars: ✭ 28,564 (+33113.95%)
Mutual labels:  command-line-tool, cli, command-line
Ecsctl
Command-line tool for managing AWS Elastic Container Service and Projects to run on it.
Stars: ✭ 15 (-82.56%)
Mutual labels:  command-line-tool, cli, command-line
Tsv Utils
eBay's TSV Utilities: Command line tools for large, tabular data files. Filtering, statistics, sampling, joins and more.
Stars: ✭ 1,215 (+1312.79%)
Mutual labels:  cli, command-line, statistics
Pyinquirer
A Python module for common interactive command line user interfaces
Stars: ✭ 1,151 (+1238.37%)
Mutual labels:  command-line-tool, cli, command-line
Q
q - Run SQL directly on CSV or TSV files
Stars: ✭ 8,809 (+10143.02%)
Mutual labels:  command-line-tool, cli, command-line
Opaline
NextJS for CLI tools
Stars: ✭ 84 (-2.33%)
Mutual labels:  command-line-tool, cli, command-line
Navi
An interactive cheatsheet tool for the command-line
Stars: ✭ 10,055 (+11591.86%)
Mutual labels:  cli, command-line, hacktoberfest
Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+35752.33%)
Mutual labels:  cli, command-line, hacktoberfest
Ed
A modern UNIX ed (line editor) clone written in Go
Stars: ✭ 44 (-48.84%)
Mutual labels:  command-line-tool, cli, command-line
Github Files Fetcher
Download a specific folder or file from a GitHub repo through command line
Stars: ✭ 73 (-15.12%)
Mutual labels:  command-line-tool, cli, command-line
Papis
Powerful and highly extensible command-line based document and bibliography manager.
Stars: ✭ 636 (+639.53%)
Mutual labels:  command-line-tool, cli, command-line
Wbot
A simple Web based BOT for WhatsApp™ in NodeJS 😜. Working as of 📅 Feb 14th, 2020
Stars: ✭ 638 (+641.86%)
Mutual labels:  command-line-tool, cli, hacktoberfest

pypistats

PyPI version Supported Python versions PyPI downloads Travis CI status Azure Pipelines status GitHub Actions status codecov GitHub DOI Code style: Black

Python 3.6+ 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

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 |
|---------:|-----------:|----------:|
|  280,842 |  7,065,928 | 1,709,689 |

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]|name]
                              [-ed yyyy-mm[-dd]|name] [-m yyyy-mm|name] [-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]|name, --start-date yyyy-mm[-dd]|name
                        Start date (default: None)
  -ed yyyy-mm[-dd]|name, --end-date yyyy-mm[-dd]|name
                        End date (default: None)
  -m yyyy-mm|name, --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)
  -v, --verbose         Print debug messages to stderr (default: False)

Get version downloads:

$ pypistats python_minor pillow --last-month
| category | percent | downloads |
|----------|--------:|----------:|
| 2.7      |  35.94% | 2,189,327 |
| 3.6      |  31.83% | 1,938,870 |
| 3.7      |  18.71% | 1,139,642 |
| 3.5      |  11.29% |   687,782 |
| 3.4      |   1.23% |    74,673 |
| null     |   0.94% |    57,476 |
| 3.8      |   0.04% |     2,147 |
| 2.6      |   0.01% |       826 |
| 3.3      |   0.00% |       212 |
| 3.2      |   0.00% |        28 |
| 2.4      |   0.00% |         6 |
| 3.9      |   0.00% |         5 |
| 2.8      |   0.00% |         1 |
| Total    |         | 6,090,995 |

The table is Markdown, ready for pasting in GitHub issues and PRs:

category percent downloads
2.7 35.94% 2,189,327
3.6 31.83% 1,938,870
3.7 18.71% 1,139,642
3.5 11.29% 687,782
3.4 1.23% 74,673
null 0.94% 57,476
3.8 0.04% 2,147
2.6 0.01% 826
3.3 0.00% 212
3.2 0.00% 28
2.4 0.00% 6
3.9 0.00% 5
2.8 0.00% 1
Total 6,090,995

These are equivalent (in May 2019):

pypistats python_major pip --last-month
pypistats python_major pip --month april
pypistats python_major pip --month apr
pypistats python_major pip --month 2019-04

And:

pypistats python_major pip --start-date december --end-date january
pypistats python_major pip --start-date dec      --end-date jan
pypistats python_major pip --start-date 2018-12  --end-date 2019-01

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"))

NumPy and pandas

To use with either NumPy or pandas, make sure they are first installed, or:

pip install --upgrade "pypistats[numpy]"
pip install --upgrade "pypistats[pandas]"
pip install --upgrade "pypistats[numpy,pandas]"

Return data in a NumPy array for further processing:

import pypistats
numpy_array = pypistats.overall("pyvista", total=True, format="numpy")
print(type(numpy_array))
# <class 'numpy.ndarray'>
print(numpy_array)
# [['with_mirrors' '2019-09-20' '2.23%' 1204]
#  ['without_mirrors' '2019-09-20' '2.08%' 1122]
#  ['with_mirrors' '2019-09-19' '0.92%' 496]
#  ...
#  ['with_mirrors' '2019-10-26' '0.02%' 13]
#  ['without_mirrors' '2019-10-26' '0.02%' 12]
#  ['Total' None None 54041]]

Or in a pandas DataFrame:

import pypistats
pandas_dataframe = pypistats.overall("pyvista", total=True, format="pandas")
print(type(pandas_dataframe))
# <class 'pandas.core.frame.DataFrame'>
print(pandas_dataframe)
#             category        date percent  downloads
# 0       with_mirrors  2019-09-20   2.23%       1204
# 1    without_mirrors  2019-09-20   2.08%       1122
# 2       with_mirrors  2019-09-19   0.92%        496
# 3       with_mirrors  2019-08-22   0.90%        489
# 4    without_mirrors  2019-09-19   0.86%        466
# ..               ...         ...     ...        ...
# 354  without_mirrors  2019-11-03   0.03%         15
# 355  without_mirrors  2019-11-16   0.03%         15
# 356     with_mirrors  2019-10-26   0.02%         13
# 357  without_mirrors  2019-10-26   0.02%         12
# 358            Total        None    None      54041
#
# [359 rows x 4 columns]

For example, create charts with pandas:

# Show overall downloads over time, excluding mirrors
import pypistats
data = pypistats.overall("pillow", total=True, format="pandas")
data = data.groupby("category").get_group("without_mirrors").sort_values("date")

chart = data.plot(x="date", y="downloads", figsize=(10, 2))
chart.figure.show()
chart.figure.savefig("overall.png")  # alternatively

overall.png

# Show Python 3 downloads over time
import pypistats
data = pypistats.python_major("pillow", total=True, format="pandas")
data = data.groupby("category").get_group(3).sort_values("date")

chart = data.plot(x="date", y="downloads", figsize=(10, 2))
chart.figure.show()
chart.figure.savefig("python3.png")  # alternatively

python3.png

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].