npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

network-avatar-picker

v2.0.1

Published

A picker for user's networks profile image.

Downloads

82

Readme

network-avatar-picker

A npm module that returns a user's avatar from his social networks as Buffer or as URL. You can choose among Facebook, Twitter, Instagram, Tumblr, Vimeo, Github, Gmail and Youtube provider. Then, you just need to pass a username without the need of token or API keys and retrieve user's social network profile picture!

npm version Build Status Coverage Status

Supported Providers

  • Facebook
  • Github
  • Gmail
  • Instagram
  • Tumblr
  • Twitter
  • Vimeo
  • Youtube

Getting Started

Installing

First, install network-avatar-picker as a dependency:

npm install --save network-avatar-picker

Usage

Basic configuration

You should require the dependency in order to be able use it:

const NetworkAvatarPicker = require('network-avatar-picker');
const avatarPicker = new NetworkAvatarPicker();

Cache configuration using Redis

In 1.4.0 we have introduced support to cache results with Redis! Just pass redis config as param to the NetworkAvatarPicker and it will create a new redis client. Then, we will store the images and avatar's URL to redis.

const NetworkAvatarPicker = require('network-avatar-picker');
const avatarPicker = new NetworkAvatarPicker({
  redis: {
    host: '127.0.0.1', // required
    port: '6379', // required
    password  : 'your password',    // optional: replace with your password
    ttl: 3600, // optional: Add your expiration caching time in seconds. Default value: 3600
  }
});

This way we create a local Redis client with expiration caching time 3600sec.

Methods

Use the async methods of the avatarPicker instance to fetch user avatars:

A) getAvatar: Fetch avatar image as Buffer

  • avatarPicker.facebook.getAvatar(username)
  • avatarPicker.twitter.getAvatar(username)
  • avatarPicker.instagram.getAvatar(username)
  • avatarPicker.tumblr.getAvatar(username)
  • avatarPicker.vimeo.getAvatar(username)
  • avatarPicker.github.getAvatar(username)
  • avatarPicker.youtube.getAvatar(username)
  • avatarPicker.gmail.getAvatar(email)

B) getAvatarUrl: Fetch avatar image as URL

  • avatarPicker.facebook.getAvatarUrl(username)
  • avatarPicker.twitter.getAvatarUrl(username)
  • avatarPicker.instagram.getAvatarUrl(username)
  • avatarPicker.tumblr.getAvatarUrl(username)
  • avatarPicker.vimeo.getAvatarUrl(username)
  • avatarPicker.github.getAvatarUrl(username)
  • avatarPicker.youtube.getAvatarUrl(username)
  • avatarPicker.gmail.getAvatarUrl(email)

Examples

  1. Fetch twitter's cnn user profile picture:

Buffer:

(async () => {
    try {
      const res = await avatarPicker.twitter.getAvatar('cnn');
    } catch (e) {
      // Deal with the fact the chain failed
    }
})();

URL:

(async () => {
    try {
      const res = await avatarPicker.twitter.getAvatarUrl('cnn');
    } catch (e) {
      // Deal with the fact the chain failed
    }
})();
  1. Fetch facebook's zuck user profile picture:

Buffer:

(async () => {
    try {
      const res = await avatarPicker.facebook.getAvatar('zuck');
    } catch (e) {
      // Deal with the fact the chain failed
    }
})();

URL:

(async () => {
    try {
      const res = await avatarPicker.facebook.getAvatarUrl('zuck');
    } catch (e) {
      // Deal with the fact the chain failed
    }
})();
  1. Fetch instagram's cnn user profile picture:

Buffer:

(async () => {
    try {
      const res = await avatarPicker.instagram.getAvatar('cnn');
    } catch (e) {
      // Deal with the fact the chain failed
    }
})();

URL:

(async () => {
    try {
      const res = await avatarPicker.instagram.getAvatarUrl('cnn');
    } catch (e) {
      // Deal with the fact the chain failed
    }
})();

Running the tests

In order to run tests you have to run:

npm run tests