Twivatar

Twitter Avatar API

Important - conditions of use

This service is free to use for low/medium traffic sites. If your site is making over a 1,000 requests per day, then you have enough traffic and resouce then you are able to host the code, so please do so. If I find you're sending too much traffic to my poor little server I will be in touch to ensure you host the service yourself, and will have to add your domain to the block list (it's nothing personal, I just want to keep this service available for smaller sites that need the support). Please respect my little box, there's lot of my projects on here that I'd like to survive when traffic picks up! - thanks!

What is Twivatar

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.