I want to fetch all GitHub Pull Requests from repositories where I am a contributor. To do that, I first need to get all repositories where I have write access.
I tried calling the GitHub API endpoint:
GET /user/repos?affiliation=owner,collaborator
…but this only returns repositories I own or am directly added to as a collaborator on personal accounts. It does not include repositories in organizations where I have write access.
I then tried:
GET /user/repos?affiliation=owner,collaborator,organization_member
and filtered the results with permissions.push === true. This works for some repos, but it still misses organization repos where I have write access via team membership.
The problem is that to reliably get all repositories where I can contribute, I would have to fetch hundreds of repos and then call the collaborator permission endpoint for each one — which is inefficient.
Question:
Is there a better way to fetch only the repositories where I have write access, including organization repos where my access comes from team membership, using the GitHub API?