Skip to main content

Object oriented SocialBlade API wrapper

Project description

Socialblade API wrapper.

Examples

Live YouTube subscriber count

Prints PewDiePie’s subscriber count in real time.

from socialblade import YouTubeChannel


pewdiepie_channel = YouTubeChannel('UC-lHJZR3Gqxm24_Vd_AJ5Yw')

for sub in pewdiepie_channel.live_subscriber_count_generator():
    print(sub)

You could also just get the subscriber count as it is at the time, like this:

from socialblade import YouTubeChannel


pewdiepie_channel = YouTubeChannel('UC-lHJZR3Gqxm24_Vd_AJ5Yw')

print(pewdiepie_channel.get_subscriber_count())

Export a Channel’s Most Viewed Videos Statistics to CSV

In this example we are exporting statistics about PewDiePie’s most viewed videos to CSV.

from socialblade import YouTubeChannel
import csv
from datetime import datetime
import locale


locale.setlocale(locale.LC_ALL, '')


def create_more_readable_ints(integer):
    return locale.currency(integer, symbol=False, grouping=True).replace('.00', '').replace(',', "'")


pewdiepie_channel = YouTubeChannel('UC-lHJZR3Gqxm24_Vd_AJ5Yw')

writer = csv.writer(
    open(
        'PewDiePie Most Viewed Videos {}.csv'.format(str(datetime.now().date())),
        'w',
        newline='',
        encoding='utf-8'
    )
)
writer.writerow(
    ['Channel', 'Title', 'Created at', 'Views', 'Comments']
)
for video in pewdiepie_channel.get_most_viewed_videos():
    writer.writerow(
        [
            'PewDiePie',
            video.title,
            str(video.created_at),
            create_more_readable_ints(video.views_num),
            create_more_readable_ints(video.comments_num)
        ]
    )

You could do the same thing to any channel. You could also export different types of statistics about videos, which I will list the functions for them here:

  • socialblade.YouTubeChannel(channel_id).get_latest_videos()

  • socialblade.YouTubeChannel(channel_id).get_most_viewed_videos()

  • socialblade.YouTubeChannel(channel_id).get_highest_rated_videos()

  • socialblade.YouTubeChannel(channel_id).get_most_relevant_videos()

Get live Twitter follower count

The Twitter functionality is limited in this wrapper to retrieving follower counts. You could get a Twitter user’s live follower count similer to how you get a youtuber’s live follower count:

from socialblade import TwitterUser


donald_trump_twitter = TwitterUser('realdonaldtrump')

for follower in donald_trump_twitter.live_follower_count_generator(request_delay=500):
    print(follower)

You could also get the follower count as it is at the moment, like so:

from socialblade import TwitterUser


donald_trump_twitter = TwitterUser('realdonaldtrump')

print(donald_trump_twitter.get_follower_count())

Get live Twitch and StoryFire follower counts

Like Twitter, Twitch and StoryFire functionality is also limited to retrieving follower counts. You could compare the follower counts of a user’s multiple platforms, whether that be Twitch and Twitter…:

from socialblade import TwitterUser, TwitchUser


user = 'michaelreeves'

reeves_twitter = TwitterUser(user)
reeves_twitch = TwitchUser(user)

twitter_followers = reeves_twitter.get_follower_count()
twitch_followers = reeves_twitch.get_follower_count()

if twitter_followers > twitch_followers:
    print(f"{user} has {twitter_followers - twitch_followers} more followers on Twitch than on Twitter.")
else:
    print(f"{user} has {twitch_followers - twitter_followers} more followers on Twitter than on Twitch.")

…or StoryFire and YouTube:

from socialblade import YouTubeChannel, StoryFireUser


rgt_youtube = YouTubeChannel('UCA5RGaQc-a8tIX_AqTTmWdw')
rgt_storyfire = StoryFireUser('1fozx1kcs0tuj3')

for sf_subscribers in rgt_storyfire.live_subscriber_count_generator():
    for yt_subscribers in rgt_youtube.live_subscriber_count_generator():
        print(f"{yt_subscribers} on YouTube vs {sf_subscribers} on StoryFire.")

Get live Dailymotion follower counts.

from socialblade import DailymotionUser
newsy = DailymotionUser('newsy')
print(newsy.get_follower_count())
for follower in newsy.live_follower_count_generator(request_delay=500):
    print(follower)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

socialblade-1.0.4.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

socialblade-1.0.4.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file socialblade-1.0.4.2.tar.gz.

File metadata

  • Download URL: socialblade-1.0.4.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for socialblade-1.0.4.2.tar.gz
Algorithm Hash digest
SHA256 3307ebbfa78fcf33cdcea16280e82f393a3ba4a8a59ff3f5244df1e4b4606fbe
MD5 c09233736b0f7e18a249fe3b90cc3d68
BLAKE2b-256 1254f5c24e17698617c07b25b0559da84c427c799bea196049316df8ecf5486c

See more details on using hashes here.

File details

Details for the file socialblade-1.0.4.2-py3-none-any.whl.

File metadata

  • Download URL: socialblade-1.0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for socialblade-1.0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c512bd820dd5a15356107e16faf9aaf3727c3a8aea891aa18c52606cdb5bdd96
MD5 abaadd38bbccadb4f0b263a3723a074a
BLAKE2b-256 232efa0b150e795329beb304bdb9f0017ecc96a2461141d54787cea43f957f01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page