Get_follows doesn't return correct number of follows

twitch_client = TwitchClient(client_id=client_id, oauth_token=oauth_token)
prova = ['19571641']
seguiti = []
for user in prova:

    for x in range(0, 3):
        top_channel_follows = twitch_client.users.get_follows(user, limit=100, offset=q)
        q= q+100




        for x in range(0, len(top_channel_follows)):


I’m trying to get all the users followed by another user with that code. The problem is that it returns the wrong number of followed user. Checking on the page of the user the number of users followed is different. Anyone knows why or what i’m doing wrong?
Thank you :slight_smile:

How far off is the displayed total, and the list of followers you’re getting? If it’s only off by a small margin then it is likely due to banned/suspended users, as they are still included in the total but wont be returned in the list of followers.

Ooohh yes! It could totally be. For example it returns just 191 users instead of 223.
(sorry for my english)
But how can I do a cicle that tells how many calls I have to do without having a “total” ?

The API does return a total value, in the new Helix API it’s the total field, and the old API has a _total field.

Yes but that _total is the correct number while the number returned by the api is different, and smaller.

You can either keep looping until your offset is greater than the _total, or you can divide the _total by your offset increment (in this case, 100) and round up, which will give the number of times you need to loop. Either way will stop the loop once you’ve got all the results the API will give.

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