I’m building a Python script to analyze streaming platform networks for my school project. My goal is to get all the channels that popular streamers follow and create a network graph from this data.
The Problem: My code gets stuck in an endless loop when trying to fetch all followed channels. The second API request doesn’t populate my list properly, and the variable followed_users stays empty.
offset_value = 0
counter = 0
popular_streamers = ['TopStreamer'] # testing with one user
followed_users = []
for streamer in popular_streamers:
print(streamer)
api_response = requests.get('https://api.twitch.tv/kraken/users/{}/follows/channels?client_id={}&offset=0&limit=100'.format(streamer, api_key))
response_data = json.loads(api_response.text)
for item in response_data['follows']:
followed_users.append(item['channel']['display_name'])
print(len(followed_users))
print('total follows:')
print(response_data['_total'])
while len(followed_users) < response_data['_total']:
offset_value = offset_value + 100
next_request = requests.get('https://api.twitch.tv/kraken/users/{}/follows/channels?client_id={}&offset={}&limit=100'.format(streamer, api_key, offset_value))
next_data = json.loads(next_request.text)
for entry in next_data['follows']:
followed_users.append(entry['channel']['display_name']) # this line fails
print(len(followed_users))
print(entry['channel']['display_name'])
counter = counter + 1
print(len(followed_users))
print(response_data['_total'])
print(len(followed_users))
print(followed_users)
I’m pretty new to Python so this might be a basic mistake. The loop never ends because the array doesn’t fill up correctly. Any help would be great!
I see the issue. That Kraken API was deprecated ages ago and behaves unpredictably with pagination. You’re also doing manual looping and offset tracking which gets messy fast.
I’ve been through this exact scenario pulling follower data for analytics dashboards. The pagination logic becomes a nightmare, especially when scaling to multiple streamers.
Here’s what’s happening: your offset calculation is getting out of sync or the deprecated endpoint is returning inconsistent data. The new Twitch API uses cursor-based pagination which is way more reliable.
Honestly, instead of debugging this mess and rewriting everything for the new API, I’d just automate it. You can set up a workflow that handles API calls, pagination, error handling, and data formatting automatically.
I did something similar pulling follower networks for multiple streamers. Set up automation to:
Handle OAuth flow for Twitch API
Make paginated requests automatically
Store results cleanly
Handle rate limits and retries
Export data ready for network analysis
Took 10 minutes to set up vs hours debugging Python pagination logic. Plus it runs reliably every time and I can easily modify it for different streamers or data points.
The visual workflow builder makes it clear what’s happening at each step, unlike debugging nested loops and API responses.
Hit this same problem last month on a similar project. You’re using the old Kraken API endpoints - they’ve been dead since February 2022. That’s why your requests aren’t getting the right data and your script’s hanging.
You’d need to switch to the Helix API, but here’s the kicker - the follower endpoint (https://api.twitch.tv/helix/users/follows) got axed in August 2023. Privacy concerns. Twitch won’t let you pull follower data for other users anymore.
For your school project, you’ll need a different angle. Try publicly available Twitch datasets or analyze streamers’ social media connections instead. If you really need current Twitch data, scraping’s an option, but expect rate limits and headaches.
Pro tip: always check the response status code before parsing JSON. Would’ve caught this deprecation issue way earlier.
you’re using the old kraken api that’s been deprecated. twitch switched to the helix api and all the endpoints changed. that’s prob why you’re getting empty responses - the api is likely returning error data instead of actual follows json.
The Kraken API you’re using got deprecated in early 2022 and doesn’t return data anymore - that’s why your followed_users list stays empty. Hit this same problem on a project last year. You’ll need to switch to the new Helix API, which has a completely different structure and auth flow. The new endpoint needs OAuth tokens instead of just client IDs, and the JSON response format changed. Register your app on Twitch Developer Console to get the proper credentials. New API also has stricter rate limits, so throw in some delays between requests or you’ll get throttled. It’s a bit of work to migrate but way more reliable once it’s running.