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


当前回答

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

其他回答

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

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

基于VonC和Michele Milidoni的答案,我创建了这个bookmarklet,它显示了github托管发布的二进制文件的下载统计数据。

注意:由于浏览器与内容安全策略实现相关的问题,bookmarklet可能会暂时违反一些CSP指令,并且在启用CSP时在github上运行时基本可能无法正常工作。

虽然这是非常不鼓励的,你可以禁用CSP在Firefox作为 临时的解决方案。打开about:config并设置security.csp.enable 为假。

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