How to get all live channels that a person follows?

So I’ve been triyng to get all channels that a user follows purely with jquery/JS. What I got so far is this:

https://api.twitch.tv/kraken/streams/followed?client_id=XXX

Is there any way to get a user’s followed channels with just their username?

My problem is that the URL only checks the currently logged in user btw.

1 Like

You can use the Get User Follows endpoint https://dev.twitch.tv/docs/api/reference/#get-users-follows and use the from_id param.

If you don’t know how to get the ID from a username, use the Get Users endpoint https://dev.twitch.tv/docs/api/reference/#get-users and specific their username as the login param. In the response will be their Twitch ID which you can use with that Get User Follows endpoint.

1 Like

Yea you will need to use the new twitch api with the ID as Dist mentioned.
But you will need to use multiple call.

You would need to call https://api.twitch.tv/helix/users/follows?from_id=xxxxx&first=100
which returns all the users that the person follows, but not who are strictly live. For the “live” part you need to call to Streams, like so:
IE: https://api.twitch.tv/helix/streams?user_id=User1&user_id=User2&user_id=User3… etc.

You might also have to repeat both of those calls multiple times if the number of follows is > 100, if you do, the second call will need to pass the cursor from the first:
https://api.twitch.tv/helix/users/follows?from_id=xxxxx&first=100&after=CURSORHERE

New twitch api is not super convient for gathering lots of information.
Like if a person has 300 followed, in order to return a full list of everyone live right now you would need to call the Follows api 3 times, then make 3 separate calls to streams in which you fill all the ID’s from the first call into the parameters. Then append the resulting json’s together to get your final list of live users a person follows.

It is a pain.

2 Likes

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