Github API:如何使用给定语言编写所有存储库

eme*_*pyc 16 github

我能够使用github API的v2以JSON格式标记给定语言的所有github存储库,但此版本去年已被弃用.我无法用新的v3找到任何方法.

有任何想法吗?

Mat*_*ugh 11

如果我跑:

> curl https://api.github.com/legacy/repos/search/Go?language=Go

{
  "repositories": [
    {
      "type": "repo",
      "username": "mattn",
      "name": "go-gtk",
      "owner": "mattn",
      "homepage": "http://mattn.github.com/go-gtk",
      "description": "Go binding for GTK",
      "language": "Go",
      "watchers": 342,
      "followers": 342,
      "forks": 67,
      "size": 416,
      "open_issues": 34,
      "score": 54.450714,
      "has_downloads": true,
      "has_issues": true,
      "has_wiki": true,
      "fork": false,
      "private": false,
      "url": "https://github.com/mattn/go-gtk",
      "created": "2009-11-26T16:58:53Z",
      "created_at": "2009-11-26T16:58:53Z",
      "pushed_at": "2013-09-02T04:29:39Z",
      "pushed": "2013-09-02T04:29:39Z"
    }
  ]
}
<TRIMMED>
Run Code Online (Sandbox Code Playgroud)

这似乎是您正在寻找的响应的本质.

此外,在最新版本的API上,您可以尝试:

curl -H 'Accept: application/vnd.github.preview.text-match+json' https://api.github.com/search/repositories?q=language:go&order=desc

如果没有媒体类型,您将获得:

{
  "message": "Not Found"
}
Run Code Online (Sandbox Code Playgroud)

但是-H在请求中使用媒体类型,您将获得适当的响应.

在Windows上:

c:\prgs\git\PortableGit-1.8.3-preview20130601\bin\curl.exe -H "Accept: application/vnd.github.preview.text-match+json" https://api.github.com/search/repositories?q=language:go&order=desc
Run Code Online (Sandbox Code Playgroud)

(注意"而不是'标题周围Accept)

  • 它可以分页https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#pagination (2认同)