Github API v3 不显示所有用户存储库
Posted
技术标签:
【中文标题】Github API v3 不显示所有用户存储库【英文标题】:Github API v3 doesn't show all user repositories 【发布时间】:2015-02-04 13:33:58 【问题描述】:如果我输入这个命令:
$ curl https://api.github.com/users/KiCad/repos | grep full_name
我希望它会返回所有 KiCad 存储库,但它会返回:
"full_name": "KiCad/Air_Coils_SML_NEOSID.pretty",
"full_name": "KiCad/Buzzers_Beepers.pretty",
"full_name": "KiCad/Capacitors_Elko_ThroughHole.pretty",
"full_name": "KiCad/Capacitors_SMD.pretty",
"full_name": "KiCad/Capacitors_Tantalum_SMD.pretty",
"full_name": "KiCad/Capacitors_ThroughHole.pretty",
"full_name": "KiCad/Choke_Axial_ThroughHole.pretty",
"full_name": "KiCad/Choke_Common-Mode_Wurth.pretty",
"full_name": "KiCad/Choke_Radial_ThroughHole.pretty",
"full_name": "KiCad/Choke_SMD.pretty",
"full_name": "KiCad/Choke_Toroid_ThroughHole.pretty",
"full_name": "KiCad/Connect.pretty",
"full_name": "KiCad/Connectors_Molex.pretty",
"full_name": "KiCad/Converters_DCDC_ACDC.pretty",
"full_name": "KiCad/Crystals.pretty",
"full_name": "KiCad/Crystals_Oscillators_SMD.pretty",
"full_name": "KiCad/Diodes_SMD.pretty",
"full_name": "KiCad/Diodes_ThroughHole.pretty",
"full_name": "KiCad/Discret.pretty",
"full_name": "KiCad/Display.pretty",
"full_name": "KiCad/Displays_7-Segment.pretty",
"full_name": "KiCad/Divers.pretty",
"full_name": "KiCad/EuroBoard_Outline.pretty",
"full_name": "KiCad/Fiducials.pretty",
"full_name": "KiCad/Filters_HF_Coils_NEOSID.pretty",
"full_name": "KiCad/Fuse_Holders_and_Fuses.pretty",
"full_name": "KiCad/Hall-Effect_Transducers_LEM.pretty",
"full_name": "KiCad/Heatsinks.pretty",
"full_name": "KiCad/Housings_DFN_QFN.pretty",
"full_name": "KiCad/Housings_QFP.pretty",
如果您查看https://github.com/KiCad,您会发现有更多的存储库。
有人遇到过这个问题吗?你是怎么解决的?
【问题讨论】:
【参考方案1】:GitHub API 使用分页,默认为每页 30 个项目。您将不得不使用
curl -i https://api.github.com/users/KiCad/repos?per_page=100
100 是您可以在单个页面上获得的最多项目数。指定-i
后,您会看到打印出的标题,而您正在寻找的标题是Links
标题。这将具有帮助您浏览页面的链接。其中一个链接应该看起来像
https://api.github.com/users/KiCad/repos?per_page=100&page=2
如果你这样做了
curl -i https://api.github.com/users/KiCad/repos?per_page=100&page=2
您将获得回购 101-200。您可以继续此操作,直到 Links
标头中没有 next
链接,或者直到您意识到您收到的结果少于 100 个。
【讨论】:
这个答案很好,这里是分页相关文档的链接,了解更多详情developer.github.com/v3/#pagination 感谢您修复 @jasonrudolph以上是关于Github API v3 不显示所有用户存储库的主要内容,如果未能解决你的问题,请参考以下文章
Google MAPS API V3 --> 如何显示存储在我的 MYSQL 表中的所有多边形?
有啥方法可以通过 GitHub Rest API v3 获取存储库见解
GitHub API v4 Graphql:获取当前授权用户组织及其存储库