How to get all user repositories by github api? (i

2019-04-14 20:39发布

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条回答
Rolldiameter
2楼-- · 2019-04-14 20:45

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

查看更多
登录 后发表回答