pypistats


Namepypistats JSON
Version 1.7.0 PyPI version JSON
download
home_pageNone
SummaryPython interface to PyPI Stats API https://pypistats.org/api
upload_time2024-10-15 21:31:33
maintainerNone
docs_urlNone
authorHugo van Kemenade
requires_python>=3.9
licenseMIT
keywords bigquery pypi downloads statistics stats
VCS
bugtrack_url
requirements freezegun httpx numpy pandas platformdirs prettytable pytablewriter pytest pytest-cov python-slugify respx termcolor
Travis-CI No Travis.
coveralls test coverage
            # pypistats

[![PyPI version](https://img.shields.io/pypi/v/pypistats.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/pypistats/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/pypistats.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/pypistats/)
[![PyPI downloads](https://img.shields.io/pypi/dm/pypistats.svg)](https://pypistats.org/packages/pypistats)
[![Azure Pipelines status](https://dev.azure.com/hugovk/hugovk/_apis/build/status/hugovk.pypistats?branchName=main)](https://dev.azure.com/hugovk/hugovk/_build?definitionId=1)
[![GitHub Actions status](https://github.com/hugovk/pypistats/workflows/Test/badge.svg)](https://github.com/hugovk/pypistats/actions)
[![codecov](https://codecov.io/gh/hugovk/pypistats/branch/main/graph/badge.svg)](https://codecov.io/gh/hugovk/pypistats)
[![Licence](https://img.shields.io/github/license/hugovk/pypistats.svg)](LICENSE.txt)
[![DOI](https://zenodo.org/badge/149862343.svg)](https://zenodo.org/badge/latestdoi/149862343)
[![Code style: Black](https://img.shields.io/badge/code%20style-Black-000000.svg)](https://github.com/psf/black)

Python interface to [PyPI Stats API](https://pypistats.org/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](https://pypistats.org/about#data). (For longer
time periods, [pypinfo](https://github.com/ofek/pypinfo) can help, you'll need an API
key and get free quota.)

## Installation

### From PyPI

```bash
python3 -m pip install --upgrade pypistats
```

### From source

```bash
git clone https://github.com/hugovk/pypistats
cd pypistats
python3 -m pip install .
```

## Example command-line use

Run `pypistats` with a subcommand (corresponding to
[PyPI Stats endpoints](https://pypistats.org/api/#endpoints)), then options for that
subcommand.

Top-level help:

<!-- [[[cog
from scripts.run_command import run
run("pypistats --help")
]]] -->

```console
$ 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
```

<!-- [[[end]]] -->

Help for a subcommand:

<!-- [[[cog run("pypistats recent --help") ]]] -->

```console
$ 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 day/week/month

positional arguments:
  package

options:
  -h, --help            show this help message and exit
  -p {day,week,month}, --period {day,week,month}
  -f {html,json,pretty,md,markdown,rst,tsv}, --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)
```

<!-- [[[end]]] -->

Get recent downloads:

<!-- [[[cog run("pypistats recent pillow") ]]] -->

```console
$ pypistats recent pillow
┌───────────┬────────────┬────────────┐
│  last_day │ last_month │  last_week │
├───────────┼────────────┼────────────┤
│ 3,419,597 │ 91,237,125 │ 21,259,217 │
└───────────┴────────────┴────────────┘
```

<!-- [[[end]]] -->

Help for another subcommand:

<!-- [[[cog run("pypistats python_minor --help") ]]] -->

```console
$ 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] [-c {yes,no,auto}] [-v]
                              package

Retrieve the aggregate daily download time series by Python minor version
number

positional arguments:
  package

options:
  -h, --help            show this help message and exit
  -V VERSION, --version VERSION
                        eg. 2.7 or 3.6 (default: None)
  -f {html,json,pretty,md,markdown,rst,tsv}, --format {html,json,pretty,md,markdown,rst,tsv}
                        The format of output (default: pretty)
  -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)
  -c {yes,no,auto}, --color {yes,no,auto}
                        Color terminal output (default: auto)
  -v, --verbose         Print debug messages to stderr (default: False)
```

<!-- [[[end]]] -->

Get version downloads:

<!-- [[[cog run("pypistats python_minor pillow --last-month") ]]] -->

```console
$ pypistats python_minor pillow --last-month
┌──────────┬─────────┬────────────┐
│ category │ percent │  downloads │
├──────────┼─────────┼────────────┤
│ 3.8      │  18.37% │ 16,161,117 │
│ 3.10     │  17.47% │ 15,373,666 │
│ 3.7      │  16.70% │ 14,691,371 │
│ 3.11     │  15.49% │ 13,630,259 │
│ 3.9      │  13.19% │ 11,605,389 │
│ 3.6      │   9.68% │  8,519,789 │
│ null     │   4.64% │  4,085,994 │
│ 3.12     │   3.26% │  2,871,386 │
│ 2.7      │   0.95% │    837,638 │
│ 3.5      │   0.25% │    216,308 │
│ 3.13     │   0.00% │      2,830 │
│ 3.4      │   0.00% │      1,237 │
│ 3.3      │   0.00% │        109 │
│ 3.1      │   0.00% │          3 │
│ 3.2      │   0.00% │          2 │
│ Total    │         │ 87,997,098 │
└──────────┴─────────┴────────────┘

Date range: 2024-02-01 - 2024-02-29
```

<!-- [[[end]]] -->

You can format in Markdown, ready for pasting in GitHub issues and PRs:

<!-- [[[cog run("pypistats python_minor pillow --last-month --format md", with_console=False) ]]] -->

| category | percent |  downloads |
| :------- | ------: | ---------: |
| 3.8      |  18.37% | 16,161,117 |
| 3.10     |  17.47% | 15,373,666 |
| 3.7      |  16.70% | 14,691,371 |
| 3.11     |  15.49% | 13,630,259 |
| 3.9      |  13.19% | 11,605,389 |
| 3.6      |   9.68% |  8,519,789 |
| null     |   4.64% |  4,085,994 |
| 3.12     |   3.26% |  2,871,386 |
| 2.7      |   0.95% |    837,638 |
| 3.5      |   0.25% |    216,308 |
| 3.13     |   0.00% |      2,830 |
| 3.4      |   0.00% |      1,237 |
| 3.3      |   0.00% |        109 |
| 3.1      |   0.00% |          3 |
| 3.2      |   0.00% |          2 |
| Total    |         | 87,997,098 |

Date range: 2024-02-01 - 2024-02-29

<!-- [[[end]]] -->

These are equivalent (in May 2019):

```sh
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:

```sh
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/

```python
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:

```bash
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:

```python
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:

```python
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:

```python
# 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](example/overall.png)

```python
# 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](example/python3.png)

## See also

Related projects

- https://github.com/ofek/pypinfo
- https://github.com/scivision/pypistats-plots

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pypistats",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "BigQuery, PyPI, downloads, statistics, stats",
    "author": "Hugo van Kemenade",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fa/26/8f8ee01c02969f486666b8c9a458d9e851dfe5db07bbca3d3ab72e9da1d1/pypistats-1.7.0.tar.gz",
    "platform": null,
    "description": "# pypistats\n\n[![PyPI version](https://img.shields.io/pypi/v/pypistats.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/pypistats/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/pypistats.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/pypistats/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/pypistats.svg)](https://pypistats.org/packages/pypistats)\n[![Azure Pipelines status](https://dev.azure.com/hugovk/hugovk/_apis/build/status/hugovk.pypistats?branchName=main)](https://dev.azure.com/hugovk/hugovk/_build?definitionId=1)\n[![GitHub Actions status](https://github.com/hugovk/pypistats/workflows/Test/badge.svg)](https://github.com/hugovk/pypistats/actions)\n[![codecov](https://codecov.io/gh/hugovk/pypistats/branch/main/graph/badge.svg)](https://codecov.io/gh/hugovk/pypistats)\n[![Licence](https://img.shields.io/github/license/hugovk/pypistats.svg)](LICENSE.txt)\n[![DOI](https://zenodo.org/badge/149862343.svg)](https://zenodo.org/badge/latestdoi/149862343)\n[![Code style: Black](https://img.shields.io/badge/code%20style-Black-000000.svg)](https://github.com/psf/black)\n\nPython interface to [PyPI Stats API](https://pypistats.org/api) to get aggregate\ndownload statistics on Python packages on the Python Package Index without having to\nexecute queries directly against Google BigQuery.\n\nData is available for the [last 180 days](https://pypistats.org/about#data). (For longer\ntime periods, [pypinfo](https://github.com/ofek/pypinfo) can help, you'll need an API\nkey and get free quota.)\n\n## Installation\n\n### From PyPI\n\n```bash\npython3 -m pip install --upgrade pypistats\n```\n\n### From source\n\n```bash\ngit clone https://github.com/hugovk/pypistats\ncd pypistats\npython3 -m pip install .\n```\n\n## Example command-line use\n\nRun `pypistats` with a subcommand (corresponding to\n[PyPI Stats endpoints](https://pypistats.org/api/#endpoints)), then options for that\nsubcommand.\n\nTop-level help:\n\n<!-- [[[cog\nfrom scripts.run_command import run\nrun(\"pypistats --help\")\n]]] -->\n\n```console\n$ pypistats --help\nusage: pypistats [-h] [-V]\n                 {recent,overall,python_major,python_minor,system} ...\n\npositional arguments:\n  {recent,overall,python_major,python_minor,system}\n\noptions:\n  -h, --help            show this help message and exit\n  -V, --version         show program's version number and exit\n```\n\n<!-- [[[end]]] -->\n\nHelp for a subcommand:\n\n<!-- [[[cog run(\"pypistats recent --help\") ]]] -->\n\n```console\n$ pypistats recent --help\nusage: pypistats recent [-h] [-p {day,week,month}]\n                        [-f {html,json,pretty,md,markdown,rst,tsv}] [-j]\n                        [-v]\n                        package\n\nRetrieve the aggregate download quantities for the last day/week/month\n\npositional arguments:\n  package\n\noptions:\n  -h, --help            show this help message and exit\n  -p {day,week,month}, --period {day,week,month}\n  -f {html,json,pretty,md,markdown,rst,tsv}, --format {html,json,pretty,md,markdown,rst,tsv}\n                        The format of output (default: pretty)\n  -j, --json            Shortcut for \"-f json\" (default: False)\n  -v, --verbose         Print debug messages to stderr (default: False)\n```\n\n<!-- [[[end]]] -->\n\nGet recent downloads:\n\n<!-- [[[cog run(\"pypistats recent pillow\") ]]] -->\n\n```console\n$ pypistats recent pillow\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  last_day \u2502 last_month \u2502  last_week \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 3,419,597 \u2502 91,237,125 \u2502 21,259,217 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n<!-- [[[end]]] -->\n\nHelp for another subcommand:\n\n<!-- [[[cog run(\"pypistats python_minor --help\") ]]] -->\n\n```console\n$ pypistats python_minor --help\nusage: pypistats python_minor [-h] [-V VERSION]\n                              [-f {html,json,pretty,md,markdown,rst,tsv}]\n                              [-j] [-sd yyyy-mm[-dd]|name]\n                              [-ed yyyy-mm[-dd]|name] [-m yyyy-mm|name] [-l]\n                              [-t] [-d] [--monthly] [-c {yes,no,auto}] [-v]\n                              package\n\nRetrieve the aggregate daily download time series by Python minor version\nnumber\n\npositional arguments:\n  package\n\noptions:\n  -h, --help            show this help message and exit\n  -V VERSION, --version VERSION\n                        eg. 2.7 or 3.6 (default: None)\n  -f {html,json,pretty,md,markdown,rst,tsv}, --format {html,json,pretty,md,markdown,rst,tsv}\n                        The format of output (default: pretty)\n  -j, --json            Shortcut for \"-f json\" (default: False)\n  -sd yyyy-mm[-dd]|name, --start-date yyyy-mm[-dd]|name\n                        Start date (default: None)\n  -ed yyyy-mm[-dd]|name, --end-date yyyy-mm[-dd]|name\n                        End date (default: None)\n  -m yyyy-mm|name, --month yyyy-mm|name\n                        Shortcut for -sd & -ed for a single month (default:\n                        None)\n  -l, --last-month      Shortcut for -sd & -ed for last month (default: False)\n  -t, --this-month      Shortcut for -sd for this month (default: False)\n  -d, --daily           Show daily downloads (default: False)\n  --monthly             Show monthly downloads (default: False)\n  -c {yes,no,auto}, --color {yes,no,auto}\n                        Color terminal output (default: auto)\n  -v, --verbose         Print debug messages to stderr (default: False)\n```\n\n<!-- [[[end]]] -->\n\nGet version downloads:\n\n<!-- [[[cog run(\"pypistats python_minor pillow --last-month\") ]]] -->\n\n```console\n$ pypistats python_minor pillow --last-month\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 category \u2502 percent \u2502  downloads \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 3.8      \u2502  18.37% \u2502 16,161,117 \u2502\n\u2502 3.10     \u2502  17.47% \u2502 15,373,666 \u2502\n\u2502 3.7      \u2502  16.70% \u2502 14,691,371 \u2502\n\u2502 3.11     \u2502  15.49% \u2502 13,630,259 \u2502\n\u2502 3.9      \u2502  13.19% \u2502 11,605,389 \u2502\n\u2502 3.6      \u2502   9.68% \u2502  8,519,789 \u2502\n\u2502 null     \u2502   4.64% \u2502  4,085,994 \u2502\n\u2502 3.12     \u2502   3.26% \u2502  2,871,386 \u2502\n\u2502 2.7      \u2502   0.95% \u2502    837,638 \u2502\n\u2502 3.5      \u2502   0.25% \u2502    216,308 \u2502\n\u2502 3.13     \u2502   0.00% \u2502      2,830 \u2502\n\u2502 3.4      \u2502   0.00% \u2502      1,237 \u2502\n\u2502 3.3      \u2502   0.00% \u2502        109 \u2502\n\u2502 3.1      \u2502   0.00% \u2502          3 \u2502\n\u2502 3.2      \u2502   0.00% \u2502          2 \u2502\n\u2502 Total    \u2502         \u2502 87,997,098 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\nDate range: 2024-02-01 - 2024-02-29\n```\n\n<!-- [[[end]]] -->\n\nYou can format in Markdown, ready for pasting in GitHub issues and PRs:\n\n<!-- [[[cog run(\"pypistats python_minor pillow --last-month --format md\", with_console=False) ]]] -->\n\n| category | percent |  downloads |\n| :------- | ------: | ---------: |\n| 3.8      |  18.37% | 16,161,117 |\n| 3.10     |  17.47% | 15,373,666 |\n| 3.7      |  16.70% | 14,691,371 |\n| 3.11     |  15.49% | 13,630,259 |\n| 3.9      |  13.19% | 11,605,389 |\n| 3.6      |   9.68% |  8,519,789 |\n| null     |   4.64% |  4,085,994 |\n| 3.12     |   3.26% |  2,871,386 |\n| 2.7      |   0.95% |    837,638 |\n| 3.5      |   0.25% |    216,308 |\n| 3.13     |   0.00% |      2,830 |\n| 3.4      |   0.00% |      1,237 |\n| 3.3      |   0.00% |        109 |\n| 3.1      |   0.00% |          3 |\n| 3.2      |   0.00% |          2 |\n| Total    |         | 87,997,098 |\n\nDate range: 2024-02-01 - 2024-02-29\n\n<!-- [[[end]]] -->\n\nThese are equivalent (in May 2019):\n\n```sh\npypistats python_major pip --last-month\npypistats python_major pip --month april\npypistats python_major pip --month apr\npypistats python_major pip --month 2019-04\n```\n\nAnd:\n\n```sh\npypistats python_major pip --start-date december --end-date january\npypistats python_major pip --start-date dec      --end-date jan\npypistats python_major pip --start-date 2018-12  --end-date 2019-01\n```\n\n## Example programmatic use\n\nReturn values are from the JSON responses documented in the API:\nhttps://pypistats.org/api/\n\n```python\nimport pypistats\nfrom pprint import pprint\n\n# Call the API\nprint(pypistats.recent(\"pillow\"))\nprint(pypistats.recent(\"pillow\", \"day\", format=\"markdown\"))\nprint(pypistats.recent(\"pillow\", \"week\", format=\"rst\"))\nprint(pypistats.recent(\"pillow\", \"month\", format=\"html\"))\npprint(pypistats.recent(\"pillow\", \"week\", format=\"json\"))\nprint(pypistats.recent(\"pillow\", \"day\"))\n\nprint(pypistats.overall(\"pillow\"))\nprint(pypistats.overall(\"pillow\", mirrors=True, format=\"markdown\"))\nprint(pypistats.overall(\"pillow\", mirrors=False, format=\"rst\"))\nprint(pypistats.overall(\"pillow\", mirrors=True, format=\"html\"))\npprint(pypistats.overall(\"pillow\", mirrors=False, format=\"json\"))\n\nprint(pypistats.python_major(\"pillow\"))\nprint(pypistats.python_major(\"pillow\", version=2, format=\"markdown\"))\nprint(pypistats.python_major(\"pillow\", version=3, format=\"rst\"))\nprint(pypistats.python_major(\"pillow\", version=\"2\", format=\"html\"))\npprint(pypistats.python_major(\"pillow\", version=\"3\", format=\"json\"))\n\nprint(pypistats.python_minor(\"pillow\"))\nprint(pypistats.python_minor(\"pillow\", version=2.7, format=\"markdown\"))\nprint(pypistats.python_minor(\"pillow\", version=\"2.7\", format=\"rst\"))\nprint(pypistats.python_minor(\"pillow\", version=3.7, format=\"html\"))\npprint(pypistats.python_minor(\"pillow\", version=\"3.7\", format=\"json\"))\n\nprint(pypistats.system(\"pillow\"))\nprint(pypistats.system(\"pillow\", os=\"darwin\", format=\"markdown\"))\nprint(pypistats.system(\"pillow\", os=\"linux\", format=\"rst\"))\nprint(pypistats.system(\"pillow\", os=\"darwin\", format=\"html\"))\npprint(pypistats.system(\"pillow\", os=\"linux\", format=\"json\"))\n```\n\n### NumPy and pandas\n\nTo use with either NumPy or pandas, make sure they are first installed, or:\n\n```bash\npip install --upgrade \"pypistats[numpy]\"\npip install --upgrade \"pypistats[pandas]\"\npip install --upgrade \"pypistats[numpy,pandas]\"\n```\n\nReturn data in a NumPy array for further processing:\n\n```python\nimport pypistats\nnumpy_array = pypistats.overall(\"pyvista\", total=True, format=\"numpy\")\nprint(type(numpy_array))\n# <class 'numpy.ndarray'>\nprint(numpy_array)\n# [['with_mirrors' '2019-09-20' '2.23%' 1204]\n#  ['without_mirrors' '2019-09-20' '2.08%' 1122]\n#  ['with_mirrors' '2019-09-19' '0.92%' 496]\n#  ...\n#  ['with_mirrors' '2019-10-26' '0.02%' 13]\n#  ['without_mirrors' '2019-10-26' '0.02%' 12]\n#  ['Total' None None 54041]]\n```\n\nOr in a pandas DataFrame:\n\n```python\nimport pypistats\npandas_dataframe = pypistats.overall(\"pyvista\", total=True, format=\"pandas\")\nprint(type(pandas_dataframe))\n# <class 'pandas.core.frame.DataFrame'>\nprint(pandas_dataframe)\n#             category        date percent  downloads\n# 0       with_mirrors  2019-09-20   2.23%       1204\n# 1    without_mirrors  2019-09-20   2.08%       1122\n# 2       with_mirrors  2019-09-19   0.92%        496\n# 3       with_mirrors  2019-08-22   0.90%        489\n# 4    without_mirrors  2019-09-19   0.86%        466\n# ..               ...         ...     ...        ...\n# 354  without_mirrors  2019-11-03   0.03%         15\n# 355  without_mirrors  2019-11-16   0.03%         15\n# 356     with_mirrors  2019-10-26   0.02%         13\n# 357  without_mirrors  2019-10-26   0.02%         12\n# 358            Total        None    None      54041\n#\n# [359 rows x 4 columns]\n```\n\nFor example, create charts with pandas:\n\n```python\n# Show overall downloads over time, excluding mirrors\nimport pypistats\ndata = pypistats.overall(\"pillow\", total=True, format=\"pandas\")\ndata = data.groupby(\"category\").get_group(\"without_mirrors\").sort_values(\"date\")\n\nchart = data.plot(x=\"date\", y=\"downloads\", figsize=(10, 2))\nchart.figure.show()\nchart.figure.savefig(\"overall.png\")  # alternatively\n```\n\n![overall.png](example/overall.png)\n\n```python\n# Show Python 3 downloads over time\nimport pypistats\ndata = pypistats.python_major(\"pillow\", total=True, format=\"pandas\")\ndata = data.groupby(\"category\").get_group(3).sort_values(\"date\")\n\nchart = data.plot(x=\"date\", y=\"downloads\", figsize=(10, 2))\nchart.figure.show()\nchart.figure.savefig(\"python3.png\")  # alternatively\n```\n\n![python3.png](example/python3.png)\n\n## See also\n\nRelated projects\n\n- https://github.com/ofek/pypinfo\n- https://github.com/scivision/pypistats-plots\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python interface to PyPI Stats API https://pypistats.org/api",
    "version": "1.7.0",
    "project_urls": {
        "Changelog": "https://github.com/hugovk/pypistats/releases",
        "Homepage": "https://github.com/hugovk/pypistats",
        "Source": "https://github.com/hugovk/pypistats"
    },
    "split_keywords": [
        "bigquery",
        " pypi",
        " downloads",
        " statistics",
        " stats"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76c2de67f8558acf541a4aeae7e63a67bb48dabdfb4c3c38ca3b58220aa72eac",
                "md5": "70bddf86a6771dc1d2d338724ad9969c",
                "sha256": "5431c7db2a541b9304330d1e8896fb9ebddb2615bdf8659f4117f3f55d6d2655"
            },
            "downloads": -1,
            "filename": "pypistats-1.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70bddf86a6771dc1d2d338724ad9969c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 13297,
            "upload_time": "2024-10-15T21:31:31",
            "upload_time_iso_8601": "2024-10-15T21:31:31.985221Z",
            "url": "https://files.pythonhosted.org/packages/76/c2/de67f8558acf541a4aeae7e63a67bb48dabdfb4c3c38ca3b58220aa72eac/pypistats-1.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa268f8ee01c02969f486666b8c9a458d9e851dfe5db07bbca3d3ab72e9da1d1",
                "md5": "ffad8efe6cc0d729b73b71b7bd102c48",
                "sha256": "dbd5ebaf0f0769eab42ee21c4bf183e4f5ca78292fdaf92a2fa4893ebc57a9f5"
            },
            "downloads": -1,
            "filename": "pypistats-1.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ffad8efe6cc0d729b73b71b7bd102c48",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 122211,
            "upload_time": "2024-10-15T21:31:33",
            "upload_time_iso_8601": "2024-10-15T21:31:33.791733Z",
            "url": "https://files.pythonhosted.org/packages/fa/26/8f8ee01c02969f486666b8c9a458d9e851dfe5db07bbca3d3ab72e9da1d1/pypistats-1.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 21:31:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hugovk",
    "github_project": "pypistats",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "freezegun",
            "specs": [
                [
                    "==",
                    "1.5.1"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    "==",
                    "0.27.2"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "2.1.1"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.2.3"
                ]
            ]
        },
        {
            "name": "platformdirs",
            "specs": [
                [
                    "==",
                    "4.3.6"
                ]
            ]
        },
        {
            "name": "prettytable",
            "specs": [
                [
                    "==",
                    "3.11.0"
                ]
            ]
        },
        {
            "name": "pytablewriter",
            "specs": [
                [
                    "==",
                    "1.2.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.3.3"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "5.0.0"
                ]
            ]
        },
        {
            "name": "python-slugify",
            "specs": [
                [
                    "==",
                    "8.0.4"
                ]
            ]
        },
        {
            "name": "respx",
            "specs": [
                [
                    "==",
                    "0.21.1"
                ]
            ]
        },
        {
            "name": "termcolor",
            "specs": [
                [
                    "==",
                    "2.4.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "pypistats"
}
        
Elapsed time: 0.33416s