Tutorial to create Custom API?

Sorry if this is a stupid question but I want to try to do some custom API but I have no idea how…
Is there some documentation online that gives a little hindsight about where to start?

I tried to use that https://api-docs.nightbot.tv/#basic-steps
but when I’m on the nightbot site I have no idea where to create the API, when it ask for links, etc…

Heya, I’m not sure what exactly you mean, looks like you’re confusing 2 different things. Custom API gives access to external sources through Nightbot commands. The page you’re linking to is the Nightbot API, an API to manage Nightbot from an external app.

If you’re refering to Custom API commands, heres a bit info:
The thing the Nightbot Custom API does is displaying the plain text content of the url you give. So the thing you should learn is a server side programming language and have access to a place where you can host your files.

Simple PHP example:

echo 'Hi';

!commands add !hi $(urlfetch https://example.com/hi.php)

xgerhard: !hi
Nightbot: Hi

If you are familiar with PHP, you can use Nightbot variables to create interactive scripts.

PHP example:

    $strQuery = strtolower(trim(urldecode($_GET['query'])));
        case 'random':
			echo rand(5, 15);
		case 'greet':
			echo 'Hello';

!commands add !hi $(urlfetch https://example.com/hi.php?query=$(querystring))

xgerhard: !hi random
Nightbot: 11
xgerhard: !hi greet
Nightbot: Hello

With those variables you can create scripts as complex as you want. Hope this helps.


Oooh Wow!

Yes that was totally what I meant, thanks I lot. I don’t have any knowledge yet about server side/php coding but at least now I know that’s what I need to look into.

Thanks a lot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.