How to use the nightbot custom api

Hey, I am trying to use the nightbot custom api, but I did not know how to, what I want to do basically is a javascript program which can edit commands, so I can edit the commands through the javascript program, I know javascript and I did some similar things, but I didn’t understand any thing in the documentation, can someone tell me where can I start? maybe a small and simple example how to use the api?

The docs give examples of sending a request to each API endpoint. Each example tells the required request method, the URL to reach the endpoint, and any necessary headers to include in the request (almost every endpoint requires you to include an access token, see here).

An example of hitting the send channel message endpoint in PHP.

<?php
// Initialize cURL, set URL to "send channel message" endpoint, set POST method,
// set access token header
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.nightbot.tv/1/channel/send");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ACCESS_TOKEN"));
curl_setopt($ch, CURLOPT_POSTFIELDS, "message=Hello World!");
curl_exec($ch);

// Job's done, close the cURL session
curl_close($ch);
?>

An example of hitting the same endpoint in AJAX, copied from my other post.

$.ajax({
    url: "https://api.nightbot.tv/1/channel/send",
    method: "POST",
    headers: {
        "Authorization":"Bearer ACCESS_TOKEN",
    },
    data: "message=Hello World!"
});

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