How to get every followers?

Hello!

I’m using Python 3 and Twitch API v5 in the project about “association between streamers”.
I want to get list of all channel followers. I just tried an offset, but the number of followers is limited to about 1600.
This is function of code, but this code could only get a limited number of followers.

def collectFollower(channel, lim, Clientid, File, Offset):
url = ("https://api.twitch.tv/kraken/channels/"+ str(channel) +
       "/follows?limit=" + str(lim) + "&offset=" + str(Offset))
req = urllib.request.Request(url, headers = {"Client-ID": Clientid, "Accept" : "application/vnd.twitchtv.v5+json"})
u = urllib.request.urlopen(req)
c = u.read().decode('utf-8')
js = json.loads(c)

#print(str(Offset))
#print(str(js["_cursor"]))

for num in range(lim):
    file.write(str(js["follows"][num]["user"]["name"]) + "\n")

When I searched through Google, I saw that I used the cursor to solve it. How do you use your cursor? If I can’t use it, how to solve?

Please Help Me!

You will need to basically recurse over the endpoint using your pagination information (cursor) until you don’t get a ful response (Length of the follower array is smaller than limit).

As the Docs specify, you can pass the _cursor to the endpoint as a query paramter named cursor to let the server know what the offset is offsetting from.

As a my result, the value of _cursor decreased irregularly when increasing the value of the offset.
How does the value of the _cursor change when the parameter cursor changes?
And when the value of the parameter cursor changes, how does the scope of the follower ID that the Twitch API brings change?

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