Useful Custom APIs

I don’t know how to create an API like that, but it would be awesome to get one though.

1 Like

Im really wondering, what do i replace the “VIEWER” Part with in https://api.rtainc.co/twitch/channels/CHANNEL/followers/VIEWER?format=[1]+has+been+following+[0]+for+[2] ?

1 Like

You can replace it with $(touser), this will pull the followage of the person who typed the command, or another user if they type their username after the command.

Examples:
!followage would return the followage of the user that typed the command.
!followage UserX would return the followage of ‘UserX’ no matter who typed the command.

1 Like

Been trying to create command for how long someone subscribed to channel using the linked API, but I’m either receiving message that user is not subbed to the channel, or an error message from Nightbot. I have the necessary Twitch token from partnered streamer.

1 Like

I have already written a php code to generate like a magic 8 ball with different characters, however I cant get it to become an API. if anyone could help I would love you forever code will be below. Thank you!

<?php $m1 = "OH this is a good one, Mei"; $m2 = "I will not waste this chance, Genji"; $m3 = "Justice ain't gonna dispense itself, McCree"; $m4 = "Justice rains from above, Pharah"; $m5 = "Die, Die, Die, Reaper"; $m6 = "We're all soldiers now, Soldier:76"; $m7 = "Been here all along, Sombra"; $m8 = "The cavalry's here, Tracer"; $m9 = "Ryū ga waga teki wo kurau, Hanzo"; $m10 = "Boo boo doo de doo, Bastion"; $m11 = "Ladies and gentlemen, start your engines, Junkrat"; $m12 = "I foresee great things for you, Torbjörn"; $m13 = "My gift to you, Widowmaker"; $m14 = "All systems checked out, D.va"; $m15 = "Don't worry my friends. I will be your shield, Reinhardt"; $m16 = "I'm a one-man apocalypse, Roadhog"; $m17 = "I'm looking forward to working with you all, Winston"; $m18 = "Together we are strong, Zarya"; $m19 = "You're going to be ok, Ana"; $m20 = "Oh, let's break it down, Lucio"; $m21 = "Did someone call a doctor, Mercy"; $m22 = "The balance shifts in my favor, Symmetra"; $m23 = "Experience tranquility, Zenyatta"; $rm = array($m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8, $m9. $m10, $m11, $m12, $m13, $m14, $m15, $m16, $m17, $m18, $m19, $m20, $m21, $m22, $m23); $random_keys = array_rand($rm, 1); echo $rm[$random_keys]; ?>
1 Like

can we make the choices one more random? NightbotDev?

1 Like

What do you mean exactly? I don’t believe there is any issue with the randomness of the api.

Hi! I’m new to Nightbot and I really appreciate being able to use those custom APIs, but I have some questions about this one:

  • I noticed that when it picks myself or Nightbot, it adds “(mod)” to the name returned, can’t this be avoided?
  • Also, wouldn’t it be possible to exclude Nightbot from the random selection?

I would gladly try to make my own version of the random viewer selection to see if those are possible, but I can’t seem to find how to access the current viewers list in the API reference…

1 Like

Is there a way to remove the “I choose” text from the “Random choise” API?

1 Like

Yes, just remove that section from the url after format= so for example it would look like this:

https://api.rtainc.co/twitch/random?format=[0]&choices=CHOICES

I am trying to make a command based off of quote that lets me change what the query is, and I was hoping I could get some help.

The goal is a !mods [game] command, but I just dont know where to start in changing the limited access I have to the API. Even just pointing me at a scripting tutorial would be great! Thanks for your work!

1 Like

Hello, I’m new to Nightbot. I’ve seen a couple of channels using the random choice api and I’m not sure how to set it up.
I want my channel to randomly choose a key blade from Kingdom Hearts that my viewers will wield in the chat.
I want to use the command !keyblade and then the response would be $(touser) now wields the (random key blade)
Can someone help me start the set up?

1 Like

You would use this custom api to achieve this:

The command should look something like this:

!commands add !keyblade $(touser) now weilds the $(urlfetch https://api.rtainc.co/twitch/random?format=[0]&choices=CHOICES) key blade.

Be sure to replace the ‘CHOICES’ in the url with the words you want to randomly generate seperated by commas.

You can read more about the urlfetch variable here.:thumbsup:

2 Likes

Oh this is perfect, thank you!

2 Likes

I’ve noticed some streamers are able to change the name of their Nightbot? How is that possible? (Example: My friend whom I can’t get ahold of has her Nightbot come up as Ambot.)

1 Like

This is not currently possible, it may be in future however there currently isn’t an eta.

Ambot is not Nightbot under a different name, it’s a seperate bot your friend probably added or coded themselves.

1 Like

I’m looking for a command that one person challenges a specific viewer to a fight and then nightbot chooses a winner from the two if that is possible. Thank you for your time.
Example: !duel Talon
Narutia challenged Talon to a keyblade duel!
Talon is the victor!

1 Like

You can use the variables $(user) and $(touser) in the custom API url, like this:

!commands add !duel $(user) challenges $(touser) to a keyblade duel! $(urlfetch https://api.rtainc.co/twitch/random?format=[0]&choices=$(user),$(touser)) is the winner!

1 Like

Awesome, thank you so much!

2 Likes

Hello, I’ve been trying to make something for my channel with the random choice API, but I have no idea how to get it to work, could anybody help me on this matter?

1 Like