在 Github 中,有没有一种方法可以查看存储库的下载次数?
更新2019年:
/repos/:owner/:repo/traffic/clones
, 用于获取克隆总数和每天或每周的详细信息,但是:只能获取最近14天的数据。/repos/:owner/:repo/releases/:release_id
,用于获取您的资产(附加到发布的文件)的下载数量,下面提到的字段download_count
,但是,as commented,仅适用于最近的30个发布版本..2017年更新
您仍然可以使用GitHub API来获取您的发布版的下载次数(这不完全是所要求的)
请参阅 "获取单个版本",其中包含download_count
字段。
不再有显示存储库克隆数量的流量屏幕。
相反,您必须依赖第三方服务,例如:
GitItBack(位于www.netguru.co/gititback
),但即使如此也不包括克隆数量。
www.somsubhra.com/github-release-stats(Web存档),在below中提到。
例如,这是latest git for Windows release的数量。
2014年8月更新
GitHub在其Traffic图表中还提供了repo克隆的数量:
请参见 "Clone Graphs"。
2013年10月更新
如下面所述,由andyberry88提到,并且如我去年七月详细说明的那样,GitHub现在提出发布(请参见其API),其中包含一个download_count
字段。
Michele Milidoni在他的(得到赞同的)答案中使用了该字段在他的Python脚本中。(非常小的摘录)
c.setopt(c.URL, 'https://api.github.com/repos/' + full_name + '/releases')
for p in myobj:
if "assets" in p:
for asset in p['assets']:
print (asset['name'] + ": " + str(asset['download_count']) +
" downloads")
原始回答(2010年12月)
我不确定您是否可以查看该信息(如果有记录的话),因为我在GitHub存储库API中没有看到它:
$ curl http://github.com/api/v2/yaml/repos/show/schacon/grit
---
repository:
:name: grit
:owner: schacon
:source: mojombo/grit # The original repo at top of the pyramid
:parent: defunkt/grit # This repo's direct parent
:description: Grit is a Ruby library for extracting information from a
git repository in an object oriented manner - this fork tries to
intergrate as much pure-ruby functionality as possible
:forks: 4
:watchers: 67
:private: false
:url: http://github.com/schacon/grit
:fork: true
:homepage: http://grit.rubyforge.org/
:has_wiki: true
:has_issues: false
:has_downloads: true
您只能看到它是否已经下载。
I got it to work with
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/:user/:repo/releases
A couple of things that I had wrong:
- I needed an actual Github release (not just git tag, even though Github does display those under releases, ugh).
- And the release needs an asset file other than the zipped source that is added automatically in order to get the download count.
download_count
字段,那应该包括发布下载次数(这些下载不总是 zip 格式,也不是克隆)。 - VonCgit clone
的实例。请向GitHub支持团队确认。 - VonC在你的仪表板>流量(或统计信息或见解)下应该提供访问者计数:
GitHub已经弃用了下载支持,现在支持'Releases' - https://github.com/blog/1547-release-your-software。要创建一个发布,请使用GitHub UI或创建一个带有注释的标签 (http:// git-scm.com/book/ch2-6.html),并将发布说明添加到GitHub中。然后,您可以上传二进制文件或“资产”到每个发布。
一旦您拥有了一些发布版本,GitHub API支持获取关于它们及其资源的信息。
curl -i \
https://api.github.com/repos/:owner/:repo/releases \
-H "Accept: application/vnd.github.manifold-preview+json"
寻找'download_count'入口。 在http://developer.github.com/v3/repos/releases/有更多信息。该API的这部分仍处于预览期,因此可能会发生更改。
GitHub 的发布 API 现已超出预览期,因此不再需要 'Accept' 标头 - http://developer.github.com/changes/2013-11-04-releases-api-is-official/
继续添加 'Accept' 标头也不会有任何影响。
download_count
是指示下载次数的字段 - 例如在 https://api.github.com/repos/twbs/bootstrap/releases 中。
值得注意的是,只有“发布”才会显示在此列表中,出现在存储库发布页面中的标签不会出现在API列表中,请参见https://developer.github.com/v3/repos/releases/。例如,https://github.com/jquery/jquery/releases 在发布部分下列出了几个标签,但是在 https://api.github.com/repos/jquery/jquery/releases 中返回了一个空列表。 - andyberry88count=0
就省略了该字段)?还是只显示 Clone 请求的字段?请参见此处,其中没有 download_count
:https://api.github.com/repos/demisjohn/pytrimsetup/releases。该页面的 GitHub 页面在此处:https://github.com/demisjohn/pyTRIMSetup/releases。 - Demisdownload_count
字段相关的bootstrap-XYZ-dist.zip
资产。如果您想查看有多少人正在下载发布版,则需要上传发布版zip文件。据我所知,没有办法通过API查看有多少人克隆/下载了存档。但是,从上面的https://dev59.com/c2855IYBdhLWcg3wcz5h#4339085中的图形视图可能会给您想要的结果。 - andyberry88如前所述,GitHub API 返回二进制文件发布的下载次数。我开发了一个小脚本来通过命令行轻松获取下载次数。
https://api.github.com/repos/ [git username] / [git project] /releases
接下来,在数据中找到你要查找的项目的id。它应该在靠近顶部的位置,紧挨着urls旁边。然后,导航到
https://api.github.com/repos/ [git username] / [git project] /releases/ [id] / assets
下载次数字段就是你要找的答案。
编辑:用户名和项目名中的大写字母很重要。
{ "message": "Not Found", "documentation_url": "https://developer.github.com/v3" }
- Sentry.co我已经检查了其他问题的一些解决方案。 Vonc的答案提供了Michele Milidoni的解决方案的重要部分。我安装了他的GDC脚本,并得到了以下结果。
# ./gdc stant
mdcsvimporter.mxt: 37 downloads
mdcsvimporter.mxt: 80 downloads
How-to-use-mdcsvimporter-beta-16.zip: 12 downloads
显然,gdc没有报告tar.gz和zip文件的下载次数。
如果您想在不安装任何内容的情况下进行检查,请尝试网页,Somsubhra在其中安装了解决方案,如他的回答中所提到的。在Github用户名中填入'stant',在Repository名称中填入'mdcsvimporter2015',您将看到以下信息:
Download Info:
mdcsvimporter.mxt(0.20MB) - Downloaded 37 times.
Last updated on 2015-03-26
哎呀,又是一份没有tar.gz和zip文件下载的报告。我仔细研究了Github API返回的信息,但它并没有提供这些文件的下载链接。现在API返回的download_count也远远不完整。
tar.gz
和zip
文件)的下载统计信息。 - Allen Luce