Domain dead; native API available Due to a number of factors, twivatar.org is no longer active (the domain was in fact doomed) – however Twitter stepped up, and now there’s an API to get the avatar directly from them: http://twitter.com/api/users/profile_image/rem – so no longer any need for twivatar anyway.
I’ve built a number of different mini-apps for Twitter, and run in to various API limitations that I’ve not been happy with (equally, Twitter did add the favourite count and fix the auth issue on favs).
Twitter avatars is one of those annoyances. If you’ve built an app that caches a Twitter user’s avatar, and that user changes their avatar (@joshr is a good example of this), the link breaks, thus breaking your app.
I’ve spoken to Doug Williams about this (during the Devnest in April) and there’s a split argument over at Twitter: some say there should be an API, some say to re-poll Twitter to get the latest avatar.
This weekend I decided that I’d had enough, and decided to hack together a fix myself (affectionately known as a toilet project for those who know me).
Twivatar is a RESTful API that lets you specify a Twitter username and it will return the avatar.
<img src="http://twivatar.org/[screen_name]" />
Alternatively you can specify the size image you want from:
- mini (24×24)
- normal (48×48 – default)
- bigger (73×73)
<img src="http://twivatar.org/[screen_name]/[size]" />
I’ve also got the app whitelisted so there’s no worries about it being blocked from Twitter.
All the source code is available on GitHub so go ahead and fork ‘n hack if you want to.
You can see the API working in action on the Weird Habit site – yes, it is safe for work ;-)