34

I've got a couple of packages on the Python Package Index (PyPI) now. Is there any way to get hold of statistics as to how many times they have been downloaded (either manually or via easy_install or pip?

Or, alternatively, how many views the main package page has received?

robintw
  • 27,571
  • 51
  • 138
  • 205

10 Answers10

26

There are at least two packages that help with this: pypstats and vanity. Vanity is very easy to use from the command line:

vanity numpy 

and you'll get a printout to your console.

askewchan
  • 45,161
  • 17
  • 118
  • 134
pastephens
  • 399
  • 3
  • 5
15

I have tried the different methods in the other answers. As far as I am concerned, vanity does not work anymore, the reason is here. Pip statistics are not available on pypi.python.org website, the reason is mention in the Python Packaging Guide together with a detailed guide on how you can analyze PyPI download using Google Big Query (summarized below in this answer).

There are 2 methods which are still available.

PyPIstats.org

First method is easier than the second one but seems less reliable as it sometimes returns 429 RATE LIMIT EXCEEDED

  1. Go to pypistats.org;
  2. search the package name;
  3. get the statistics of its download. The following figure is the results of numpy. enter image description here

Google Big Query

Second method is Google Big Query, recommended by PiPy officially.

  1. Go to https://bigquery.cloud.google.com/dataset/the-psf:pypi
  2. Copy the following code into the editor window.
SELECT
  details.installer.name,
  COUNT(*) as download_count,
FROM `the-psf.pypi.downloads*`
WHERE
file.project = 'dvc'
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE('%Y%m%d', DATE('2020-01-04'))
AND FORMAT_DATE('%Y%m%d', DATE('2020-02-04'))
GROUP BY details.installer.name
  1. Click run button, get the results. The following 2 figures show the code and results of numpy.
    code results

Please noter that the second method requires you have a google cloud account, and require you to provide your credict card information, and has limited query times every day. So I personally recommend the first method.

joelostblom
  • 43,590
  • 17
  • 150
  • 159
Jingnan Jia
  • 1,108
  • 2
  • 12
  • 28
  • Note that pypistats.org seems to offer download statistics from the last six months only. – AstroFloyd Aug 23 '22 at 12:20
  • Note also that Google's BigQuery is available without credit card in [some cases](https://cloud.google.com/blog/products/data-analytics/query-without-a-credit-card-introducing-bigquery-sandbox). – AstroFloyd Aug 23 '22 at 12:51
9

Pip statistics is not available on pypi.python.org website and vanity package does not work as well.

Today you can get pip statistics only through this dataset in BigQuery: https://bigquery.cloud.google.com/dataset/the-psf:pypi

Query example for https://pypi.python.org/pypi/dvc package:

SELECT
  details.system.name,
  COUNT(*) as download_count,
FROM
  TABLE_DATE_RANGE(
    [the-psf:pypi.downloads],
    DATE_ADD(CURRENT_TIMESTAMP(), -31, "day"),
    DATE_ADD(CURRENT_TIMESTAMP(), -1, "day")
  )
WHERE
  file.project = 'dvc'
GROUP BY details.system.name

Please note, some of the download signals are generated by monitoring tools and should not be counted as user's downloads. For example, you should exclude null values from the output:

Row details_system_name download_count   
1   Darwin  1111     
2   null    10000    
3   Windows 222  
4   Linux   3333     
Dmitry Petrov
  • 1,490
  • 1
  • 19
  • 34
  • 1
    The link you provide doesn't seem to work anymore (unable to find dataset error). – CiaranWelsh Apr 18 '18 at 13:57
  • I've just checked - it seems to work. You need to click "Compose Query" and copy\paste the select statement from the above. – Dmitry Petrov Apr 19 '18 at 05:21
  • 2
    It only works if you are currently a Google BigQuery customer, with an account that has been verified by providing your card details. The service is however free - you are not charged. – CiaranWelsh Apr 20 '18 at 08:34
  • 1
    I cant believe how hard it is to obtain such simple statistic, thanks for the answer, this was the only thing that worked – Borislav Stoilov Aug 26 '19 at 11:33
  • This answer is so useful that it should be marked as Protected for the community – Shadi Sep 11 '19 at 08:38
  • 2
    These downloads can be further filtered with `details.installer.name` to ignore downloads by [bandersnatch](https://github.com/pypa/bandersnatch), which is a mirroring tool. – Shadi Sep 11 '19 at 14:31
  • 2
    The Big Query link seems not work anymore. Waring: "The Classic UI has been decomissioned as of October 1st. Go to Google Cloud Console". After I enter the Google Cloud Console, the code above does not works. Error: "Table-valued function not found: TABLE_DATE_RANGE at [5:3]" – Jingnan Jia Oct 18 '20 at 23:40
  • Seconding @JingnanJia here. Same observation.l – Bernd Wechner Nov 21 '21 at 05:25
9

https://pepy.tech/ will show information on the number of downloads and trends over time.

enter image description here

joelostblom
  • 43,590
  • 17
  • 150
  • 159
6

UPDATE 2: it's back! There's now a "Downloads (All Versions)" just after the list of downloads (below the user-supplied docs).

announcement at http://mail.python.org/pipermail/distutils-sig/2013-June/021344.html - it's currently daily counts; weeks and months will be added as they become available. but, curiously, no total.

UPDATE: this no longer works (the info is not displayed) - see http://mail.python.org/pipermail/distutils-sig/2013-May/020855.html (unfortunately this affects the other answer too).

maybe i'm misunderstanding (sorry) but i think this is on the pypi main page for your project!

see updates above for latest details (i've deleted info below that's no longer correct).

andrew cooke
  • 45,717
  • 10
  • 93
  • 143
  • I can't believe I didn't notice that! Doh! Do you happen to know if that includes downloads when it was installed via `pip install xxx`? – robintw Apr 30 '12 at 07:58
  • i don't know for sure, but i would guess so - that seems to just use http to grab things. – andrew cooke Apr 30 '12 at 11:25
  • Maybe I'm just being dumb, but I don't see the "# downloads" column at all when I look at that page... – Crowman Jun 02 '13 at 22:45
  • see the UPDATE i added 4 hours before your comment? – andrew cooke Jun 03 '13 at 01:38
  • Aha! So *that's* the "this" that no longer works. I don't know whether to feel more or less dumb, now ;) – Crowman Jun 03 '13 at 04:29
  • I could not found the "Downloads (All Versions)" (7.7.21). I only found: View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery for example: https://pypi.org/project/numpy/ – Eli Simhayev Jul 07 '21 at 12:14
2

There is a site which I found: https://pypistats.org/packages/py3-pinterest

They track downloads but only for 1 day, 1 week and 1 month. @Dmitry Petrov's answer is better though.

Borislav Stoilov
  • 3,247
  • 2
  • 21
  • 46
2

You can now use the pypistats website to check your statistics.

For the pytest package: https://pypistats.org/packages/pytest

The figures are coherent with the bigquery's ones. For instance for day 13-04: 501685 downloads without mirror.

Using request :

#standardSQL
SELECT
  COUNT(*) AS num_downloads,
  SUBSTR(_TABLE_SUFFIX, 7, 8) AS `day`
FROM `the-psf.pypi.downloads*`
WHERE file.project = 'pytest'
  AND _TABLE_SUFFIX
    BETWEEN FORMAT_DATE(
      '%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 10 DAY))
    AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
GROUP BY `day`
ORDER BY `day`
BlueSheepToken
  • 5,751
  • 3
  • 17
  • 42
2

you can use this website for statistics - https://pypistats.org/

if you want to use it in a script you can use the api -

https://pypistats.org/api/packages/{package_name}/recent

Tal Folkman
  • 2,368
  • 1
  • 7
  • 21
1

If you like to filter the data and check all downloads per installer run:

SELECT
  details.installer.name,
  COUNT(*) as download_count,
FROM `the-psf.pypi.downloads*`
WHERE
file.project = 'dvc'
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE('%Y%m%d', DATE('2020-01-04'))
AND FORMAT_DATE('%Y%m%d', DATE('2020-02-04'))
GROUP BY details.installer.name

So you should see all the installers for e.g: enter image description here

For more information check useful-queries

Zoran Pandovski
  • 2,312
  • 14
  • 24
0

I came across https://www.piwheels.org which shows how many downloads a PyPi library has had. Just add the library you are checking to the end of this url e.g. numpy

https://www.piwheels.org/project/numpy/

enter image description here

Christopher
  • 427
  • 1
  • 8
  • 18