You can pass the affiliation
parameter, in order to filter out any collaborators that directly work on a certain project.
curl -H "Authorization: <bearer KEY>" \
-H "Accept: application/vnd.github.v3+json" \
-XGET https://api.github.com/repos/:org/:repo/collaborators\?affiliation\=direct
This should return just the people who work on a project, and not both collaborators and owners.
GitHub states that:
affiliation | string | query
Filter collaborators returned by their affiliation. Can be one of:
- outside: All outside collaborators of an organization-owned repository.
- direct: All collaborators with permissions to an organization-owned repository, regardless of organization membership status.
- all: All collaborators the authenticated user can see.
If it so happens that an owner is also a direct collaborator to this repo, then you have to do another request, where you check which person is the owner, and then filter them out from the collaborators request.
curl -H "Authorization: <bearer KEY>" \
-H "Accept: application/vnd.github.v3+json" \
-XGET https://api.github.com/orgs/:org/members\?role\=admin
With this request, you can check which are the owners of an organization.
If you fancy using the new graphql feature, then you can query for
{
organization(login: "org_name") {
id
name
repository(name: "repo_name") {
collaborators(affiliation: DIRECT, first: N) {
edges {
permission
node {
name
}
}
}
}
}
}