Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

"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.

Has anyone encountered this problem? How do you solve it?

like image 670
Ondra Šesták Avatar asked Dec 06 '14 12:12

Ondra Šesták


People also ask

How do I see all repositories in GitHub?

Hitting https://api.github.com/users/USERNAME/repos will list public repositories for the user USERNAME. Show activity on this post. to find all the user's repos.

How do I find my GitHub repository API?

Go to Developer Settings ->Personal Access Tokens. Add a name and select the scope for the API access and click on Create Token. In the next screen, make sure to copy the token and save it in a file. This token will be used in the command line to access GitHub API.

How many repositories are on GitHub?

It is commonly used to host open source software development projects. As of June 2022, GitHub reported having over 83 million developers and more than 200 million repositories, including at least 28 million public repositories. It is the largest source code host as of November 2021.


1 Answers

The GitHub API uses pagination and defaults to 30 items per page. 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. With -i specified you'll see headers printed out and the header you're looking for is the Links header. 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. 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.

like image 140
Ian Stapleton Cordasco Avatar answered Sep 29 '22 17:09

Ian Stapleton Cordasco