按created_at日期对github API列表repos进行排序

时间:2017-03-21 16:38:08

标签: sorting github-api

我正在使用 github developer API link 列出具有给定搜索字词的所有存储库,我希望按created_at日期降序排序。我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

根据Github Search API v3文档,排序字段仅支持星号,分叉或更新之一。默认结果按最佳匹配排序。

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

答案 1 :(得分:0)

我自己找到了解决方案: 列出具有给定搜索词的repos(例如oauth):

response = https://api.github.com/search/repositories?q=oauth&order=desc

现在将其排序为

# Sort based on created_at date 
data = sorted(response.json()['items'], key=lambda x: x['created_at'], reverse = True)

感谢similar post

相关问题