Useful Custom APIs

Do you know of any other bot that can do that

1 Like

Out of respect for NightDev I won’t post any here. I’ve sent you a PM with some bots that do, though.

2 Likes

Hello, it seems that the sub length command is not working properly. Could you please give me more insight on how to use it?. I tried but it always gives me an incorrect sub length.
Thanks in advance

1 Like
https://api.rtainc.co/twitch/subbed-since?token=TOKEN&user=USER

To get the sub length of the person doing the command (e.g. !sublength):

https://api.rtainc.co/twitch/subbed-since?token=TOKEN&user=$(user)

To get the sub length of a specified user (e.g. !sublength rtainc):

https://api.rtainc.co/twitch/subbed-since?token=TOKEN&user=$(touser)
2 Likes

Thank you for the answer. But the problem is that the channel that i am using this, i am subbed for almost 11 months and it shows the same answer all the time - 8 months and 2 days. I did exactly the way you instructed me.
Thank you in advance

1 Like

That’s odd. If you PM me the token and your Twitch name, I’ll look into it.

1 Like

How do you use these API’s? Such as https://apis.rtainc.co/twitchbot/following?channel=CHANNEL&user=USER This one meant to return how long a USER has been following the CHANNEL

1 Like

For example (remember to replace CHANNEL with the channel’s name),

!addcom !howlong $(user) has been following for: $(customapi https://apis.rtainc.co/twitchbot/following?channel=CHANNEL&user=$(user))

Then you can use the command…

rtainc: !howlong
Nightbot: rtainc has been following for: 1 month, 3 days
1 Like

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