Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get GitHub avatar from email or name

Tags:

github-api

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

I've found these API:

https://avatars.githubusercontent.com/<username> https://avatars.githubusercontent.com/u/<userid> 

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?

like image 403
Fez Vrasta Avatar asked Apr 08 '14 09:04

Fez Vrasta


People also ask

Does GitHub profile picture matter?

Use a Professional Profile PictureIf you're planning on showing your GitHub Profile to recruiters, admissions officers, or hiring managers, you need to make sure that your account looks trustworthy. Pick a photo of yourself that showcases your ability to be a qualified coder.

How do I get my GitHub pro badge?

If you're a registered member of the GitHub Developer Program, building an app with the GitHub API, you'll get a Developer Program Member badge on your profile. For more information on the GitHub Developer Program, see GitHub Developer. If you use GitHub Pro you'll get a PRO badge on your profile.

Can you search GitHub by email?

According to GitHub API Search users, you can specify only searching by public email using keyword in . Then, you'll only get users with "franky" in there emails. Save this answer.


2 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:

https://github.com/twbs.png

https://github.com/npm.png?size=200

https://github.com/github.png?size=40

like image 133
Paul Avatar answered Sep 20 '22 12:09

Paul


https://developer.github.com/v3/users/#get-a-single-user

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 http://www.gravatar.com/avatar/[md5_here].

like image 40
photoionized Avatar answered Sep 21 '22 12:09

photoionized