Useful Custom APIs

well xgerhard ( @gerhardoh ) on Twitter hooked me up with a working one which was nice of him! So i think it might be solved for now unless you guys are wanting to do something with it.

thanks Izl

I honestly love you for making this thread, this has helped tremendously, and made being the main command creater for a less tech friendly streamer so much more smooth. Props to you

1 Like

The “Returns a Random Subscriber of the channel” Legacy API seems to be malfunctioning. Is there a replacement or a fix?

I use this command every stream to reward a random subscriber.

This is the Error I am receiving:
Warning:
file_get_contents(https://apis.rtainc.co/twitch/subscribers/THISISMYTOKEN):
failed to open stream: Connection refused in /home/rtainc/www/apis.rtainc.co/twitchbot/randomsub.php on line 2

Warning: array_rand() expects parameter 1 to be array, null given in /home/rtainc/www/apis.rtainc.co/twitchbot/randomsub.php on line 4

The issue should now be fixed. Sorry about that.

1 Like

It’s working again; thanks for the fast response!

It looks like the Random Sub command is broken again!

It’s pulling up this error: Notice: Undefined index: subscribsaers in /home/rtainc/www/apis.rtainc.co/twitchbot/randomsub.php on line 4

It looks like “subscribers” is misspelled on Line 4. Can this be fixed?

Sorry about all this; I use this command for a daily giveaway.

Feel free to try out the new giveaways page in the control panel as it might work better for that purpose: https://beta.nightbot.tv/giveaways

Is there a way to make a command to run a giveaway, Night?

I currently rely on this API command because I can just enter !subwinner into the chat the same way I would enter !winner into the chat, rather than having to open Nightbot and mess with all of the confusing Giveaway buttons. I’ve tried doing Giveaways on the Nightbot page before, and it’s kind of cumbersome and takes more time to set up than just entering a command and having a winner pop up.

Hey @rtainc

I’ve been working on getting a !funfact api set up. I finally got around to writing an html/javascript file that would pull from an array of 100 fun facts and display one of those, but I found out, after the fact, that NightBot does not work well/at all with javascript.
Here is the current html file: noahsiano.com/randomfact.html
Source code if this location changes:

<html>
<body>
<p id="facts"></p>
</body>
<script>


var facts = [
"Fun Fact # 1: Banging your head against a wall burns 150 calories an hour.",
"Fun Fact # 2: In the UK, it is illegal to eat mince pies on Christmas Day!",
"Fun Fact # 3: Pteronophobia is the fear of being tickled by feathers!",
"Fun Fact # 4: When hippos are upset, their sweat turns red.",
"Fun Fact # 5: A flock of crows is known as a murder.",
"Fun Fact # 6: “Facebook Addiction Disorder” is a mental disorder identified by Psychologists.",
"Fun Fact # 7: The average woman uses her height in lipstick every 5 years.",
"Fun Fact # 8: 29th May is officially “Put a Pillow on Your Fridge Day“.",
"Fun Fact # 9: Cherophobia is the fear of fun.",
"Fun Fact # 10: Human saliva has a boiling point three times that of regular water.",
"Fun Fact # 11: If you lift a kangaroo’s tail off the ground it can’t hop.",
"Fun Fact # 12: Hyphephilia are people who get aroused by touching fabrics.",
"Fun Fact # 13: Billy goats urinate on their own heads to smell more attractive to females.",
"Fun Fact # 14: The person who invented the Frisbee was cremated and made into frisbees after he died!",
"Fun Fact # 15: During your lifetime, you will produce enough saliva to fill two swimming pools.",
"Fun Fact # 16: An eagle can kill a young deer and fly away with it.",
"Fun Fact # 17: Polar bears can eat as many as 86 penguins in a single sitting.",
"Fun Fact # 18: King Henry VIII slept with a gigantic axe beside him.",
"Fun Fact # 19: Bikinis and tampons invented by men.",
"Fun Fact # 20: If Pinokio says “My Noes Will Grow Now”, it would cause a paradox.",
"Fun Fact # 21: Heart attacks are more likely to happen on a Monday.",
"Fun Fact # 22: If you consistently fart for 6 years & 9 months, enough gas is produced to create the energy of an atomic bomb!",
"Fun Fact # 23: An average person’s yearly fast food intake will contain 12 pubic hairs.",
"Fun Fact # 24: The top six foods that make your fart are beans, corn, bell peppers, cauliflower, cabbage and milk!",
"Fun Fact # 25: There is a species of spider called the Hobo Spider.",
"Fun Fact # 26: ‘Penis Fencing’ is a scientific term for the mating ritual between flatworms. It involves two flatworms attempting to stab the other flatworm with their penis.",
"Fun Fact # 27: A toaster uses almost half as much energy as a full-sized oven.",
"Fun Fact # 28: A baby spider is called a spiderling.",
"Fun Fact # 29: You cannot snore and dream at the same time.",
"Fun Fact # 30: The following can be read forward and backwards: Do geese see God?",
"Fun Fact # 31: A baby octopus is about the size of a flea when it is born.",
"Fun Fact # 32: A sheep, a duck and a rooster were the first passengers in a hot air balloon.",
"Fun Fact # 33: In Uganda, 50% of the population is under 15 years of age.",
"Fun Fact # 34: Hitler’s mother considered abortion but the doctor persuaded her to keep the baby.",
"Fun Fact # 35: Arab women can initiate a divorce if their husbands don’t pour coffee for them.",
"Fun Fact # 36: Recycling one glass jar saves enough energy to watch TV for 3 hours.",
"Fun Fact # 37: Smearing a small amount of dog feces on an insect bite will relieve the itching and swelling.",
"Fun Fact # 38: Catfish are the only animals that naturally have an odd number of whiskers.",
"Fun Fact # 39: Facebook, Skype and Twitter are all banned in China.",
"Fun Fact # 40: 95% of people text things they could never say in person.",
"Fun Fact # 41: The Titanic was the first ship to use the SOS signal.",
"Fun Fact # 42: In Poole, ‘Pound World’ went out of business because of a store across the road called ’99p Stores’, which was selling the same products but for just 1 pence cheaper!",
"Fun Fact # 43: About 8,000 Americans are injured by musical instruments each year.",
"Fun Fact # 44: The French language has seventeen different words for ‘surrender’.",
"Fun Fact # 45: Nearly three percent of the ice in Antarctic glaciers is penguin urine.",
"Fun Fact # 46: Bob Dylan’s real name is Robert Zimmerman.",
"Fun Fact # 47: A crocodile can’t poke its tongue out :p",
"Fun Fact # 48: Sea otters hold hands when they sleep so they don’t drift away from each other.",
"Fun Fact # 49: A small child could swim through the veins of a blue whale.",
"Fun Fact # 50: Bin Laden’s death was announced on 1st May 2011. Hitler’s death was announced on 1st May 1945.",
"Fun Fact # 51: J.K. Rowling chose the unusual name ‘Hermione’ so young girls wouldn’t be teased for being nerdy!",
"Fun Fact # 52: Hewlett-Packard’s name was decided in a coin toss.",
"Fun Fact # 53: The total number of steps in the Eiffel Tower are 1665.",
"Fun Fact # 54: The Pokémon Hitmonlee and Hitmonchan are based off of Bruce Lee and Jackie Chan.",
"Fun Fact # 55: The toothpaste ‘Colgate’ in Spanish translates to ‘go hang yourself’.",
"Fun Fact # 56: Pirates wore earrings because they believed it improved their eyesight.",
"Fun Fact # 57: Los Angeles’s full name is “El Pueblo de Nuestra Senora la Reina de los Angeles de Porciuncula.”",
"Fun Fact # 58: Dr. Kellogg introduced Kellogg Corn Flakes in hopes that it would reduce masturbation.",
"Fun Fact # 59: The testicles on an octopus are located in its head!",
"Fun Fact # 60: In England, in the 1880’s, “Pants” was considered a dirty word.",
"Fun Fact # 61: It snowed in the Sahara desert for 30 minutes on the 18th February 1979.",
"Fun Fact # 62: Every human spent about half an hour as a single cell.",
"Fun Fact # 63: If you leave everything to the last minute
 it will only take a minute.",
"Fun Fact # 64: Ithyphallophobia is the fear of erections.",
"Fun Fact # 65: The first alarm clock could only ring at 4am.",
"Fun Fact # 66: Birds don’t urinate.",
"Fun Fact # 67: Dying is illegal in the Houses of Parliaments – This has been voted as the most ridiculous law by the British citizens.",
"Fun Fact # 68: The word ‘ejaculation’ comes from the Latin word meaning ‘throwing out’.",
"Fun Fact # 69: The 20th of March is known as Snowman Burning Day!",
"Fun Fact # 70: Slugs have 4 noses.",
"Fun Fact # 71: Panphobia is the fear of everything
 which is a pretty unlucky phobia to have.",
"Fun Fact # 72: An apple, potato, and onion all taste the same if you eat them with your nose plugged.",
"Fun Fact # 73: George Washington grew marijuana in his garden.",
"Fun Fact # 74: A company in Taiwan makes dinnerware out of wheat, so you can eat your plate!",
"Fun Fact # 75: The average person walks the equivalent of twice around the world in a lifetime.",
"Fun Fact # 76: The Bible is the most shoplifted book in the world.",
"Fun Fact # 77: Marco Hort has the world record for fitting 264 straws in his mouth at once!",
"Fun Fact # 78: Mel Blanc – the voice of Bugs Bunny – was allergic to carrots.",
"Fun Fact # 79: California has issued 6 drivers licenses to people named Jesus Christ.",
"Fun Fact # 80: According to Genesis 1:20-22 the chicken came before the egg.",
"Fun Fact # 81: In the Caribbean there are oysters that can climb trees.",
"Fun Fact # 82: Worms eat their own poo.",
"Fun Fact # 83: Squirrels forget where they hide about half of their nuts.",
"Fun Fact # 84: Over 1000 birds a year die from smashing into windows.",
"Fun Fact # 85: The inventor of the Waffle Iron did not like waffles.",
"Fun Fact # 86: George W. Bush was once a cheerleader.",
"Fun Fact # 87: In Japan, it is completely acceptable to name your child ‘Buttocks’ or ‘Prostitute’.",
"Fun Fact # 88: In 1895 Hampshire police handed out the first ever speeding ticket, fining a man for doing 6mph!",
"Fun Fact # 89: Each year, there are more than 40,000 toilet related injuries in the United States.",
"Fun Fact # 90: A tapir has the largest penis-to-body ratio of any animal.",
"Fun Fact # 91: Mewtwo is a clone of the Pokémon Mew, yet it comes before Mew in the Pokédex.",
"Fun Fact # 92: Every year more than 2500 left-handed people are killed from using right-handed products.",
"Fun Fact # 93: Madonna suffers from garophobia which is the fear of thunder.",
"Fun Fact # 94: China has more English speakers than the United States.",
"Fun Fact # 95: Samuel L. Jackson requested to have a purple light saber in Star Wars in order for him to accept the part as Mace Windu.",
"Fun Fact # 96: Paraskavedekatriaphobia is the fear of Friday the 13th!",
"Fun Fact # 97: Kleenex tissues were originally used as filters in gas masks.",
"Fun Fact # 98: In 1998, Sony accidentally sold 700,000 camcorders that had the technology to see through people’s clothes. These cameras had special lenses that use infrared light, which allowed you to see through some types of clothing.",
"Fun Fact # 99: Upon losing battles, apes will tend to masturbate.",
"Fun Fact # 100: Ronald McDonald is “Donald McDonald” in Japan because it makes pronunciation easier for the Japanese. In Singapore he’s known as “Uncle McDonald”."
];



var randomInt = Math.floor(Math.random() * (facts.length));
var randomFact = facts[randomInt];
document.getElementById("facts").innerHTML = randomFact;
</script>

</html>

I don’t have any php experience, but I know SQL so it can’t be too hard. Would I be able to just create a program with it and host the file on my domain and use that as the custom api link? Or would I need to create a LEMP and get all of the choices set in a SQL database? I currently have github, nginx, and a digitalocean droplet to work with.

Thanks,

-Noah

While I’m no php or api master, I can help you out based on my knowledge of it.

but I found out, after the fact, that NightBot does not work well/at all with javascript.

The reason JavaScript won’t produce an answer is because it is a client-side programming language. The only languages that work have to be server-side (PHP, Python, Ruby, etc.).

Would I be able to just create a program with it and host the file on my domain and use that as the custom api link?

Yes you can just be sure that is it a server-side language and that the text returned is < 400 characters.

As far as the rest of your knowledge I just tried my luck at php and got the results to turn out well, you’re welcome to use it.

Here is a basic starting point for you with a couple of facts (you can add in the rest): Fun Facts · GitHub

And the final result:
No Longer Available

Hope this helps!

I tried that and I tried the other stuff to none of them will work for me, I did: !addcom !following $(c9i67z8lajpfyhubszf1ho0zf5s645 https://apis.rtainc.co/twitchbot/following?channel=CHANNEL&user=$(user)) . why it no work? oh ya I’m using nightbot, does that matter?

@austin_and_gaming Not sure what that code is, if thats an auth key better remove it :wink:
Try this, change CHANNEL to your channelname:

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

@rtainc Not following returns a 404 warning.

Thanks. The live webpage demo does not ever load for me, but I get the idea from the github coding. I added php to my server, I’ll get around to adding the code later tonight and let you know if I get it working.

(When I get it working, it should be live at http://noahsiano.com/funfact.php)

EDIT: uploaded the .php file to server, and all I get is a download whenever I visit the link. Apparantly I don’t know how to set it up to just be a script, or I set up php wrong on my server haha. Any ideas?

Hello, I am new and just getting into working with night bot. I am in search of a point system and mabey a blackjack or scramble game as well? Would one of you kind people point me in the right direction and or assist me

@noahsiano The web host you are using needs to support PHP. If it doesn’t, loading your page will just give you the raw text source of the page.

@dbootyhd Nightbot does not yet have a loyalty system, but it is highly requested and is something we’ll be working on in the future. As for games, they tend to be quite spammy but it’s something we might explore if there’s enough interest (there’s not any at present).

I’m gonna have to work on it on my own. I’ve got php5 installed and it’s running, I believe it’s just a matter of I don’t know how to properly host a php script haha.

Thanks for the help @Aaron128l and @night :smiley:

I was wondering if someone would be kind enough to host an API for me. HotsLogs offers a very basic API for Heroes of the Storm via hotslogs.com/API/Players/1/(BattleTag_####~)
Ex: https://www.hotslogs.com/API/Players/1/McIntyre_1261

If someone could structure one to return something like “%NAME% - Quick Match [Rank %RANK_1%]: %MMR_1% | Hero League [Rank %RANK_2%]: %MMR_2% | Team League [Rank %RANK_3%]: %MMR_3% - Profile: https://www.hotslogs.com/Player/Profile?PlayerID=%PLAYERID%”

That would be super sick and much appreciated by many streamers. I don’t have any reliable hosting right now.

I’ve actually created a series of urls that can be used as an API to manage your queue. Everything is managed with chat commands which also means users don’t have to open an additional tab just to submit a level. The entire list of commands can be found here: http://www.pokemonrby.com/smm/commands.txt

1 Like

Due to all the new and different things this offers, please feel free to create a brand new topic to better “showcase” these for users. Almost in a similar way this is created. https://community.nightdev.com/c/nightbot

Hey @rtainc thanks for your continued work for the community. Could you please make a customapi that tracks call of duty black ops 3 stats like kd and favorite lethal and most used specialist? That would be great because I am a big call of duty player and I can’t seem to find one like that. Thanks in advance!