githubgithub-api

GitHub API: Get email addresses of all members of organization


GitHub API provides a way to get the members of an organization. I am the admin/owner for my organization and I would like to get the email addresses of all the users. I tried with the members API but it does not return the email addresses.

Using curl with my admin auth-token:

GET /orgs/my-org/members

I get the response that look like this (for one of the users):

"login": "auny",
    "id": some-number,
    "avatar_url": "https://secure.gravatar.com/avatar/6579d09c459f1adad8a60463f47eadd3?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
    "gravatar_id": "6579d09c459f1adad8a60463f47eadd3",
    "url": "https://api.github.com/users/auny",
    "html_url": "https://github.com/auny",
    "followers_url": "https://api.github.com/users/auny/followers",
    "following_url": "https://api.github.com/users/auny/following{/other_user}",
    "gists_url": "https://api.github.com/users/auny/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/auny/starred{/owner} 
     {/repo}",
    "subscriptions_url": "https://api.github.com/users/auny/subscriptions",
    "organizations_url": "https://api.github.com/users/auny/orgs",
    "repos_url": "https://api.github.com/users/auny/repos",
    "events_url": "https://api.github.com/users/auny/events{/privacy}",
    "received_events_url": 
    "https://api.github.com/users/auny/received_events",
    "type": "User"

Strangely enough, this contains a wealth of information about the user but not one of the important ones i.e the email address of the user. Being the admin I should be able to get the email address's of all my users.

The other user API only return my own email address i.e the email address of the account whose auth-token is used in the request. API usage:

GET /user/emails

How can this be achieved? Is there way around it?


Solution

  • After fetching the list of org members, fetch the info for each member using this API endpoint:

    /users/:user
    

    This will return the e-mail address of the user you have specified in your request URL.