mjackson / unpkg

The CDN for everything on npm
https://unpkg.com
Other
2.98k stars 302 forks source link

Badges for package download count #250

Open joeldenning opened 4 years ago

joeldenning commented 4 years ago

One thing I like about jsdelivr is that it hosts images to be used as badges within Readmes for projects that show the number of monthly downloads for a particular npm package. See example below:

Does this exist in unpkg? Is it something you'd be open to adding? I would be happy to help out with the implementation of it.

mjackson commented 4 years ago

We would first have to build out some infra to track download counts for certain packages, which we don't currently do. I've experimented before with automatically importing all our logs into Google BigQuery (we're hosted on GCP) but there was just too much data and my costs ran too high.

I think if I were to attempt doing something like this again I'd probably:

Once that's built, we can provide an API on top that queries Redis and gives you the count. The actual badge should be pretty easy to make once you have the number.

mjackson commented 4 years ago

Side note: we used to track all this when unpkg was hosted on Heroku, and I used a Redis instance for it then. It worked well enough, but I never ported the service over to GCP when I switched hosting providers.

joeldenning commented 4 years ago

Ah I didn't know that download counts were not already available. That makes it a lot harder.

maraisr commented 3 years ago

@mjackson is this something I can help bring to fruition?