Github API v3 doesn't show all user repositories

前端 未结 1 1912
青春惊慌失措
青春惊慌失措 2021-02-02 10:15

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, b

相关标签:
1条回答
  • 2021-02-02 10:52

    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.

    0 讨论(0)
提交回复
热议问题