Github API:如何获取以给定语言编写的所有存储库 [英] Github API: How to get all repositories written in a given language
问题描述
我能够使用 github API 的v2,以JSON格式获取所有以给定语言标记的github存储库,但是该版本已于去年弃用.我找不到使用新v3 的任何方法.
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.
有什么想法吗?
推荐答案
如果我运行:
> 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.
此外,在 API的最新版本上,您可以尝试:
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"
}
但是在请求中使用-H
媒体类型时,您将获得正确的响应.
But with the -H
media type in the request, you'll get a proper response.
在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
周围使用"
而不是'
)
(note the "
instead of '
around the header Accept
)
这篇关于Github API:如何获取以给定语言编写的所有存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!