Jump to content




Kd's Twitch Interface-API

utility api lua

2 replies to this topic

#1 kd8lvt

  • Members
  • 12 posts

Posted 07 November 2015 - 12:51 AM

Have you ever wanted to know when a certain streamer is live, but you don't want to leave the game? Perhaps you want a quick easy way to see your latest follower? Maybe you want to see your viewer or follower count? You probably want a computerized solution to this problem, yeah? Want to make it easier on yourself with an API? Well, here is what you have been looking for all along!

Kd's Twitch Interface-API

The basic gist of how this works: It uses the JSON api (found here though it auto-downloads) by the talented ElvishJerricco
It asks the twitch API servers for a streamer's stream (or follows) element you specify (see usage below) and then spits out information regarding the function you choose. I highly recommend having a second or so sleep every four or so times you 'ping' Twitch, otherwise you may get temporarily banned from the Twitch api ;)

USAGE:
os.loadAPI("twitchapi")
twitchapi.live("wolftaz",colors.green,colors.red) -- argumets: streamer name, live color, NOT live color
OR...
os.loadAPI("twitchapi")
if twitchapi.checkLive("choobtastic") then
  print("Live!")
else
  print("Not live!")
end
OR...
os.loadAPI("twitchapi")
print(twitchapi.lastFollower("rebelofroses")
OR...
os.loadAPI("twitchapi")
print(twitchapi.followerCount("EthanRay10"))
OR...
os.loadAPI("twitchapi")
print(twitchapi.viewerCount("kd8lvt"))
OR...
os.loadAPI("twitchapi")
print(twitchapi.viewCount("leavaris")) --This only works when the stream is LIVE! Additionally, View count it DIFFERENT from current VIEWERS! This is how many times the stream page has been loaded!
If you want, here is the code so you can suggest improvements:
Spoiler
DOWNLOADS:

API: pastebin get vh4Jd1B6 twitchapi
EXAMPLE: pastebin get BkR9un49 example

NEW! My friend, Funniray, has slightly edited the API for beam.pro use!
pastebin get wbPC0Zv7 beamapi

Edited by kd8lvt, 04 January 2016 - 03:13 PM.


#2 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 07 November 2015 - 08:05 AM

Maybe you can add an option telling the API to check NOW which would allow you to not flood the twitch servers and to check whenever YOU want.

#3 kd8lvt

  • Members
  • 12 posts

Posted 07 November 2015 - 12:03 PM

I'm not sure I understand what you mean, it only checks when you call the function "live" which is checking now - and I'm not sure what you mean by "check whenever YOU want"
==EDIT==
OH, it can do three or four 'pings' in a row, but once you get to five it gets a bit dicey. Maybe I should word that differently.

Edited by kd8lvt, 07 November 2015 - 12:05 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users