使用github搜索api而不指定存储库或组织 [英] using github search api without specifying the repository or organization

查看:288
本文介绍了使用github搜索api而不指定存储库或组织的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取一个存储库或文件列表,其中存储库中包含的文件内容与我在搜索中指定的关键字匹配.我尝试使用https GET请求进行简单搜索,但是如果未指定存储库或组织名称,则似乎无法进行搜索.我收到以下错误.

I want to get a list of repositories or files where the contents of the files contained in the repositories match the keywords I specify in the search. I tried doing a simple search using https GET request and it looks like the search is not possible without specifying the repository or organization name. I get the below error.

https://api.github.com/search/code?q=authorization+in:file

{
  "message": "Validation Failed",
  "errors": [
    {
      "message": "Must include at least one user, organization, or repository",
      "resource": "Search",
      "field": "q",
      "code": "invalid"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/search/#search-code"
}

我了解没有存储库或组织名称的搜索将占用大量资源.有什么解决方法吗?我以为既然可以通过在线搜索获得结果,那么我应该可以使用git search api达到同样的效果.

I understand that searching without repository or organization name will be resource-intensive operation. Is there any work-around for this? I was assuming that since I am able to get results by using online search, I should be able to achieve the same using git search api.

所以基本上,我正在尝试模拟以下内容:

So basically I am trying to simulate the below:

https://github .com/search?utf8 =%E2%9C%93& q = authorization& type = Code& ref = searchresults

推荐答案

有什么解决方法吗?我以为既然可以通过在线搜索获得结果,那么我应该可以使用git search api达到同样的效果.

Is there any work-around for this? I was assuming that since I am able to get results by using online search, I should be able to achieve the same using git search api.

您目前观察到的行为是预期的-使用代码搜索API时确实需要指定用户,组织或存储库(使用Web UI时不需要执行的操作),并且当前存在没办法.

The behavior you observed is expected for now -- you indeed need to specify a user, org or repository when using the code search API (something you don't need to do when using the Web UI), and currently there is no way around that.

https://developer.github.com /changes/2013-10-18-new-code-search-requirements/

这篇关于使用github搜索api而不指定存储库或组织的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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