我想按照创建日期对存储库搜索结果进行排序。 这可能是一件容易的事,但我一直在苦苦挣扎。 请帮忙:(
答案 0 :(得分:2)
如果仍然可以选择Github API Graphql v4,那么您可以从the explorer轻松完成此任务:
{
user(login: "bertrandmartel") {
repositories(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes {
createdAt
name
}
}
}
}
使用curl:
curl -H "Authorization: bearer token" -d '
{
"query": "query { user(login: \"bertrandmartel\") { repositories(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) { nodes { createdAt name } } } }"
}
' https://api.github.com/graphql
答案 1 :(得分:2)
对于API(V3),您可以在查询中包含排序限定符 - +sort:author-date-desc
表示降序,+sort:author-date-asc
表示升序。
例如:要搜索由km-poonacha
按升序排序的所有存储库,您可以进行以下搜索请求:
https://api.github.com/search/repositories?q=user:km-poonacha+sort:author-date-asc