Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
network-avatar-picker
Advanced tools
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!
First, install network-avatar-picker
as a dependency:
npm install --save network-avatar-picker
You should require the dependency in order to be able use it:
const NetworkAvatarPicker = require('network-avatar-picker');
const avatarPicker = new NetworkAvatarPicker();
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.
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)
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
}
})();
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
}
})();
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
}
})();
In order to run tests you have to run:
npm run tests
FAQs
A picker for user's networks profile image.
The npm package network-avatar-picker receives a total of 29 weekly downloads. As such, network-avatar-picker popularity was classified as not popular.
We found that network-avatar-picker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.