How can we get the avatar of a GitHub user using PyGitHub?
Github.get_user gives NamedUser | AuthenticatedUser
, however, neither NamedUser nor AuthenticatedUser have any functions for getting the avatar, as far as I see.
Turns out, there is a avatar_url
attribute:
def get_avatar_url(g: Github, user: str) -> str:
return g.get_user(user).avatar_url
This isn't mentioned in the documentation of PyGithub, but it is mentioned in the documentation of the REST API of GitHub (link), inside the "Default response" panel.