PyGitHub: Get avatar of user?

23 views Asked by At

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.

1

There are 1 answers

0
kostrykin On BEST ANSWER

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.