Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show combined download counts for multiple packages? #4964

Closed
FezVrasta opened this issue Apr 28, 2020 · 6 comments
Closed

Show combined download counts for multiple packages? #4964

FezVrasta opened this issue Apr 28, 2020 · 6 comments
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas

Comments

@FezVrasta
Copy link
Contributor

Question

Hi, is there any way to have a badge to display the combined downloads count of multiple npm packages? We changed package name and we'd like to show the total downloads rather than having two different badges (or worse, just one)

@FezVrasta FezVrasta added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Apr 28, 2020
@paulmelnikow
Copy link
Member

Hi! Thanks for the question. Something similar was requested for NuGet a few years back in #204 and our suggested workaround is to use the Endpoint badge, which is a way you can write your own badge data fetching logic, emit JSON, and then use Shields for formatting, rendering, and caching. It's hard to bound the number of requests or request time for a badge like this, so I think the Endpoint badge is probably a good way to accomplish this.

@FezVrasta
Copy link
Contributor Author

I see, I'll try with the RunKit + Endpoint badge solution then, thanks!

@FezVrasta
Copy link
Contributor Author

FezVrasta commented Apr 29, 2020

For anyone interested, I published an endpoint here:

https://runkit.io/fezvrasta/combined-npm-downloads/1.0.0

You can use it as follows:

https://img.shields.io/endpoint?style=for-the-badge&url=https://runkit.io/fezvrasta/combined-npm-downloads/1.0.0?packages=popper.js,@popperjs/core

demo

Docs:

https://runkit.io/fezvrasta/combined-npm-downloads/1.0.0?packages=<pkg1>,<pkg2>,<pkg3>&period=<period>
  • packages is a comma separated list of npm packages;
  • period is last-week, last-month, last-day, and all the other standard npm periods;

@thetarnav
Copy link

@FezVrasta
I just dug this thread up, and your solution seems to work the best.
But is seems to be a little bit broke currently. Adding &period=last-week at the end of the URL changes the download amount but the caption remains the same — "123K/MONTH".
Would you mind sharing the runkit source code, or correcting the message text?

@FezVrasta
Copy link
Contributor Author

https://runkit.com/FezVrasta/combined-npm-downloads

@thetarnav
Copy link

thetarnav commented Jun 14, 2022

Thank you :)
This is my take on it then: https://runkit.com/thetarnav/combined-weekly-npm-downloads
And one deployed on deno: https://dash.deno.com/playground/combined-npm-downloads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas
Projects
None yet
Development

No branches or pull requests

3 participants