Twivatar

Twitter Avatar API

Twivatar is a RESTful API to a Twitter user's avatar built out of frustration of external Twitter apps breaking when the avatar url is stored, and then changed by that user later on Twitter - the result is a broken image on that app unless they constantly check for profile changes.

Usage

<img src="http://twivatar.org/[screen_name]" />

Alternatively you can specify the size image you want from:

<img src="http://twivatar.org/[screen_name]/[size]" />

Behind the scenes

This is a simple one script app that stores the url of the avatar. When the avatar is requested for x user, it runs the following logic:

  1. Get the stored avatar url
  2. If there's no record, go to Twitter and pull the profile_image_url
  3. If a record is found, perform a HEAD request to test the avatar url
  4. Finally use a location redirect to the avatar url

All the code is available on GitHub, so feel free to fork and contribute.

Todo

I'd like to upgrade the entire app to read the ETags from S3 (or some kind of cache control), and send them back to the client, so that the browser uses it's local cache if the avatar is available and up to date.