问题
I want to sort my repositories search result by the date they are created. This might be an easy task but I have been struggling for a while. Please help :(
回答1:
If Github API Graphql v4 is still an option, you can do this very easily, from the explorer :
{
user(login: "bertrandmartel") {
repositories(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes {
createdAt
name
}
}
}
}
using 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
回答2:
For API (V3) you can include the sort qualifier in your query - +sort:author-date-desc
for descending and +sort:author-date-asc
for ascending.
For example: to search all repos started by km-poonacha
sorted ascending you can make the following search request:
https://api.github.com/search/repositories?q=user:km-poonacha+sort:author-date-asc
Ref: Sorting Search Results
来源:https://stackoverflow.com/questions/47255773/github-apiv3-sort-search-result-by-date-created