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
Editbutton (the yellow pencil icon underActions).
There copy theClient IDand theClient Secretand save them somewhere safe.
Never share yourClient Secret!
If you don’t have aClient Secret, click on theNew Secretbutton.
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_IDandCLIENT_SECRETwith the information you saved earlier.Press
Enterand 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 IDandClient Secret.
Never share yourAccess Tokeneither!
To access the command prompt on Windows, press the
Windows + Rkeys, typecmdin the dialogue and pressEnter.
On OSX or Linux, just open a terminal.
Please note that the
Access Tokenlasts 30 days, but you can refresh it with theRefresh Tokenthat 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_TOKENandREFRESH_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_TOKENwith the information you saved earlier.Press
Enterand 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
.jsonfile if you know how to use them.
- So the answer is more readable, you can format it using a JSON Formatter.