简体   繁体   English

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

[英]Github API v3 doesn't show all user repositories

If i type this command: 如果我输入此命令:

$ curl https://api.github.com/users/KiCad/repos | grep full_name

I expect that it will return all KiCad repositories, but it returns: 我希望它将返回所有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",

If you look at https://github.com/KiCad , you will see, that there are more repositories. 如果你看一下https://github.com/KiCad ,你会看到有更多的存储库。

Has anyone encountered this problem? 有谁遇到过这个问题? How do you solve it? 你是如何解决的?

The GitHub API uses pagination and defaults to 30 items per page. GitHub API使用分页,默认为每页30个项目。 You will have to use 你将不得不使用

curl -i https://api.github.com/users/KiCad/repos?per_page=100

100 is the most number of items you can get on a single page. 100是您可以在一个页面上获得的最多项目数。 With -i specified you'll see headers printed out and the header you're looking for is the Links header. 使用-i指定,您将看到打印出的标题,并且您要查找的标题是Links标题。 That will have links to help you navigate the pages. 这将有帮助您浏览页面的链接。 One of those links should look like 其中一个链接应该是这样的

https://api.github.com/users/KiCad/repos?per_page=100&page=2

So if you do 所以,如果你这样做

curl -i https://api.github.com/users/KiCad/repos?per_page=100&page=2

You'll get repos 101-200. 你会得到回购101-200。 You can continue this until there is no next link in the Links header or until you realize you've received fewer than 100 results. 您可以继续此操作,直到“ Links标题中没有next链接,或者直到您意识到收到的结果少于100个为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM