简体   繁体   中英

Github API: How to get all repositories written in a given language

I was able to get all github repositories tagged with a given language in JSON format with the v2 of the github API , but this version has been deprecated last year. I can't find any way to do this with the new v3 .

Any ideas?

If I run:

> 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>

Which seems to be the nature of the response you are looking for.

Also, on the latest version of the API , you can try:

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

Without the media type, you'll get:

{
  "message": "Not Found"
}

But with the -H media type in the request, you'll get a proper response.

On 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

(note the " instead of ' around the header Accept )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM