Skip to content

Instantly share code, notes, and snippets.

@bsquidwrd
Last active November 24, 2017 23:30
Show Gist options
  • Save bsquidwrd/8020fe1f1adb456d0ce85168bd7fd4ad to your computer and use it in GitHub Desktop.
Save bsquidwrd/8020fe1f1adb456d0ce85168bd7fd4ad to your computer and use it in GitHub Desktop.
Get the first follower of a channel
import requests
from dateutil.parser import parse
channel = "lassiz"
client_id = "INSERT TWITCH CLIENT ID HERE"
number_of_followers_to_print = 100
url = "https://api.twitch.tv/kraken/channels/{}/follows".format(channel)
payload = {
"direction": "asc",
"limit": "100",
}
headers = {
"Client-ID": client_id,
}
r = requests.get(url, params=payload, headers=headers).json()
for number, follower in enumerate(r["follows"]):
if number + 1 > number_of_followers_to_print:
break
count = str(number + 1)
total_followers = int(len(str(r['_total']))) # User for number padding
print(count.zfill(total_followers), parse(follower["created_at"]), follower["user"]["name"])
python-dateutil==2.6.1
requests==2.12.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment