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

后端 未结 1 1943
慢半拍i
慢半拍i 2021-02-07 04:52

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 fin

相关标签:
1条回答
  • 2021-02-07 05:08

    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)

    0 讨论(0)
提交回复
热议问题