Controller API

The Controller API is the central interface for managing your SimpleCloud infrastructure. It provides comprehensive control over server groups, individual servers, and real-time event handling through our Protocol Buffer based controllerApi.

Installation

Loading dependency information...

Authentication

If you're using our Controller API in a Minecraft server, the token is automatically provided via environment variables. For external applications, you'll need to use the master authentication token.

You can find the master token in /components/.secrets/auth.secret in your SimpleCloud directory.

// Uses CONTROLLER_SECRET from environment
val controllerApi = ControllercontrollerApi.createCoroutineApi()

Other Programming Languages

Our Controller API is primarily written in Kotlin, but we also have Proto Definitions available for other languages. You can find the definitions in the buf.build/simplecloud/proto-specs repository.

It provides support for all kinds of languages, including:

createGroup

Creates a new server group template.

val group = Group(
    name = "lobby",
    type = ServerType.SERVER,
    minMemory = 512,
    maxMemory = 1024,
    startPort = 25565,
    minOnlineCount = 1,
    maxOnlineCount = 5,
    maxPlayers = 100,
    newServerPlayerRatio = 50,
    properties = mapOf("gamemode" to "LOBBY")
)

val createdGroup = controllerApi.getGroups().createGroup(group)

getGroupByName

Retrieves a specific group by its name.

val lobbyGroup = controllerApi.getGroups().getGroupByName("lobby")

getAllGroups

Retrieves all configured groups.

val allGroups = controllerApi.getGroups().getAllGroups()

getGroupsByType

Retrieves all groups of a specific type.

val serverGroups = controllerApi.getGroups().getGroupsByType(ServerType.SERVER)

updateGroup

Updates an existing group's configuration.

val updatedGroup = existingGroup.copy(
    maxPlayers = 200,
    maxMemory = 2048
)
controllerApi.getGroups().updateGroup(updatedGroup)

deleteGroup

Removes a server group.

controllerApi.getGroups().deleteGroup("lobby")

startServer

Starts a new server instance from a group template.

val server = controllerApi.getServers().startServer(
    groupName = "lobby",
    startCause = ServerStartCause.API_START
)

getAllServers

Retrieves all running servers.

val allServers = controllerApi.getServers().getAllServers()

getServerById

Retrieves a specific server by its unique ID.

val server = controllerApi.getServers().getServerById("0f0c2d1a-d7d5-4c7f-b7a9-c0e8e9b5a6b8")

getServersByGroup

Retrieves all servers belonging to a specific group.

val lobbyServers = controllerApi.getServers().getServersByGroup("lobby")

getServerByNumerical

Retrieves a specific server by its group name and numerical ID.

val specificServer = controllerApi.getServers().getServerByNumerical("lobby", 1)

getServersByType

Retrieves all servers of a specific type.

val serverServers = controllerApi.getServers().getServersByType(ServerType.SERVER)

updateServerState

Updates the state of a server.

controllerApi.getServers().updateServerState(
    id = "0f0c2d1a-d7d5-4c7f-b7a9-c0e8e9b5a6b8",
    state = ServerState.AVAILABLE
)

updateServerProperty

Updates a custom property of a server.

controllerApi.getServers().updateServerProperty(
    id = "0f0c2d1a-d7d5-4c7f-b7a9-c0e8e9b5a6b8",
    key = "gameMode",
    value = "CAPTURE_THE_FLAG"
)

stopServer

Stops a running server instance.

// Stop by ID
controllerApi.getServers().stopServer(
    id = "0f0c2d1a-d7d5-4c7f-b7a9-c0e8e9b5a6b8",
    stopCause = ServerStopCause.API_STOP
)

// Stop by group and numerical ID
controllerApi.getServers().stopServer(
    groupName = "lobby",
    numericalId = 1,
    stopCause = ServerStopCause.API_STOP
)

Data Models

Group Properties

The Group class represents a server group template with the following properties:

PropertyTypeDescription
namestringUnique identifier for the group
typeenumServer type (UNKNOWN_SERVER, SERVER, PROXY)
minMemorylongMinimum RAM allocation in MB
maxMemorylongMaximum RAM allocation in MB
startPortlongBase port number for new servers
minOnlineCountlongMinimum number of servers to keep running
maxOnlineCountlongMaximum number of servers allowed
maxPlayerslongMaximum players per server
newServerPlayerRatiolongPlayer count threshold for starting new servers (-1 to disable)
propertiesMap<String, String>Custom key-value properties

Server Properties

The Server class represents a running server instance with the following properties:

PropertyTypeDescription
uniqueIdstringUnique identifier (e.g., "0f0c2d1a-d7d5-4c7f-b7a9-c0e8e9b5a6b8")
typeenumServer type (UNKNOWN_SERVER, SERVER, PROXY)
groupstringParent group name
hoststringHost machine identifier
numericalIdintNumerical ID within group
ipstringServer IP address
portlongServer port
minMemorylongMinimum RAM allocation in MB
maxMemorylongMaximum RAM allocation in MB
maxPlayerslongMaximum allowed players
playerCountlongCurrent player count
propertiesMap<String, String>Custom key-value properties
stateenumServer state (UNKNOWN_STATE, PREPARING, STARTING, AVAILABLE, INGAME, STOPPING)
createdAtLocalDateTimeCreation timestamp
updatedAtLocalDateTimeLast update timestamp

Was this page helpful?