Twitter avatar API client for Node.js
Install the module with: npm install twitface
var twitface = require('twitface');
twitface.load('markdalgleish', function(err, url) {
console.log(url); // Avatar URL ('normal' size)
});
twitface.load(['markdalgleish', 'ryah'], function(err, urls) {
console.log(urls); // Array of avatar URLs ('normal' size)
});
Requesting a single image:
twitface.load('markdalgleish', 'bigger', function(err, url) {
console.log(url); // Avatar URL
});
Requesting multiple images:
twitface.load(['markdalgleish', 'ryah'], 'bigger', function(err, urls) {
console.log(urls); // Array of avatar URLs
});
Twitter offers the following sizes:
original
(Original upload size)mini
(24x24)normal
(48x48)bigger
(73x73)reasonably_small
(128x128 - Don't ask me, ask Twitter…)
By default, 'normal' avatar URLs are returned. This default can be changed with setDefaultSize
:
twitface.setDefaultSize('reasonably_small');
twitface.load('markdalgleish', function(err, url) {
console.log(url); // Avatar URL (128x128)
});
By default, avatar URLs are cached for 24 hours to limit the amount the API is hit.
You can modify how long URLs are cached with setExpiryDuration
:
twitface.setExpiryDuration(1000 * 60 * 60); // Cache for 60 minutes
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Copyright (c) 2012 Mark Dalgleish
Licensed under the MIT license.