mil*_*les 1 python api github github-api pygithub
我正在使用PyGithub库邀请新成员加入该组织。我面临的问题是下一个:在方案中,当我仅知道用户的主电子邮件时,如何检索他的用户名以进行相应的邀请?我知道可以通过UI进行操作,但无法通过API找到相应的调用。请协助!
为此使用github 用户搜索api。我尝试了以下之一。
https://api.github.com/search/users?q=solankiarpit1997@gmail.com
Run Code Online (Sandbox Code Playgroud)
密钥名称login是此处的用户名。响应:
{
"total_count": 1,
"incomplete_results": false,
"items": [
{
"login": "arpit1997",
"id": 10682054,
"avatar_url": "https://avatars1.githubusercontent.com/u/10682054?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/arpit1997",
"html_url": "https://github.com/arpit1997",
"followers_url": "https://api.github.com/users/arpit1997/followers",
"following_url": "https://api.github.com/users/arpit1997/following{/other_user}",
"gists_url": "https://api.github.com/users/arpit1997/gists{/gist_id}",
"starred_url": "https://api.github.com/users/arpit1997/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/arpit1997/subscriptions",
"organizations_url": "https://api.github.com/users/arpit1997/orgs",
"repos_url": "https://api.github.com/users/arpit1997/repos",
"events_url": "https://api.github.com/users/arpit1997/events{/privacy}",
"received_events_url": "https://api.github.com/users/arpit1997/received_events",
"type": "User",
"site_admin": false,
"score": 52.297474
}
]
}
Run Code Online (Sandbox Code Playgroud)
参考search_users。
search_users(query, sort=NotSet, order=NotSet, **qualifiers)
- 请求参数
- 排序 - 字符串('追随者','存储库','加入')
- 订单 - 字符串('asc','desc')
- qualifiers – 关键字 dict 查询限定符
例如,
g = github.Github("USERNAME", "PASSWORD")
users = g.search_users("franky in:email")
for user in users:
print(user.login) # print the selected users' username.
Run Code Online (Sandbox Code Playgroud)
根据 GitHub API搜索用户的说法,您可以使用关键字指定仅通过公共电子邮件进行搜索in。
例如,
https://api.github.com/search/users?q=franky+in:email
然后,您只会在电子邮件中获得“坦率”的用户。
| 归档时间: |
|
| 查看次数: |
2428 次 |
| 最近记录: |