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

时间:2013-05-07 10:49:30

标签: github

我能够使用github API的v2以JSON格式标记给定语言的所有github存储库,但去年版本为has been deprecated。我无法通过new v3找到任何方法。

有什么想法吗?

1 个答案:

答案 0 :(得分: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>

这似乎是您正在寻找的回应的本质。

此外,在latest version of the 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"
}

但是,如果请求中包含-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

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