socialblade

package module
v0.0.0-...-31035d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Social Blade API in Go

Build Status GoDoc Personal Discord Social Blade Discord


Information and Disclaimer

Just because I work for Social Blade does not mean this is an official library. This is an unofficial library created for my personal convenience on my personal time.

This library supports most of the api.socialblade.com endpoints that are being exposed by either the official Social Blade Browser Extensions, Apps, or Website. Any endpoints that are not exposed publically will not be added until done so.

Social Blade's API is a private API used for Social Blade official tools and for companies with express written permission. Use of the Social Blade API without express permission is prohibited by the active Terms of Service and may result in being blocked from the Social Blade website and all of it's data.


Install

go get github.com/TimothyCole/socialblade-go

Usage

Import the library into your project.

import "github.com/TimothyCole/socialblade-go"

Construct a new client which will be used to access the API by using the third-party Auth function.

// Third-Party Auth
sb, err := socialblade.Auth("Third-Party API Key")

Example

Getting YouTube Stats

sb, _ := socialblade.Auth("Third-Party API Key")
stats, _ := sb.StatsYouTube("EatTim")
fmt.Printf("%s has %s subs \n", stats.Data.DisplayName, stats.Data.Subs)

Troubleshooting

If you have official access to the Social Blade API via express permission from the company then feel free to contact me via Twitter or email me for any help.

Documentation

Index

Constants

View Source
const (
	// SectionYouTube is the favourite section for YouTube
	SectionYouTube = section("youtube")
	// SectionTwitch is the favourite section for Twitch
	SectionTwitch = section("twitch")
	// SectionTwitter is the favourite section for Twitter
	SectionTwitter = section("twitter")
	// SectionInstagram is the favourite section for Instagram
	SectionInstagram = section("instagram")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the authed data for the client

func Auth

func Auth(key string) (*Client, error)

Auth allows you to authenticate with a third-party api key

func AuthAsAnon

func AuthAsAnon() *Client

AuthAsAnon allows you to create a client without needing creds to access unlocked endpoints

func AuthAsService

func AuthAsService(token string) *Client

AuthAsService allows you to create a client with a service based api token

func AuthAsUser

func AuthAsUser(email, token string) (*Client, error)

AuthAsUser allows you to authenticate with an email and account token

func (*Client) CheckFavourited

func (c *Client) CheckFavourited(sec section, id string) bool

CheckFavourited gets a list of a users favourites (User auths only)

func (*Client) Favourite

func (c *Client) Favourite(sec section, id string) error

Favourite gets a list of a users favourites (User auths only)

func (*Client) GetFavourites

func (c *Client) GetFavourites() ([]Favourite, error)

GetFavourites gets a list of a users favourites (User auths only)

func (*Client) StatsTwitch

func (c *Client) StatsTwitch(identifier string) (*TwitchStatsData, error)

StatsTwitch returns stats for a specific Twitch Channel

func (*Client) StatsYouTube

func (c *Client) StatsYouTube(identifier string) (*YouTubeStatsData, error)

StatsYouTube returns stats for a specific YouTube Channel

func (*Client) Team

func (c *Client) Team() (*TeamData, error)

Team gets a list of the Social Blade Team

func (*Client) TopTwitch

func (c *Client) TopTwitch(filter string) (*TwitchTopList, error)

TopTwitch get the top YouTube Users

func (*Client) TopYouTube

func (c *Client) TopYouTube(filter string) (*YouTubeTopList, error)

TopYouTube get the top YouTube Users

func (*Client) Unfavourite

func (c *Client) Unfavourite(sec section, id string) error

Unfavourite gets a list of a users favourites (User auths only)

type Favourite

type Favourite struct {
	Username string `json:"username,omitempty"`
	Section  string `json:"section,omitempty"`
	Data     struct {
		Followers string `json:"followers,omitempty"`
		Tweets    string `json:"tweets,omitempty"`
		Avatar    string `json:"avatar,omitempty"`
		Banner    string `json:"banner,omitempty"`
		Name      string `json:"name,omitempty"`
	} `json:"data,omitempty"`
	Growth []struct {
		Followers string `json:"followers,omitempty"`
		Following string `json:"following,omitempty"`
		Tweets    string `json:"tweets,omitempty"`
		Favorites string `json:"favorites,omitempty"`
		Date      string `json:"date,omitempty"`
	} `json:"growth,omitempty"`
	Type string `json:"type,omitempty"`
}

Favourite is the data of a user favourite

type TeamData

type TeamData struct {
	Team []struct {
		Name    string   `json:"name"`
		Title   string   `json:"title,omitempty"`
		Image   string   `json:"image,omitempty"`
		Socials []string `json:"socials,omitempty"`
		Discord int64    `json:"discord"`
	} `json:"team"`
}

TeamData is the struct for the Social Blade Team

type TwitchStatsData

type TwitchStatsData struct {
	Status struct {
		Response int         `json:"response"`
		Error    interface{} `json:"error"`
		Message  string      `json:"message"`
	} `json:"status"`
	ID struct {
		Results  int    `json:"results"`
		TwitchID int    `json:"twitch_id"`
		Username string `json:"username"`
		Mod      string `json:"mod"`
	} `json:"id"`
	Data struct {
		Username           string `json:"username"`
		Game               string `json:"game"`
		Status             string `json:"status"`
		Avatar             string `json:"avatar"`
		Banner             string `json:"banner"`
		Followers          int    `json:"followers"`
		Followersdaygain   int    `json:"followersdaygain"`
		Followersmonthgain int    `json:"followersmonthgain"`
		Avgdailyfollowers  int    `json:"avgdailyfollowers"`
		Avgdailyviews      int    `json:"avgdailyviews"`
		Activity           int    `json:"activity"`
		Views              int    `json:"views"`
		Viewsdaygain       int    `json:"viewsdaygain"`
		Viewsmonthgain     int    `json:"viewsmonthgain"`
		CreatedAt          string `json:"created_at"`
		IsVerified         int    `json:"isVerified"`
	} `json:"data"`
	Rank struct {
		Rank        interface{} `json:"rank"`
		Vidviewrank interface{} `json:"vidviewrank"`
		Grade       struct {
			Raw     interface{} `json:"raw"`
			Grade   string      `json:"grade"`
			Display string      `json:"display"`
		} `json:"grade"`
	} `json:"rank"`
	DataDaily []struct {
		Date      string `json:"date"`
		Followers int    `json:"followers"`
		Views     int    `json:"views"`
	} `json:"data_daily"`
}

TwitchStatsData is data for YouTube Stats

type TwitchTopList

type TwitchTopList struct {
	Status struct {
		Cache    string `json:"cache"`
		Type     string `json:"type"`
		Response int    `json:"response"`
	} `json:"status"`
	Result []struct {
		Username          string      `json:"username"`
		Displayname       interface{} `json:"displayname"`
		Followers         string      `json:"followers"`
		Views             string      `json:"views"`
		Avgdailyfollowers string      `json:"avgdailyfollowers"`
		Avgdailyviews     string      `json:"avgdailyviews"`
		CreatedAt         string      `json:"created_at"`
		Game              string      `json:"game"`
		Status            string      `json:"status"`
		// rank_followers and rank_channelviews currently have a glich where the filtered type (followers/views) will be an int and the other will be a string
		//  it's an interface so it to unmarshal correctly and you can still use it by check the type of it first
		RankFollowers    interface{} `json:"rank_followers"`
		RankChannelviews interface{} `json:"rank_channelviews"`
	} `json:"result"`
}

TwitchTopList is used for youtube top lists

type YouTubeStatsData

type YouTubeStatsData struct {
	Status struct {
		Response int         `json:"response"`
		Error    interface{} `json:"error"`
		Message  string      `json:"message,omitempty"`
	} `json:"status"`
	ID struct {
		Type      string `json:"type,omitempty"`
		ChannelID string `json:"channelid,omitempty"`
		Username  string `json:"username,omitempty"`
		CUsername string `json:"cusername,omitempty"`
	} `json:"id"`
	Data struct {
		Username      string `json:"username"`
		DisplayName   string `json:"displayname"`
		CreatedAt     string `json:"created_at"`
		Uploads       string `json:"uploads"`
		Subs          string `json:"subs"`
		Views         string `json:"views"`
		CountryCode   string `json:"country_code"`
		Country       string `json:"country"`
		ChannelType   string `json:"channeltype"`
		Avatar        string `json:"avatar"`
		Banner        string `json:"banner"`
		AvgDailySubs  string `json:"avgdailysubs"`
		AvgDailyViews string `json:"avgdailyviews"`
		Partner       string `json:"partner"`
		IsVerified    string `json:"isVerified"`
	} `json:"data,omitempty"`
	Rank struct {
		SBRank          string `json:"sbrank"`
		Rank            string `json:"rank"`
		ViewsRank       string `json:"viewsrank"`
		CountryRank     string `json:"countryrank"`
		ChannelTypeRank string `json:"channeltyperank"`
		Raw             struct {
			Sbrank          string `json:"sbrank"`
			Rank            string `json:"rank"`
			Viewsrank       string `json:"viewsrank"`
			Countryrank     string `json:"countryrank"`
			Channeltyperank string `json:"channeltyperank"`
		} `json:"raw"`
		GradeRaw string `json:"grade_raw"`
		Grade    string `json:"grade"`
	} `json:"rank,omitempty"`
	Charts struct {
		Subs struct {
			Subs14  string `json:"subs14"`
			Subs30  string `json:"subs30"`
			Subs60  string `json:"subs60"`
			Subs90  string `json:"subs90"`
			Subs180 string `json:"subs180"`
			Subs365 string `json:"subs365"`
		} `json:"subs"`
		Views struct {
			Views14  string `json:"views14"`
			Views30  string `json:"views30"`
			Views60  string `json:"views60"`
			Views90  string `json:"views90"`
			Views180 string `json:"views180"`
			Views365 string `json:"views365"`
		} `json:"views"`
		Growth struct {
			Subs  string `json:"subs"`
			Views string `json:"views"`
		} `json:"growth"`
	} `json:"charts,omitempty"`
	Social struct {
		Googleplus string `json:"googleplus,omitempty"`
		Facebook   string `json:"facebook,omitempty"`
		Twitter    string `json:"twitter,omitempty"`
		Instagram  string `json:"instagram,omitempty"`
	} `json:"social,omitempty"`
	DataDaily []struct {
		Date  string `json:"date"`
		Subs  string `json:"subs"`
		Views string `json:"views"`
	} `json:"data_daily,omitempty"`
}

YouTubeStatsData is data for YouTube Stats

type YouTubeTopList

type YouTubeTopList struct {
	Status struct {
		Cache    string `json:"cache"`
		Type     string `json:"type"`
		Response int    `json:"response"`
	} `json:"status"`
	Result []struct {
		Username          string `json:"username"`
		Channelid         string `json:"channelid"`
		Cusername         string `json:"cusername"`
		Displayname       string `json:"displayname"`
		Subscribers       string `json:"subscribers"`
		Vidviews          string `json:"vidviews"`
		Uploads           string `json:"uploads"`
		CreatedAt         string `json:"created_at"`
		Channeltype       string `json:"channeltype"`
		Country           string `json:"country"`
		Avgdailyviews     string `json:"avgdailyviews"`
		Views30           string `json:"views30"`
		Views365          string `json:"views365"`
		Sbrank            string `json:"sbrank"`
		RankSubscribers   int    `json:"rank_subscribers"`
		RankViews         string `json:"rank_views"`
		EstimatedEarnings struct {
			Daily struct {
				Low  float32 `json:"low"`
				High float32 `json:"high"`
			} `json:"daily"`
			Monthly struct {
				Low  float32 `json:"low"`
				High float32 `json:"high"`
			} `json:"monthly"`
			Yearly struct {
				Low  float32 `json:"low"`
				High float32 `json:"high"`
			} `json:"yearly"`
		} `json:"estimated_earnings"`
	} `json:"result"`
}

YouTubeTopList is used for youtube top lists

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL