fmenabe / pypi-stats

Simple tool for displaying downloads of PyPI packages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pypi-stats

Simple tool that shows PyPI downloads of packages by retrieving data from Google BigQuery and the [the-psf:pypi.downloads] public dataset.

Creating a service account for using BigQuery

This is probably the hardest part!

You need to:

  1. Go to the Google API console
  2. Go to credentials and create new credentials. If you don't already have a project, you will be asked to create one (the name of the project is not really important)
  3. Create a Service Account key with the BigQuery Job User role (again the name is not really important). It will ask you to download the JSON file you need to authenticate to BigQuery.

Note: Take care that free usage of BigQuery is limited and it is easy to exceed quota!

Installation

pip install pypi-stats

Examples

Downloads since the start of the month::

pypi-stats -t TOKENPATH.json yamlordereddictloader clg
┌───────────────────────┬─────────┬─────┬──────┬───────┐
│ Name                  │ Version │ Day │ Week │ Month │
├───────────────────────┼─────────┼─────┼──────┼───────┤
│ clg                   │ 2.0.0   │ 2   │ 37   │ 37    │
│ clg                   │ *       │ 2   │ 37   │ 37    │
├───────────────────────┼─────────┼─────┼──────┼───────┤
│ yamlordereddictloader │ 0.4.0   │ 42  │ 399  │ 399   │
│ yamlordereddictloader │ 0.3.0   │ -   │ 24   │ 24    │
│ yamlordereddictloader │ 0.2.2   │ 1   │ 12   │ 12    │
│ yamlordereddictloader │ 0.1.1   │ -   │ 31   │ 31    │
│ yamlordereddictloader │ 0.1.0   │ -   │ 14   │ 14    │
│ yamlordereddictloader │ *       │ 43  │ 480  │ 480   │
└───────────────────────┴─────────┴─────┴──────┴───────┘

Downloads since the start of the year:

pypi-stats -t TOKENPATH.json --year clg
┌───────────────────────┬─────────┬─────┬──────┬───────┬──────┐
│ Name                  │ Version │ Day │ Week │ Month │ Year │
├───────────────────────┼─────────┼─────┼──────┼───────┼──────┤
│ clg                   │ 2.3.1   │ -   │ 3    │ -     │ 14   │
│ clg                   │ 2.3.0   │ -   │ -    │ -     │ 8    │
│ clg                   │ 2.0.0   │ 2   │ 77   │ 37    │ 537  │
│ clg                   │ *       │ 2   │ 80   │ 37    │ 559  │
└───────────────────────┴─────────┴─────┴──────┴───────┴──────┘

Save statistics in a JSON file:

pypi-stats -t TOKENPATH.json --format json --output-file stats.json yamlordereddictloader clg

Re-use the JSON file to show statistics:

pypi-stats --file stats.json
┌───────────────────────┬─────────┬─────┬──────┬───────┐
│ Name                  │ Version │ Day │ Week │ Month │
├───────────────────────┼─────────┼─────┼──────┼───────┤
│ clg                   │ 2.0.0   │ 2   │ 37   │ 37    │
│ clg                   │ *       │ 2   │ 37   │ 37    │
└───────────────────────┴─────────┴─────┴──────┴───────┘

About

Simple tool for displaying downloads of PyPI packages.

License:MIT License


Languages

Language:Python 100.0%