在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分页

其他回答

这里是一个使用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))

我做了一个web应用程序,以干净的格式显示GitHub发布的统计数据: https://hanadigital.github.io/grev/

2019年的答案:

对于克隆的数量,您可以使用https://developer.github.com/v3/repos/traffic/#clones(但请注意,它只返回过去14天的计数) 为了获得你的资产(附加到发行版的文件)的下载数量,你可以使用https://developer.github.com/v3/repos/releases/#get-a-single-release(确切地说,是资产列表项的“download_count”属性作为响应)

为了更清楚地说明这一点: 对于这个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

我用javascript写了一个小的web应用程序,用于显示Github上任何项目可用版本中所有资产的下载数量。您可以在这里试用该应用程序:http://somsubhra.github.io/github-release-stats/