Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Twitter avatar API client for Node.js

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

twitface

Twitter avatar API client for Node.js Build Status

Setup

Install the module with: npm install twitface

Basic Usage

var twitface = require('twitface');

twitface.load('markdalgleish', function(err, url) {
    console.log(url); // Avatar URL ('normal' size)
});

Requesting multiple images

twitface.load(['markdalgleish', 'ryah'], function(err, urls) {
    console.log(urls); // Array of avatar URLs ('normal' size)
});

Request a specific 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…)

Modify the default size

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)
});

Modify the cache expiry duration

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

Contributing

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.

License

Copyright (c) 2012 Mark Dalgleish
Licensed under the MIT license.

Something went wrong with that request. Please try again.