How to get all user repositories by github api? (including Pinned repositories)

大城市里の小女人 提交于 2019-12-06 12:01:35

问题


I' trying get all user's repositories by using PyGithub. For clarity the user: https://github.com/mbostock has 53 public repos.

my code:

import github
con = github.Github(mylogin, pass)
u = g.get_user('mbostock').get_repos('all')

and I get 53, It's correct number but, I have noticed that among all received repos I can't find some user's Pinned repositories, for example d3/d3, although that user also make big contribution on this repo.

If somebody know github api, and way of receiving all user's contributed repos, please help.


回答1:


Not all of the user's pinned repositories belong to that user—they belong to organisations that the user happens to be a member of, so they won't show up when asking the API for the user's repositories via GET /users/:user/repos (apologies, I'm not familiar with PyGithub so I'll speak only in the standard API URLs).

There's no easy way to get a list of repositories that a user contributes to without making multiple API queries—for example to get a list of organisations the user belongs to (GET /user/:user/orgs), and then listing the repositories in that organisation (GET /orgs/:org/repos). However, using this approach there's no guarantee the user contributed to each repository in the organisation.

You could of course further filter by commit authors, but at this point you will probably have expended a lot of effort (and rate limit).



来源:https://stackoverflow.com/questions/40225679/how-to-get-all-user-repositories-by-github-api-including-pinned-repositories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!