If you wish to have a backup of your commands on your machine, you can use the API to export them.
-
Go to your Nightbot Applications and create a new one.
Give it a name so you know what it is, there’s no need for a redirect URI.
Click onSubmit
. -
Once created, click on the
Edit
button (the yellow pencil icon underActions
).
There copy theClient ID
and theClient Secret
and save them somewhere safe.
Never share yourClient Secret
!
If you don’t have aClient Secret
, click on theNew Secret
button.
You now have everything you need to obtain your access token.
-
To obtain your access token, open the command prompt and paste the following cURL command:
curl -X POST "https://api.nightbot.tv/oauth2/token" -d "client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials&scope=commands"
Don’t forget to replace
CLIENT_ID
andCLIENT_SECRET
with the information you saved earlier.Press
Enter
and you should get an answer that looks like this:{"access_token":"ACCESS_TOKEN","token_type":"bearer","expires_in":2592000,"refresh_token":"REFRESH_TOKEN","scope":"commands"}
What we’re interested here is the
Access Token
, save it along theClient ID
andClient Secret
.
Never share yourAccess Token
either!
To access the command prompt on Windows, press the
Windows + R
keys, typecmd
in the dialogue and pressEnter
.
On OSX or Linux, just open a terminal.
Please note that the
Access Token
lasts 30 days, but you can refresh it with theRefresh Token
that lasts 60 days with the following cURL command:curl -X POST "https://api.nightbot.tv/oauth2/token" -d "client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=refresh_token&refresh_token=REFRESH_TOKEN"
It’ll answer you with new
ACCESS_TOKEN
andREFRESH_TOKEN
.
Finally, let’s get our commands!
-
On the command prompt, paste the following cURL command:
curl -X GET "https://api.nightbot.tv/1/commands" \ -H "Authorization: Bearer ACCESS_TOKEN"
Don’t forget to replace
ACCESS_TOKEN
with the information you saved earlier.Press
Enter
and you’ll get an answer that looks like this:{"_total":5,"commands":[{},{},{},{},{}],"status":200}
Copy the answer and save it in a file, preferably a
.json
file if you know how to use them.
- So the answer is more readable, you can format it using a JSON Formatter.