pufferd

The pufferd API specification
Authentication

The PufferPanel and pufferd APIs both use the OAuth2 specification for allowing applications to authenticate with the API and for permission control.

OAuth2 differs from other authentication methods in that you first are required to get an “access token” (AT) in order to perform any actions against an API. This AT is issued from the “authentication server” who’s job is to validate the authenticity of the credentials and to grant an AT that allows for certain privileges. This AT is then given to the APIs which validate the AT and then perform the action requested.

In the case of PufferPanel, the authentication server is the panel itself, which exposes the “Auth” endpoint. This endpoint MUST be called first in order to get the access token. A description of how to use this endpoint is located here: Auth

Auth
POST /oauth2/token/request

Authentication

Open

Authenticate with the panel to get an access token, which is used to authenticate with the remainder of the API.

Request parameters

grant_type
string required

Method of authentication to use

Enumeration:
client_credentials

Use a client_id and client_secret to authenticate

password

Use a username and password to authenticate

client_id
string optional

The client_id to authenticate with. REQUIRED when grant_type is client_credentials.

client_secret
string optional

The secret key for the client_id. REQUIRED when grant_type is client_credentials.

username
string optional

Username of account. REQUIRED when grant_type is password.

password
string optional

Password for account. REQUIRED when grant_type is password.

Responses

200 OK

This response is given to signify the request was processed and the credentials provided were correct.

Body
Object
access_token
string

The access token to be sent to authenticate with the rest of the API

expires
string

The time this token expires

token_type
string

The type of token issued. This will always be bearer.

Enumeration:
bearer
scope
string

The scopes this access token will grant, space delimited

Example:
server.create server.edit server.delete
400

This is returned when the client sends an invalid request, generally due to missing or invalid data

Body
Object
error
string

Reason why request failed

Daemon Control

Calls which are specific to control the daemon

GET /_shutdown
Shutdown
GET /_shutdown

Authentication

OAuth 2
node.stop

Responses

200 OK

Daemon was told to shutdown and is processing

Body
Object
success
boolean

Always true if a 200

Default:
true
msg
string

Simply states the daemon is shutting down

Template
GET /_templates
GET /template/{id}
Get All
GET /_templates

Authentication

OAuth 2
node.templates

Gets all templates registered

Responses

200 OK
Body
Object
success
boolean

True if the call was successful

data
Array of string
Get One
GET /template/{id}

Authentication

OAuth 2

Gets a specific template

Path variables

id
string required

Template name

Responses

200 OK
Body
Object
success
boolean

True if successful

data
Object
404 Not Found

Template does not exist

Server
PUT /server/{id}
DELETE /server/{id}
GET /server/{id}
POST /server/{id}
POST /server/{id}/reload
GET /server/{id}/start
GET /server/{id}/stop
GET /server/{id}/stats
Create Server
PUT /server/{id}

Authentication

OAuth 2
server.create

DO NOT CALL THIS METHOD DIRECTLY, AS THIS WILL NOT REGISTER THE OPERATION IN THE PANEL

Creates a server, using the body to populate the data values in the template. Note, any keys specified that do not exist in the template will still be added to the server’s data file.

Name indicates the human-readable name for the server. Type indicates the template name the server should be created with.

Path variables

id
string required

Server’s unique identifier (UUID)

Examples

PUT /server/12345678-1234-1234-1234-123456789012 HTTP/1.1 

Content-Type: application/json

{
    "name": "mytestserver",
    "type": "minecraft"
    "memory": "1024",
    "jar": "server.jar"
}
Delete Server
DELETE /server/{id}

Authentication

OAuth 2
server.delete

DO NOT CALL THIS METHOD DIRECTLY, AS THIS WILL NOT REGISTER THE OPERATION IN THE PANEL

Deletes the specified server from pufferd. This will also stop the server and remove all files related to it.

Path variables

id
string required

Server UUID

Get Server Info
GET /server/{id}

Authentication

OAuth 2
server.edit

Gets the information about the server’s data file. This will not get the status of the server.

Path variables

id
string required
Edit Server
POST /server/{id}

Authentication

OAuth 2
server.edit

This edits the data for a server. The syntax follows the Create Server function call. All values are explicitly set, there is no way to remove or reset a value. Only fields passed in will be updated.

Path variables

id
string required
Reload Server
POST /server/{id}/reload

Authentication

OAuth 2
server.edit

Reloads the data objects for the server from the server’s data file. This will not restart the server, only refresh the in-memory settings. Restarting the server or other operations will have the newly reloaded data.

Path variables

id
string required

Server UUID

Start Server
GET /server/{id}/start

Authentication

OAuth 2
server.start

Starts the associated server

Path variables

id
string required

Server UUID

Stop Server
GET /server/{id}/stop

Authentication

OAuth 2
server.stop

Stops the server, optionally waiting for it to stop before returning.

Path variables

id
string required

Request parameters

wait
boolean optional

If this is provided, waits for server to stop

Stats
GET /server/{id}/stats

Authentication

OAuth 2
server.stats

Gets memory and CPU stats for a server. This does not work with docker-ran servers. CPU is the percentage of CPU time used (similar to htop) and memory is the RSS value.

Path variables

id
string required

Responses

200 OK
Body
Object
success
boolean
data
Object
memory
integer
cpu
integer