在Github中,是否有一种方法可以让我看到回购的下载数量?


当前回答

我创建了三个解决方案来获取GitHub版本的下载计数和其他统计数据。这些实现都能够累积GitHub API分页结果,这意味着计算总的下载数量将不是一个问题。

Web应用程序

https://qwertycube.com/github-release-stats/ 可作为PWA使用 支持GitHub API分页

node . js实现

https://github.com/kefir500/github-release-stats 可通过NPM获取 用TypeScript编写,编译成JavaScript 可以用作命令行工具吗 可以作为Node.js模块使用吗 可以在浏览器环境中使用吗 支持GitHub API分页

Python实现

https://github.com/kefir500/ghstats 可通过PyPI获得 可以用作命令行工具吗 可以作为Python模块使用吗 支持GitHub API分页

其他回答

为了更清楚地说明这一点: 对于这个github项目:stant/ mdcsvimportter2015 https://github.com/stant/mdcsvimporter2015 在 https://github.com/stant/mdcsvimporter2015/releases

转到HTTP或https:(注意添加了“api.”和“/repos”) https://api.github.com/repos/stant/mdcsvimporter2015/releases

你会得到这个json输出,你可以搜索"download_count":

    "download_count": 2,
    "created_at": "2015-02-24T18:20:06Z",
    "updated_at": "2015-02-24T18:20:07Z",
    "browser_download_url": "https://github.com/stant/mdcsvimporter2015/releases/download/v18/mdcsvimporter-beta-18.zip"

或者在命令行执行: Wget——no-check-certificate https://api.github.com/repos/stant/mdcsvimporter2015/releases

这里是一个使用pip install PyGithub包的python解决方案

from github import Github
g = Github("youroauth key") #create token from settings page


for repo in g.get_user().get_repos():
    if repo.name == "yourreponame":
        releases = repo.get_releases()
        for i in releases:
            if i.tag_name == "yourtagname":
                for j in i.get_assets():
                    print("{} date: {} download count: {}".format(j.name, j.updated_at, j._download_count.value))

如前所述,GitHub API返回二进制文件发布的下载计数。我开发了一个小脚本,通过命令行轻松获得下载计数。

新的实现:

移植到GitHub组合动作重用工作流代码基。

https://github.com/andry81-devops/github-accum-stats

附加功能:

可以计数流量克隆或/和视图。 可以使用GitHub复合动作重用工作流代码基:https://docs.github.com/en/actions/creating-actions/creating-a-composite-action

GitHub工作流文件示例:

.github /工作流/ accum-gh-clone-stats.yml


以前的实现(标记为obsolete):

此实现基于GitHub Actions +统计累加到单独的存储库:https://github.com/andry81-devops/github-clone-count-badge

基于:https://github.com/MShawon/github-clone-count-badge

有一些优点:

用于跟踪的存储库和用于存储流量统计数据的存储库是不同的,您可以直接将统计数据指向提交列表:https://github.com/{{REPO_OWNER}}/{{REPO}}--gh-stats/commits/master/traffic/clones 工作流使用aac -traffic-clone .sh bash脚本积累流量克隆 脚本将统计数据累加到单个文件和一组按年分组并每天分配的文件中:traffic/克隆/by_year/YYYY/YYYY- mm - dd .json

GitHub工作流文件示例:

.github /工作流/ myrepo-gh-clone-stats.yml

很晚了,但这是你想要的答案:

https://api.github.com/repos/ [git username] / [git project] /releases

接下来,在数据中找到您要查找的项目的id。它应该在顶部附近,在url旁边。然后,导航到

https://api.github.com/repos/ [git username] / [git project] /releases/ [id] / assets

名为download_count的字段就是答案。

编辑:在你的用户名和项目名中大写字母很重要