vorisi
November 21, 2014, 7:34am
1
I am writing a greasemonkey script and I need to fetch the current follower count from the api.
Twitch.api.get("channels/target").done(function(channel){ console.log(channel); });
When the above line is entered into console, it spits out an object that contains a lot of information, but not all of the information contained in the channel object, including the follower count.
Is this behavior intended?
Freddy
November 21, 2014, 12:49pm
2
you can get the current follower count by calling
Twitch.api.get(“channels/:name/follows”).done(function(channel){ console.log(channel._total); });
1 Like
night
November 21, 2014, 5:50pm
3
vorisi:
I am writing a greasemonkey script and I need to fetch the current follower count from the api.
Twitch.api.get(“channels/target”).done(function(channel){ console.log(channel); });
When the above line is entered into console, it spits out an object that contains a lot of information, but not all of the information contained in the channel object, including the follower count.
Is this behavior intended?
You’re pulling the entire channel object, so you need to grab the followers from the output object.
Twitch.api.get("channels/:name").done(function(channel){ console.log(channel.followers); });
vorisi
November 21, 2014, 8:24pm
4
@night the Channel object does not have a followers property according to my Firefox Element Inspecter
If you’re looking for total amount of channels followed, Freddy was correct.
If you want to know how many objects are in the follows array that was returned. Then do this.
Twitch.api.get(“channels/:name/follows”).done(function(json){ console.log(json.follows.length); });
EDIT: changed “channels array” to “follows array” and “of followers” to “of channels followed,”
Hi Freddy,
how would a websites code look like, that simply has the number of followers as an output? (I am no Developer, thus it would be nice to have a noobfriendly explanation)
I want to generate a website that displays the number of followers as text to embed that then into a costom command of the nightbot.
greetz, Frank