ghcr-badge icon indicating copy to clipboard operation
ghcr-badge copied to clipboard

Total pulls count

Open kroese opened this issue 1 year ago • 5 comments

It would be nice to have a badge that display the total pulls count, like is possible with Dockerhub badges. I dont know if GHCR provides this information, or that it is only available per image. In that case the badge would need to sum up all values, but that might be too resource-intensive.

kroese avatar Apr 29 '23 23:04 kroese

It can be fetched with not Docker Registry API but GitHub GraphQL API.

https://docs.github.com/en/graphql/reference/objects#packagestatistics

https://docs.github.com/en/graphql/reference/objects#packageversionstatistics

But I think it is out of scope this badge service for now. If you want to use this feature, please send your PR. I'll welcome.

eggplants avatar May 01 '23 10:05 eggplants

This will be awesome!

zhilyaev avatar Jun 17 '23 12:06 zhilyaev

+1 for this feature, most of the users of my images prefer to use GHCR than Docker Hub, the number of downloads is almost surpassing Docker Hub's.

razonyang avatar Jul 19 '23 09:07 razonyang

It can be fetched with not Docker Registry API but GitHub GraphQL API.

https://docs.github.com/en/graphql/reference/objects#packagestatistics

https://docs.github.com/en/graphql/reference/objects#packageversionstatistics

GraphQL Query for repo packages seems dead due to deprecation. https://github.blog/changelog/2022-08-18-deprecation-notice-graphql-for-packages/

And I confirmed these queries are currently not working.

image

Sadly, there does not seem to be a replacement for PackageVersionStatistics in the REST API. https://docs.github.com/en/free-pro-team@latest/rest/packages/packages?apiVersion=2022-11-28

eggplants avatar Aug 04 '23 18:08 eggplants

What about parsing HTML other than using API as a provisional solution?

razonyang avatar Dec 14 '23 06:12 razonyang

This now implemented in: https://github.com/ipitio/badpack

kroese avatar Jun 20 '24 07:06 kroese