github-apioctokit

Where are the "teams" in the GitHub hypermedia API?


Using Octokit, I can traverse link rels to get to "organization" and "members," but I can't seem to find "teams" anywhere.

I can get a representation of an org, but the link rels don't include anything for team

curl -H "Authorization: token $OAUTHTOKEN" https://api.github.com/orgs/MY_ORG

gives me

{
    "login": "…",
    "id": …,
    "url": "https://api.github.com/orgs/MY_ORG",
    "repos_url": "https://api.github.com/orgs/MY_ORG/repos",
    "events_url": "https://api.github.com/orgs/MY_ORG/events",
    "members_url": "https://api.github.com/orgs/MY_ORG/members{/member}",
    "public_members_url": "https://api.github.com/orgs/MY_ORG/public_members{/member}",
    "…": "…"
}

Octokit nets similar results:

client = Octokit::Client.new access_token: ENV['GITHUB_ACCESS_TOKEN']
my_org = client.org 'MY_ORG'
my_org.rels
{:self_url=>"https://api.github.com/orgs/MY_ORG",
 :repos_url=>"https://api.github.com/orgs/MY_ORG/repos",
 :events_url=>"https://api.github.com/orgs/MY_ORG/events",
 :members_url=>"https://api.github.com/orgs/MY_ORG/members",
 :public_members_url=>"https://api.github.com/orgs/MY_ORG/public_members",
 :avatar_url=>"…",
 :html_url=>"https://github.com/MY_ORG"}

Solution

  • If you read the developer documentation for Organizations you'll see that the endpoint is /orgs/:org_name/teams. To get an individual team you want /teams/:team_id.


    I see now that you're using an OAuth Token (from the Authorizations API). You likely don't have the proper scopes set for the token. Take a look at the list of scopes and note that you probably at least nead read:org to see your teams.