在Github中,是否有一种方法可以让我看到回购的下载数量?
当前回答
GitHub已经弃用下载支持,现在支持“发布”- 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仍然处于预览期,所以可能会有变化。
2013年11月更新:
GitHub的发布API现在已经过了预览期,因此不再需要'Accept'标头- http://developer.github.com/changes/2013-11-04-releases-api-is-official/
不过,继续添加'Accept'标头不会造成任何伤害。
其他回答
2019年更新:
Ustin的答案是:
API /repos/:owner/:repo/traffic/克隆,以获得每天或每周的克隆总数和崩溃,但是:仅为过去14天。 API /repos/:owner/:repo/releases/:release_id用于获取资产的下载数量(附加到发布的文件),下面提到的字段download_count,但是,正如评论所述,仅针对最近的30个版本。
更新2017
你仍然可以使用GitHub API来获得你的版本的下载计数(这不是确切的要求) 参见“Get a single release”,download_count字段。
不再有流量屏幕提到回购克隆的数量。 相反,你必须依赖第三方服务,比如:
GitItBack(网址:www.netguru.co/gititback),但这还不包括克隆的数量。 githubstats0,下面由Aveek Saha提到。 www.somsubhra.com/github-release-stats(网络档案),如下所述。 例如,这是Windows版本的最新git的编号
2014年8月更新
GitHub还在其流量图中提出了用于回购的克隆数量: 参见“克隆图形”
2013年10月更新
正如下面andyberry88所提到的,正如我去年7月所详细描述的,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
你只能看到它是否有下载。
Adam Jagosz在评论中报道:
我用它来工作 curl -H "Accept: application/vnd.github。v3 + json " https://api.github.com/repos/:用户/:回购/版本 我做错了几件事: 我需要一个实际的Github发布(不仅仅是git标签,即使Github确实显示这些下发布,额)。 发行版需要一个资产文件,而不是自动添加的压缩源代码,以便获得下载计数。
如前所述,您可以通过API获得有关您的版本的信息。
对于那些使用WordPress的人,我开发了这个插件:GitHub Release Downloads。它可以让你获得下载计数,链接和更多的信息发布GitHub存储库。
为了解决最初的问题,短代码[grd_count user=" user " repo="MyRepo"]将返回存储库的下载数量。这个数字对应于一个GitHub存储库的所有版本的所有下载计数值的总和。
例子:
访问者数量应该可以在你的仪表板>流量(或统计数据或见解):
这里是一个使用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项目: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
推荐文章
- Github:我能看到回购的下载数量吗?
- 如何运行一个github-actions步骤,即使前一步失败,同时仍然失败的工作
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 在GitHub repo上显示Jenkins构建的当前状态
- 如何取消在github上的拉请求?
- HEAD和master的区别
- 在另一个目录中运行操作
- GitHub克隆与OAuth访问令牌
- 我可以在GitHub上对要点进行拉请求吗?
- Git:在推送后删除提交的文件
- 在GitHub中编辑git提交消息
- Github:导入上游分支到fork
- GitHub上的分叉和克隆有什么区别?
- 如何将现有的解决方案从Visual Studio 2013添加到GitHub
- 是否可以在GitHub上搜索特定的文件名?