Useful Custom APIs

Omg! Thanks so much this is absolutely incredible because users in my channel have been dying to figure out for months on how to know how long they have been following for due to the rules in my chat to become moderator they must be following for x amount of months before they can become a moderator. So this has been extremely helpful. Thank you!!

1 Like

No worries, glad it helped!

1 Like

Hi,

The URL for getting a random subscriber username seems to always answer with an empty string (https://apis.rtainc.co/twitchbot/randomsub?token=TOKEN). I have tried the other feature related to subscribers (/subbed, to know for how long someone has been a subscriber) and the token I used is working. So is this API feature still working?

1 Like

You need the token of a partnered streamer on twitch. Subscribing isnā€™t the same as following on twitch.

1 Like

I know, as I said I have tried /subbed with a token and that worked, I was implying that it returned what was expected and thus that I am testing it with a token from a partnered stream. The same token does not work for /randomsub (it always returns an empty string).

Iā€™ve actually just written my own version of a randomsub script and I could get it to work so there is definitely something wrong with hereā€¦

1 Like

@fireb0mb1

Try this URL:

https://api.rtainc.co/twitch/random-sub?token=TOKEN
1 Like

It works! Thanks for the quick fix. Thereā€™s just a PHP notice when the token isnā€™t valid, specified or if the channel isnā€™t partnered (most likely itā€™s just about handling the Twitch API response that has an error property set), but it shouldnā€™t be an issue for this use senario. For reference hereā€™s the notice:

Notice: Undefined index: message in /home/rtainc/www/api.rtainc.co/twitch/random-sub.php on line 4

Could I ask you which RNG function you are using for the random drawing? When Iā€™ve coded a similar feature Iā€™ve noticed that it wasnā€™t giving me that of a random drawing with array_rand (in the case of a quick succession of drawingsā€¦ as Iā€™ve added the ability to have more than 1 drawing to be done at the same time), so Iā€™ve used mt_rand and coded my own simple mt_rand_array in the end.

Again, thanks for your reactivity :slight_smile:

For https://apis.rtainc.co/twitchbot/following?channel=CHANNEL&user=USER how can I make it to output Years, Months, Weeks, Days, & Seconds? Not just

As far as I know there is only one output format for the following command. Unless another gets added, then your out of luck. Youā€™re more than welcome to create your own customapi.

1 Like

Edit: Scroll down for updated command.

1 Like

Iā€™m looking for like "Animatedpanda has been following Channel for 1 year, 4 Months, 6 days.

You can append how many units of time you want to the new URL -

GET https://api.rtainc.co/twitch/followed-since?channel=kdwolf77&user=rtainc&units=6
5 months, 3 weeks, 2 days, 4 hours, 8 minutes, 53 seconds

Fixed!


By default it uses array_rand but you may now specify &method=mt_rand if you prefer its results.

1 Like

Very nice addition! Thank you.

@rtainc hey man can you make an API command to read ā€œSOLO MMRā€ or ā€œHero winrateā€ for DOTA (Defense of the ancients) from this website? dotabuff.com/players/114827878 ā€¦ if you already have something like this, please share :slight_smile:

Thanks for the suggestion! Unfortunately Dotabuff doesnā€™t provide any type of API, and I do not have any knowledge on how DotA stats are stored, so I am (at current) unable to do so. If you do end up finding any type of DotA Stats site with links to an API, Iā€™ll be happy to implement it for a Nightbot command. :smile:

Just read your message. Thank you so much. Exactly what I was looking for.

Hi can anyone please make a customapi to make nightbot answer like clever bot like !addcom nightbot $(customapi $(query)) so you could say Nightbot hello and nightbot would respond based on what you said if someone could do this I will be in debt to them forever

I mean you could use:

and make the responses yourself.

I have no idea what Cleverbot does or says. So this is the best I can offer.

2 Likes

Thanks Iā€™ll try clever bot is like an ai that replies to you based on what you said

Itā€™s not what Iā€™m looking for but thanks!