npm / download-counts

Background jobs and a minimal service for collecting and delivering download counts
329 stars 27 forks source link

Total download counts #34

Closed paulmelnikow closed 7 years ago

paulmelnikow commented 7 years ago

I'm a maintainer for Shields, which has long offered a lifetime total download badge for npm packages. Recently these badges stopped working, and judging from the number of people who have noticed, they are popular.

From a human perspective this makes sense. Counting a package's lifetime total downloads is a good way to motivate open-source maintainers!

https://img.shields.io/npm/dt/jquery.svg is rendering

The implementation was making requests like these:

https://api.npmjs.org/downloads/range/1000-01-01:3000-01-01/jquery

Admittedly, this was a bit of a hack. After a change by npm, these requests are now returning {"error":"exceeded max days of 365"}

Could you relax this requirement? Could you provide another way to get the lifetime total through the API?

bcoe commented 7 years ago

@paulmelnikow this should be fixed now; not quite sure why downloads 0 is still being rendered?

paulmelnikow commented 7 years ago

It is fixed indeed, thank you for addressing it so quickly!

Here is the live badge for https://img.shields.io/npm/dt/jquery.svg

Are you considering adding a shortcut endpoint to get the lifetime total?

seldo commented 7 years ago

Iiiiit's complicated. We don't really have lifetime totals; stats in the current system go back to 2015 and even the oldest stats we have, currently sitting on ice in a backup file, start in early 2014. For the oldest packages there's just no such thing.

But of course, 66% of packages were created since 2015, so for a majority of packages there is now a meaningful lifetime downloads number. We've got a couple things planned for v3 of this API, and a specific endpoint for all-time stats will probably be in there. But it took us 2 years to ship v2, so don't hold your breath :-)

paulmelnikow commented 7 years ago

Gotcha. Thanks! And thanks for you all your work on npm!