badgen.net icon indicating copy to clipboard operation
badgen.net copied to clipboard

Downloads total is not correct

Open tunnckoCore opened this issue 5 years ago • 7 comments

Recently I'm digging more and more around the statistics of my most (that I know) used packages, and seeing that the downloads badge isn't showing correct information. Not sure if it's only the total downloads badge though.

For example, the badge https://badgen.net/npm/dt/formidable for formidable is showing 170M, but it's around 312M - https://twitter.com/tunnckoCore/status/1225150205982662657.

Today I'm seeing such mismatches with koa-better-body (600K, shows 329K), parse-function (2.7M, shows 35K) and get-installed-path is most close (2.1M, shows 1.7), and more. I'm looking on https://npm-stat.com

I can look around when get some time.

tunnckoCore avatar Feb 06 '20 17:02 tunnckoCore

Hmm, what's the source for 312M counts? We are counting it from registry api https://github.com/badgen/badgen.net/blob/75a2cabbbfc194b434389108d11a075105b03269/api/npm.ts#L121-L136

amio avatar Feb 07 '20 13:02 amio

I don't know, it's from npm-stat.com, we should check how they are doing it :)

tunnckoCore avatar Feb 07 '20 14:02 tunnckoCore

Seems like they are crawling the npmjs.com site

https://github.com/pvorb/npm-stat.com/blob/develop/src/main/js/charts.js

tunnckoCore avatar Feb 07 '20 15:02 tunnckoCore

The NPM API returns the last 18 months as the maximum range - you'll need to do multiple queries for each 18 month period.

wopian avatar Feb 07 '20 16:02 wopian

Oooh, cool insight @wopian ! :)

tunnckoCore avatar Feb 07 '20 18:02 tunnckoCore

The NPM API returns the last 18 months as the maximum range - you'll need to do multiple queries for each 18 month period.

In addition, it looks like the api reports data starting from 2015-1-10 (not 2005-1-1): https://api.npmjs.org/downloads/range/2000-1-1:2015-1-31/express

amio avatar Feb 10 '20 07:02 amio

Download counts before 2015-2-27 is lost:

https://api.npmjs.org/downloads/range/2000-1-1:2015-12-31/express (born in 2010) https://api.npmjs.org/downloads/range/2000-1-1:2015-12-31/npm (hits 1.0 in 2011)

amio avatar Feb 10 '20 07:02 amio