Follower number response inconsistencies

Hi all,

I have been trying to pull some viewership and follower data from the API using Python. I generally make a page requests for a games page for the top channels. For example, the top 5 channels for LoL:

url = 'https://api.twitch.tv/kraken/streams?limit=5&offset=0&game=League+of+Legends&broadcaster_language=&on_site=1'

data = requests.get(url)
data = data.json()  
for channel in data['streams']:
    print(channel)

Now, this returns all the data for the top five channels. I, however, find that if i want to iterate through the followers of all these channels I sometimes get returned key errors. For example

for channel in data['streams']:
    print(channel['channel']['followers'])

This returns followers for most of the channels, and then once in a while (differs per channel every time) it fails to return the followers. I have gone through the API page as well and I am not able to find the follower key in the request.

http://pastebin.com/3PNb2Vk9

As you can see in the file in the link, the RiotGames2 channel does have followers included, but the MushIsGosu channel does not return the same API format.

I wanted to note that if I run the same code 2 seconds later it will not give a key error for MushIsGosu but likely for another channel. Sometimes it also just gives follower data for all of them, but I get an incomplete response more often.

Does anyone know what I am doing wrong or what is going on here?

Cheers,

Pieter

This is a bug that I have already reported.

The problem you are experiencing is that the user object is being returned instead of the channel object for the channel requested.

Unfortunately this appears to be a caching bug, and as far as I’m aware there’s underlying technical challenges which prevent its immediate possibility of being fixed.

Hi!

Thank you for your response! At least I know it wasn’t a problem on my end then. I will just add an exception for key errors until it is fixed then. Is there any place I can find these ‘known bugs’?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.