下载与主题匹配的 GitHub 存储库列表?

Ver*_*ica 5 git command-line github github-api

有没有办法下载与 GitHub 主题匹配的项目列表?例如,如果我写:

https://github.com/topics/haskell

在 Web 浏览器中,返回包含与 Haskell 相关的 GitHub 项目的页面。我阅读了他们的 GitHub API,但他们似乎没有实现该功能:https : //developer.github.com/v3/

此外端点https://api.github.com/似乎不包含任何选项。我得到的像https://api.github.com/topics/haskell这样的尝试是:

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}
Run Code Online (Sandbox Code Playgroud)

Ber*_*tel 5

如果您想搜索与主题匹配的存储库,请使用/search/repositories属性topic

curl -H "Accept: application/vnd.github.mercy-preview+json" \
    https://api.github.com/search/repositories?q=topic:haskell
Run Code Online (Sandbox Code Playgroud)

您必须application/vnd.github.mercy-preview+json在它仍处于开发人员预览版时提供:

注意:GitHub 上存储库的主题属性目前可供开发者预览。要在返回存储库结果的调用中查看主题属性,您必须在 Accept 标头中提供自定义媒体类型:

应用程序/vnd.github.mercy-preview+json


met*_*ttj 2

主题的正确 GitHub API 端点是:https://api.github.com/search/topics并且您需要在查询参数中提供主题查询q以下是直接来自API 文档的示例查询:

curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=ruby+is:featured'
Run Code Online (Sandbox Code Playgroud)

以下是查找搜索主题“haskell”的示例:

curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=haskell'
Run Code Online (Sandbox Code Playgroud)

请参阅: https: //developer.github.com/v3/search/#search-topics

  • 但结果不包含存储库列表 - 它是子主题列表 (3认同)