0.0.2 • Published 2 years ago
get-social-avatar v0.0.2
This package help to get user's avatar from social.
Supported social network types
- Telegram
Get social network type
import { getSocialByLink } from 'get-social-avatar';
const link = https://www.facebook.com/UkraineUA.MFA;
const type = getSocialByLink(link); // ----> facebook
Social network type's enum
import { SocialType } from 'get-social-avatar';
const facebookType = SocialType.FACEBOOK; // ----> facebook
Get avatar by social network type
import { SocialType, getImageByType } from 'get-social-avatar';
const socialLink = https://www.facebook.com/UkraineUA.MFA;
const avatarUrl = await getImageByType({
url: socialLink,
type: SocialType.FACEBOOK,
canBeUsername: false,
});
Where:
url
- link or username of user's profiletype
- social network type (SocialType
)canBeUsername
- indicates if url can be an username
Examples
await getImageByType({
url: 'https://www.facebook.com/UkraineUA.MFA',
type: SocialType.FACEBOOK,
canBeUsername: false,
});
await getImageByType({
url: 'https://twitter.com/Ukraine',
type: SocialType.TWITTER,
canBeUsername: false,
});
Telegram
await getImageByType({
url: '@Ukraine',
type: SocialType.TELEGRAM,
});
Get avatar from url (get type automatically):
import { SocialType, getImageFromUrl } from 'get-social-avatar';
const socialLink = https://www.facebook.com/UkraineUA.MFA;
const avatarUrl = await getImageFromUrl({
url: socialLink,
canBeUsername: false,
});