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!
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.
According to GitHub API Search users, you can specify only searching by public email using keyword in
.
For example,
https://api.github.com/search/users?q=franky+in:email
Then, you'll only get users with "franky" in there emails.