Get GitHub avatar from email or name

I'm trying to get the GitHub user picture (avatar) from users of GitHub.

I've found these API:

 

But I can't find a way to get the avatar from the user email or the user display name. I can't find documentation about that.

Is there some similar URL API to get what I'm looking for?

5 Answers

You can append .png to the URL for the User's profile to get redirected to their avatar. You can add the query param size to specify a size smaller than the default of 460px wide (i.e. it won't allow larger than 460).

Examples:

6

Use the /users/:user endpoint. Should be under avatar_url in the returned json.

For example, my avatar_url can be found by hitting this url.

Edit

There is another way I can think of that is kind of roundabout. Since GitHub uses Gravatar, if you know the email associated with the account, do an md5 hash of the lowercase, stripped email address and construct a url like

8

This is an old post but nobody has proposed Github Search Users API with scope field :

  • using in:email :
  • using in:username :

Or using new Graphql API v4 :

{ search(type: USER, query: "in:email bmartel", first: 1) { userCount edges { node { ... on User { avatarUrl } } } } } 

Using GraphQL API v4, this will work too

Query (for username)-

{ user(login: "username") { avatarUrl } } 

Response -

{ "data": { "user": { "avatarUrl": "" } } } 
0

GitHub avatar can be accessed through

Optionally, you can modify the size at the end like so

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like