Using the QuackPlane API
An API key lets your own code, such as a Discord bot or a script, do what you do in QuackPlane: start and stop your server, run commands on its console and take backups. The key acts as your account, so it can do everything you can, on every server you can open in QuackPlane.
Creating an API key
Section titled “Creating an API key”-
In QuackPlane, select API keys in the list on the left.
-
Under Description, say what will use the key, such as
Discord bot, so you can tell your keys apart later. -
If your code always runs from the same IP address, enter it under Allowed IPs and press Enter. The key then works only from there. Leave it empty to use the key from anywhere.
-
Select Create, and copy the key from the message that appears. It starts with
pacc_, and QuackPlane shows it only this once.
To stop a key working, delete it from the list of your keys on the same page.
Sending a request
Section titled “Sending a request”Every request takes two headers: Authorization, with your key after Bearer, and Accept: application/json. Without the second, QuackPlane answers a request it refuses with a web page, such as its login page, instead of JSON saying why. This lists your servers:
curl https://plane.quack.host/api/client \ -H "Authorization: Bearer pacc_YourKey" \ -H "Accept: application/json"Controlling your server
Section titled “Controlling your server”Each request below adds its path, such as /power, to this address, which ends in your server’s ID:
https://plane.quack.host/api/client/servers/1a2b3c4dThe ID is the identifier in the list of your servers, and your server’s Settings page shows it too, after “ID” in the small print at the bottom. Send a body as JSON, with Content-Type: application/json.
GET /resourcesYour server’s state in
current_state, such asrunningoroffline, and the memory, CPU and disk it’s using.POST /powerStarts, stops or restarts your server: send
{"signal": "start"},"stop"or"restart"."kill"stops it at once, losing whatever it hasn’t saved.POST /commandRuns a command on your server’s console: send
{"command": "say Hello"}. Your server has to be running.GET /backupsLists your server’s backups.
POST /backupsTakes a backup, named by
{"name": "Before the update"}, or by the date and time if you send no name. It’s refused once your server has as many backups as it keeps.
This restarts the server with the ID 1a2b3c4d:
curl -H "Authorization: Bearer pacc_YourKey" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"signal": "restart"}' \ https://plane.quack.host/api/client/servers/1a2b3c4d/powerQuackPlane lists every request it takes, such as for files and schedules, at plane.quack.host/docs/api/client, while you’re logged in.