In a repos that belongs to an organization (as opposed to an individual), collaborators are members of \"teams\", and teams can have three different kinds of permissions:
If you want to check whether you have push access to a GitHub repo, you can use the repo endpoint:
GET /repos/:owner/:repo
If your request includes your authorization information (either including your account credentials or an OAuth access token), the permissions
field will give you the information you're looking for:
{
'admin': False,
'push': False,
'pull': True
}
Update June 2017: You now have nested teams.
However, the orgs/teams API mentions:
The REST API v3 does not yet fully support nested teams.
For example, the endpoints for List team members and List team repositories do not return results inherited from a nested team's structure.
Warning: since January 2020, The Team APIs will be moving from a top-level path under /teams/:team_id
to a scoped path under the organization that owns the team with a path like /organizations/:org_id/team/:team_id
.
See "Moving the teams API" by Dirkjan Bussink
Original answer 2016
The one query which should include your permission is mentioned in "List User Teams"
GET /user/teams
List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth.
The answer looks like:
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
[
{
"url": "https://api.github.com/teams/1",
"name": "Owners",
"id": 1,
"permission": "admin", <============
"members_count": 3,
"repos_count": 10,
"organization": {
"login": "github",
"id": 1,
"url": "https://api.github.com/orgs/github",
"avatar_url": "https://github.com/images/error/octocat_happy.gif"
}
}
]
You need to filter that result in order to match the team with the right repo, and you should get back the permission level associated to that repo that way.