6

I've seen a couple of Stack Apps that have the actual picture for the user profile. Is that coming from the API, and if so how? If not I'm assuming they are using some screen-scrapping to get that URL.

2 Answers 2

6

AFAIK StackExchange network uses gravatars. Hence you can get their profile picture from their email address (check the gravatar site for details).

0
3

Actually, the API does this already, and I'd prefer this method over using my email address. In fact, the reason for the Stack Exchange API is so that our apps don't have to rely on third parties that may break, change their APIs, misuse our data, or go away. Additionally, if your app doesn't need access to sending me emails, then I'd just prefer you not have my email address, as no one else on Stack Exchange has it.

http://api.stackexchange.com/2.1/users?order=desc&sort=reputation&inname=jmort253&site=stackoverflow&filter=!*MxL2GdM9OVn.VWD

The above is an example request, that uses my username instead, to retrieve my gravitar profile image. My email address isn't needed. You don't need to ask me for it at account creation in your app, which means I'm more likely to use your app.

In addition, it may be easier to pull these details by userId, such as this example:

http://api.stackexchange.com/2.1/users/552792?order=desc&sort=reputation&site=stackoverflow&filter=!*N1O2t9FKJv(Hwn5

{
  "items": [
    {
      "user_id": 552792,
      "user_type": "registered",
      "display_name": "jmort253",
      "profile_image": "http://www.gravatar.com/avatar/af668818d6cfecc1a1b008cf599562cd?d=identicon&r=PG",
      "reputation": 11660,
      "website_url": "http://blog.opensourceopportunities.com",
      "account_id": 265671
    }
  ],
  "quota_remaining": 9951,
  "quota_max": 10000,
  "has_more": false
}

To create your own /users filter, see the users API or the Users by ID API.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .