下载 GitHub 个与主题匹配的存储库列表?
Download GitHub repositories list matching a topic?
有没有办法下载与 GitHub 主题匹配的项目列表?
例如,如果我写:
https://github.com/topics/haskell
在网络浏览器中,returns 一个页面包含 GitHub 个与 Haskell 相关的项目。我读了他们的 GitHub API 但他们似乎没有实现该功能:https://developer.github.com/v3/
端点 https://api.github.com/ does not seem to contain any option. All I get for my attempts like https://api.github.com/topics/haskell 也是:
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
主题的正确 GitHub API 端点是:https://api.github.com/search/topics
并且您需要在 q
查询参数中提供主题查询。这是直接来自 API documentation:
的示例查询
curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=ruby+is:featured'
下面是一个查找您的搜索主题的示例 'haskell':
curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=haskell'
如果要搜索与主题匹配的存储库,请使用 /search/repositories
和 topic
属性:
curl -H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:haskell
您必须在开发人员预览版中提供 application/vnd.github.mercy-preview+json
:
Note: The topics property for repositories on GitHub is currently
available for developers to preview. To view the topics property in
calls that return repository results, you must provide a custom media
type in the Accept header:
application/vnd.github.mercy-preview+json
“您可以在所有 GitHub 企业中全局搜索代码,或在特定存储库或组织中搜索代码。要在所有 public 存储库中搜索代码,您必须已签名进入 GitHub 企业帐户。"
此 curl 只会 return 个标签或主题
curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=haskell'
您可以使用 GraphQL API 获取主题中的存储库。
试用:https://docs.github.com/en/graphql/overview/explorer
query {
search(first: 10, type: REPOSITORY, query: "topic:databases") {
repositoryCount
nodes {
... on Repository {
nameWithOwner
}
}
}
}
{
"data": {
"search": {
"repositoryCount": 831,
"nodes": [
{
"nameWithOwner": ".../..."
},
{
"nameWithOwner": ".../..."
},
...
警告:您不能使用 GraphQL api 获取主题列表。
主题查询受限
有Query.topic
搜索单个主题和Repository.repositoryTopics
。 Topic.relatedTopics
存在为“相关主题列表,包括该主题的别名,最相关的排在最前面。Returns 最多 10 个主题。”。
有没有办法下载与 GitHub 主题匹配的项目列表? 例如,如果我写:
https://github.com/topics/haskell
在网络浏览器中,returns 一个页面包含 GitHub 个与 Haskell 相关的项目。我读了他们的 GitHub API 但他们似乎没有实现该功能:https://developer.github.com/v3/
端点 https://api.github.com/ does not seem to contain any option. All I get for my attempts like https://api.github.com/topics/haskell 也是:
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
主题的正确 GitHub API 端点是:https://api.github.com/search/topics
并且您需要在 q
查询参数中提供主题查询。这是直接来自 API documentation:
curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=ruby+is:featured'
下面是一个查找您的搜索主题的示例 'haskell':
curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=haskell'
如果要搜索与主题匹配的存储库,请使用 /search/repositories
和 topic
属性:
curl -H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:haskell
您必须在开发人员预览版中提供 application/vnd.github.mercy-preview+json
:
Note: The topics property for repositories on GitHub is currently available for developers to preview. To view the topics property in calls that return repository results, you must provide a custom media type in the Accept header:
application/vnd.github.mercy-preview+json
“您可以在所有 GitHub 企业中全局搜索代码,或在特定存储库或组织中搜索代码。要在所有 public 存储库中搜索代码,您必须已签名进入 GitHub 企业帐户。"
此 curl 只会 return 个标签或主题 curl -H 'Accept: application/vnd.github.mercy-preview+json' 'https://api.github.com/search/topics?q=haskell'
您可以使用 GraphQL API 获取主题中的存储库。
试用:https://docs.github.com/en/graphql/overview/explorer
query {
search(first: 10, type: REPOSITORY, query: "topic:databases") {
repositoryCount
nodes {
... on Repository {
nameWithOwner
}
}
}
}
{
"data": {
"search": {
"repositoryCount": 831,
"nodes": [
{
"nameWithOwner": ".../..."
},
{
"nameWithOwner": ".../..."
},
...
警告:您不能使用 GraphQL api 获取主题列表。
主题查询受限
有Query.topic
搜索单个主题和Repository.repositoryTopics
。 Topic.relatedTopics
存在为“相关主题列表,包括该主题的别名,最相关的排在最前面。Returns 最多 10 个主题。”。