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

@blockapexofficial/social-media-analytics-client

v0.0.4

Published

A package which provides you with the analytics of major social media platforms.

Downloads

7

Readme

@blockapexofficial/social-media-analytics

A package which provides you with the analytics of major social media platforms.

Supported social media platforms

  • Facebook
  • Instagram
  • Tiktok
  • Linkedin
  • Twitter
  • Youtube
  • Twitch

Installation Guide

Install the package in your js/ts appication.

npm install @blockapexofficial/social-media-analytics
OR
yarn add @blockapexofficial/social-media-analytics

Integration Guide

Facebook

Create facebook developer account. (https://developers.facebook.com/)

Create facebook app. (https://developers.facebook.com/apps/?show_reminder=true)

Configure facebook login for your facebook app. (https://developers.facebook.com/apps/{your-app-id}/fb-login/settings/)

Add your application's server URL in Valid OAuth Redirect URIs input.

Import Facebook constructor from the sdk. Create Facebook instance.

import { Facebook } from '@blockapexofficial/social-media-analytics';

const facebook = new Facebook({
  apiKey: '',
  apiSecret: '',
  redirectLink: '',
});

You'll find apiKey as App ID and apiSecret as App Secret from your facebook app's basic settings.

Methods

facebook.getAuthorizationLink()

returns authorization link which you can attach to your login with facebook button. After successful authorization facebook will redirect user to the redirect link you provided in the constructor with authorization code in query params.

facebook.getUserAccessToken(_authorizationToken)

returns user's access token which is obtained after successful authorization from authorization link above.

facebook.getUserDetails(_accessToken): UserObject

returns user's profile info. Function takes in access token which is obtained using getUserAccessToken function.

facebook.getUserLatestPosts(_accessToken): PostObject[]

returns user's latest posts list. Function takes in access token which is obtained using getUserAccessToken function.

facebook.getPostDetails(_postIdentifiers[], _accessToken): PostObject[]

returns user's post details list. Function takes in an array of post identifiers, these are obtained using getUserLatestPosts function. Function takes in access token which is obtained using getUserAccessToken function.

Response Objects

User Object

| property | value | | ----------- | ------ | | about | string | | email | string | | first_name | string | | last_name | string | | middle_name | string | | name | string | | link | string |

Post Object

| property | value | | ------------ | ------ | | engagements | number | | impressions | number | | reactions | number | | comments | number | | shares | number | | description | string | | created_time | string | | updated_time | string | | message | string |

Instagram

Before you start you'll need.

  • An Instagram Business Account or Instagram Creator Account
  • A Facebook Page connected to that account
  • A Facebook Developer account that can perform Tasks on that Page
  • A registered Facebook App with Basic settings configured

Configure facebook login for your facebook app with permissions. (https://developers.facebook.com/apps/{your-app-id}/fb-login/settings/)

Add your application's server URL in Valid OAuth Redirect URIs input.

Import Instagram constructor from the sdk. Create Instagram instance.

Prerequisites for Users

User should have a facebook page. The Instagram account type has to be business. User should have a instagram account. The facebook page personal profile has to be connected with an actual instagram business page.

Prerequisites for Developers

The developer application has to be setup as type: business The developer app needs to have graph API access and Facebook login access with it using appropriate facebook developer application. The request needs to have the token with an appropriate permission (instagram_basics, pages_show_list) associated with it.

Implementation

import { Instagram } from '@blockapexofficial/social-media-analytics';

const instagram = new Instagram({
  apiKey: '',
  apiSecret: '',
  redirectLink: '',
});

You'll find apiKey as App ID and apiSecret as App Secret from your facebook app's basic settings.

Methods

instagram.getAuthorizationLink()

returns authorization link which you can attach to your login with instagram button. After successful authorization instagram will redirect user to the redirect link you provided in the constructor with authorization code in query params.

instagram.getUserAccessToken(_authorizationToken)

returns user's access token which is obtained after successful authorization from authorization link above.

instagram.getUserDetails(_accessToken): UserObject

returns user's profile info. Function takes in access token which is obtained using getUserAccessToken function.

instagram.getUserLatestPosts(_accessToken): PostObject[]

returns user's latest posts list. Function takes in access token which is obtained using getUserAccessToken function.

instagram.getPostDetails(_postIdentifiers[], _accessToken): PostObject[]

returns user's post details list. Function takes in an array of post identifiers, these are obtained using getUserLatestPosts function. Function takes in access token which is obtained using getUserAccessToken function.

Response Objects

User Object

| property | value | | ------------------- | ------------ | | id | string | | name | string | | username | string | | profile_picture_url | string | | biography | string | | media | PostObject[] |

Post Object

| property | value | | ------------ | ------ | | engagements | number | | impressions | number | | likes | number | | comments | number | | description | string | | created_time | string | | updated_time | string | | message | string |

Tiktok

Create Tiktok developer account.

Create Tiktok app. (https://developers.tiktok.com/apps/)

Fill in the basic information on Tiktok application dashboard.

Add login kit and Video kit as product in your Tiktok application.

In login kit find input with label Redirect domain, and add your application server's domain in it.

In Tiktok api section found at the bottom of Tiktok application dashboard. Add user.info.basic and video.list as scopes.

Submit your app for review. Tiktok SDK won't work if your app is not approved.

Import Tiktok constructor from the sdk. Create Tiktok instance.

import { Tiktok } from '@blockapexofficial/social-media-analytics';

const tiktok = new Tiktok({
  clientId: '',
  clientSecret: '',
});

You'll find clientKey and clientSecret from your tiktok application's dashboard.

Methods

tiktok.getAuthorizationLink(_redirectLink)

returns authorization link which you can attach to your login with tiktok button. After successful authorization tiktok will redirect user to the redirect link you provided in function param with authorization code in query params.

tiktok.getUserAccessToken(_authorizationToken)

returns user's access token which is obtained after successful authorization from authorization link above.

tiktok.refreshAccessToken(_refreshToken)

returns user's refreshed access token which is obtained after successful authorization from authorization link above.

tiktok.getUserProfileInfo(_accessToken): UserObject

returns user's profile info. Function takes in access token which is obtained using getUserAccessToken function.

tiktok.getUserVideoList(_accessToken, _maxResults?, _sort?): VideoObject[]

returns user's latest video list. Function takes in access token which is obtained using getUserAccessToken function.

tiktok.getVideoDetails(_postIdentifiers, _accessToken): VideoObject[]

returns user's video details list. Function takes in an array of post identifiers, which can be video ids or video urls.

Response Objects

User Object

| property | value | | ----------------- | ------- | | avatar_url | string | | bio_description | string | | display_name | string | | follower_count | number | | is_verified | boolean | | open_id | string | | profile_deep_link | string | | likes_count | number | | following_count | number | | union_id | string |

Video Object

| property | value | | ----------------- | ------ | | engagements | number | | impressions | number | | id | string | | create_time | number | | cover_image_url | string | | share_url | string | | video_description | string | | duration | number | | height | number | | width | number | | title | string | | embed_html | string | | embed_link | string | | like_count | number | | comment_count | number | | share_count | number | | view_count | number |

Twitter

Create twitter developer account. (https://developer.twitter.com/en/portal/petition/essential/basic-info)

You have to apply for developer account in order to use twitter's api service

Create twitter app. (https://developer.twitter.com/en/portal/projects-and-apps)

Get your bearer token by clicking on key icon. (https://developer.twitter.com/en/portal/projects/{projectId}/apps/{appId}/keys)

Import Twitter constructor from the sdk. Create Twitter instance.

import { Twitter } from '@blockapexofficial/social-media-analytics';

const TwitterBearerToken = 'your app bearer token';

const twitter = new Twitter({ apiToken: TwitterBearerToken });

You'll find token as Bearer Token from your twitter Projects and Apps selected app tab.

Methods

twitter.getTweetDetails(_tweetId[])

returns returns details and statistics of tweet with engagements and impressions using list of tweet ids, tweet id can be get from url bar of tweet detail page

twitter.getLatestTweets(_username[])

returns list of most recent 10 tweets of users using username, tweets id can be get from url bar of tweet detail page

twitter.getUserDetails(_userName[])

returns list of user details using list of twitter username, tweets id can be get from url bar of tweet detail page

Youtube

Create gmail account.(https://accounts.google.com/signup/v2/webcreateaccount?flowName=GlifWebSignIn&flowEntry=SignUp)

Create project on Google console. (https://console.cloud.google.com/)

Enable youtube v3 apis from. (https://console.cloud.google.com/apis/library/youtube.googleapis.com)

Create Api key for your app integration from. (https://console.cloud.google.com/apis/credentials)

Import youtube constructor from the sdk. Create youtube instance.

import { Youtube } from '@blockapexofficial/social-media-analytics';

const youtubeBearerToken = 'your app api token';

const youtube = new Youtube({ apiToken: youtubeBearerToken });

You'll find token as Api token from your google console project (https://console.cloud.google.com/apis/credentials).

Methods

youtube.getVideoDetails(videoUrls[])

returns details of video(s) with engagements and impressions using list of video urls, videos url can be get from url bar of video page

youtube.getLatestVideos(videoUrls[])

returns list of most recent 10 videos of channel(s) using list of video urls, videos url can be get from url bar of video page

youtube.getChannelDetails(channelUrls[])

returns list of channel details using array of channel urls in an array, videos url can be get from url bar of video page of youtube

Response Objects

Channel Object

| property | value | | -----------------------| ------- | | id | string | | title | string | | description | string | | customUrl | string | | publishedAt | string | | thumbnails | Object | | country | string | | localized | Object | | viewCount | string | | subscriberCount | string | | hiddenSubscriberCount | boolean | | videoCount | string |

Video Object

| property | value | | ------------------------ | ----------------| |publishedAt | string | |channelId | string | |title | string | |description | string | |thumbnails | Object | |channelTitle | string | |tags | Array | |categoryId | string | |liveBroadcastContent | string | |localized | Object | |viewCount | string | |likeCount | string | |favoriteCount | string | |commentCount | string | |impressions | number | |engagements | number |

LinkedIn

Create linkedIn account.(https://www.linkedin.com/login)

Create an App. (https://developer.linkedin.com/) + user will need a linkedIn page to connect their app.

verify your app with page. (https://www.linkedin.com/developers/apps/{your app id}/settings)

set your authorized redirect urls to allow access to your url. (https://www.linkedin.com/developers/apps/{your app id}/auth)

User have to apply for Marketing Developer Platform in order to get access to api to fetch organization and user data (https://console.cloud.google.com/apis/credentials) applying to marketing developer platform may take some days to verify your access request. although app cannot get access to user data due to resource restriction from linkedIn.

Get your application creadentions such as Client ID and Client Secret (https://www.linkedin.com/developers/apps/{your app id}/auth)

Import LinkedIn constructor from the sdk. Create linkedIn instance.

import { LinkedIn } from '@blockapexofficial/social-media-analytics';

const clientId = '78owxoz0fwu37s';
const clientSecret = 'aSypQ3MbeDDDAzAT';
const redirect_uri = 'https://testsocialapis.web.app/login/linkedin'; //should be same as you setted on application auth page


const linkedIn = new LinkedIn({
    clientId,
    clientSecret,
    apiUrl: 'https://testsocialapis.web.app/login/linkedin',
  });

Methods

linkedIn.getAuthorizationLink(redirect_uri)

returns authorization link which user can add on their auth button. This will redirect user to the social media platform and will ask them to authorize the given permissions. After successful authorization social media platform will redirect on the given redirect link in the constructor param with the auth code in the query params, which should be extracted and used to give them the access token for that particular user.

linkedIn.getAccessToken(_authenticationCode: string, _redirectLink: string)

returns user access token object by using authentication code obtain by using getAuthorizationlink methods url. access token then can be use to authenticate user while using other methods by sending access token in methods _accessToken parameter.

linkedIn.getAccessTokenFromRefreshToken(_refreshToken: string)

returns user access token object by using refresh token obtain by using getAccessToken methods url. access token then can be use to authenticate user while using other methods.

linkedIn.getOrgLatestPosts(_accessToken: string, _orgNames: string[])

returns organization's latest 10 posts list of multiple organizations taken as an array in parameter. Function takes in access token which is obtained using getAccessToken function.

linkedIn.getOrgPostDetails(_accessToken: string, _postUrls: string[])

returns organization's post details of multiple urls taken in an array as parameter. Function takes in array of post urls, these are obtained from url of post page in linkedIn function. Function takes in access token which is obtained using getUserAccessToken function.

linkedIn.getOrgDetails(_accessToken: string,_orgNames: string[],_getFollowers: boolean = true)

returns organization details by name. function take list of organization names as parameters and fetch details for all. second parameter "_getFollowers" is optional and true by default.

Response Objects

Organization Object

| property | value | | ----------------- | ------- | | orgId | string | | orgName | string | | orgWebsite | string | | orgAddress | number | | orgLogo | boolean | | orgFollowers | string |

Post Object

| property | value | | ------------------------ | --------------------------| |isReshareDisabledByAuthor | boolean | |createdAt | number | |postState | string | |lastModifiedAt | number | |visibility | string | |publishedAt | number | |title | string | |isEditedByAuthor | boolean | |content | { media: { id: string } } | |totalFirstLevelComments | number | |aggregatedTotalComments | number | |likedByCurrentUser | boolean | |totalFirstLevelLikes | number | |aggregatedTotalLikes | number | |impressions | number | |engagements | number |

Twitch

Create twitch account by signing up or loging in.(https://www.twitch.tv/)

Create an App. (https://dev.twitch.tv/console), user will need a twitch account with two factor authentication enabled.

Add your redirected urls.

Create secret and save it to integrate with your app. (https://dev.twitch.tv/console/apps/{your app id})

Copy client id with client secret as well.

Get your application creadentions such as Client ID and Client Secret

Import Twitch constructor from the sdk. Create twitch instance.

import { Twitch } from '@blockapexofficial/social-media-analytics';

const clientSecret = 'your client secret';

const clientId = 'your client id';
const twitchApp = new Twitch({ clientId: clientId, clientSecret: clientSecret });

Methods

twitchApp.getAccessToken()

returns authorization link which user can add on their auth button. This will redirect user to the social media platform and will ask them to authorize the given permissions. After successful authorization social media platform will redirect on the given redirect link in the constructor param with the auth code in the query params, which should be extracted and used to give them the access token for that particular user.

twitchApp.getVideos(_videoUrls: string[], _accessToken: string)

returns user list of user details by username. array of username and a access token is required to fetch details. access token can be retrieve by using getAccessToken methods.

twitchApp.getClips(_clipsUrls: string[], _accessToken:string)

returns list of clips from live streams details by clip url. array of clip url and a access token is required to fetch details. access token can be retrieve by using getAccessToken methods.

twitchApp.getLatestLiveStreams(_userNames_: string[], _accessToken:string)

returns list of latest videos including streams and clips details by list of usernames present in url. array of video Ids and a access token is required to fetch details. access token can be retrieve by using getAccessToken methods.

twitchApp.getUsers(_userNames_: string[], _accessToken:string)

returns user list of user details by username. array of username and a access token is required to fetch details. access token can be retrieve by using getAccessToken methods.

Response Objects

User/Channel Object

| property | value | | ----------------- | ------- | |id | string | |login | string | |display_name | string | |type | string | |broadcaster_type | string | |description | string | |profile_image_url | string | |offline_image_url | string | |view_count | number | |followers | number | |email? | string | |created_at | string |

Live Stream Object

| property | value | | ----------------- | --------------| | id | string | | user_id | string | | user_login | string | | user_name | string | | game_id | string | | game_name | string | | type | string | | title | string | | viewer_count | number | | started_at | string | | language | string | | thumbnail_url | string | | tag_ids | Array | | is_mature | false |

Video Object

| property | value | | ----------------- | --------------| | id |string | | stream_id |string | | user_id |string | | user_login |string | | user_name |string | | title |string | | description |string | | created_at |string | | published_at |string | | url |string | | thumbnail_url |string | | viewable |string | | view_count |number | | language |string | | type |string | | duration |string | | muted_segments |null | [string]|

Clip Object

| property | value | | ----------------- | ---------------| | id | string | | url | string | | embed_url | string | | broadcaster_id | string | | broadcaster_name | string | | creator_id | string | | creator_name | string | | video_id | string | | game_id | string | | language | string | | title | string | | view_count | number | | created_at | string | | thumbnail_url | string | | duration | number | | vod_offset | number |