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.
Twitter have deprecated the "direct link" API for avatar images. To get a twitter avatar when one has a twitter username, one now needs to get OAuth tokens (because the Twitter 1.1 API requires them) and use the users/show API endpoint (which is rate-limited *and* requires an auth token). This is terrible by comparison with merely inserting an image pointing to a single url, but there you go, Twitter hates developers.
🎉 Twivatar is back thanks to glitch: https://twivatar.glitch.com
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.
UK EVENTAttend ffconf.org 2024
The conference for people who are passionate about the web. 8 amazing speakers with real human interaction and content you can't just read in a blog post or watch on a tiktok!
£249+VAT - reserve your place today
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).
I give you: Twivatar (twivatar.glitch.com) (previously on twivatar.org)
Twivatar is a RESTful API that lets you specify a Twitter username and it will return the avatar.
Usage
Usage
<img src="https://twivatar.glitch.com/[screen_name]">
Alternatively you can specify the size image you want from:
- mini (24x24)
- normal (48x48 - default)
- bigger (73x73)
- original
<img src="https://twivatar.glitch.com/[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.