Get github username through primary email

I'm using the PyGithub library to invite new member to the organization. The issue I faced is the next: In the scenario, when I know only users primary email, how can I retrieve his username to proceed invite accordingly? I know it is possible through UI, but can't find the corresponding call through API. Please, assist!


PyGithub API

Refer to search_users.

search_users(query, sort=NotSet, order=NotSet, **qualifiers)

  • query – string
  • sort – string (‘followers’, ‘repositories’, ‘joined’)
  • order – string (‘asc’, ‘desc’)
  • qualifiers – keyword dict query qualifiers

For example,

g = github.Github("USERNAME", "PASSWORD")
users = g.search_users("franky in:email")
for user in users:
    print(user.login)  # print the selected users' username.

GitHub API

According to GitHub API Search users, you can specify only searching by public email using keyword in.

For example,

Then, you'll only get users with "franky" in there emails.

Posted on by YLJ

Use github user search api for this . I tried the below one.[email protected]

Key name login is the username here. response:

  "total_count": 1,
  "incomplete_results": false,
  "items": [
      "login": "arpit1997",
      "id": 10682054,
      "avatar_url": "",
      "gravatar_id": "",
      "url": "",
      "html_url": "",
      "followers_url": "",
      "following_url": "{/other_user}",
      "gists_url": "{/gist_id}",
      "starred_url": "{/owner}{/repo}",
      "subscriptions_url": "",
      "organizations_url": "",
      "repos_url": "",
      "events_url": "{/privacy}",
      "received_events_url": "",
      "type": "User",
      "site_admin": false,
      "score": 52.297474

Posted on by Arpit Solanki