GitHub API - 如何获取“问题数量”谷歌表格从私人GitHub回购? [英] GitHub API - how to get "amount of issues" to Google Sheets from private GitHub repo?

查看:183
本文介绍了GitHub API - 如何获取“问题数量”谷歌表格从私人GitHub回购?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图去处理GitHub API。我已经从API中获得了详细的问题清单:

  function myFunction(){var url =' https://api.github.com/repos/repo/subrepo/issues'; 
var response = UrlFetchApp.fetch(url,{'muteHttpExceptions':true});
Logger.log(response);
}

但这只是控制台日志 - 而且似乎并不能使我看看有多少问题。有没有一种GitHub API方法来获取未解决的问题总数或已解决的问题?

理想情况下,我希望将数据导入Google表格中,喂它进入Geckoboard,但首先我要知道我实际上可以将所需的数据写入日志,然后我可以开始研究如何将它放到表单上。



PS 一个具体细节:回购是私人的 - 而且搜索问题似乎无法访问?access_token = mytoken

解决方案

您可以使用GitHub API的搜索功能来获取所需的问题。例如,要查找您打开的repo / subrepo中的问题,您可以使用 - https://api.github.com/search/issues?q=repo:repo/subrepo +状态:打开 即可。



注意如果您的回购是私密的,您需要创建一个access_token 并在查询中提供它,如下所示:
https://api.github .com / search / issues?q = repo:repo / subrepo + state:open& access_token = yourToken

常规查询?access_token = yourToken 可以正常工作,但是在搜索此类时,语法必须是 & access_token = yourToken



在JSON响应中,字段total_count为您提供了搜索中发现的问题数量。请参阅: https://help.github.com/articles/searching-issues/


I'm trying to come to grips with the GitHub API. I've gotten a detailed list of issues from the API, by doing this:

function myFunction() { var url = 'https://api.github.com/repos/repo/subrepo/issues';
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
Logger.log(response);
}

but that just goes the console log - and does not seem to enable me to see how many issues there are. Is there a GitHub API method of getting the "total amount of open issues" or "closed issues"?

I'm ideally hoping to get data into a Google Sheet and feed it into Geckoboard, but first I gotta know I can actually get the required data into the log, then I can I guess start working on how to get it onto a sheet.

PS one specific detail: the repo is private - and the search-issues does not seem capable of accessing a ?access_token=mytoken

解决方案

You can use the search feature of the GitHub API to get the issues you want. For example to find the issues from your "repo/subrepo" that are open you can use - https://api.github.com/search/issues?q=repo:repo/subrepo+state:open.

NOTE If your repo is private, you will need to create an access_token and supply it in your query, like this: https://api.github.com/search/issues?q=repo:repo/subrepo+state:open&access_token=yourToken.

In regular queries, ?access_token=yourToken will work, but in a search such as this the syntax must be &access_token=yourToken

In the JSON response the field 'total_count' gives you the number of issues found in the search. Refer: https://help.github.com/articles/searching-issues/

这篇关于GitHub API - 如何获取“问题数量”谷歌表格从私人GitHub回购?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆