Github API v3不显示所有用户存储库

时间:2014-12-06 12:49:02

标签: curl get repository github-api kicad

如果我输入此命令:

$ 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 个答案:

答案 0 :(得分:21)

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。您可以继续此操作,直到next标题中没有Links个链接,或直到您意识到收到的结果少于100个为止。