### Start the SimpleCloud setup wizard Source: https://simplecloud.app/docs/en/manual/introduction/architecture/cli Run 'sc setup' to start the setup wizard, which signs you in, connects the machine to your network, and installs the serverhost. ```bash sc setup ``` -------------------------------- ### Install and start Syncthing on macOS Source: https://simplecloud.app/docs/en/manual/setup/multi-root On macOS, install and start Syncthing before continuing with the synchronization setup. The CLI offers to install and start Syncthing on Linux when needed. ```bash brew install syncthing jq brew services start syncthing ``` -------------------------------- ### Go example for get player by name Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-name Go example using net/http to GET /v0/players/name. Adds the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/name" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example for listing player profiles Source: https://simplecloud.app/docs/en/developer/api-reference/players/list-player-profiles Go example using net/http to GET /v0/players/profiles. Adds the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/profiles" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go GET request example Source: https://simplecloud.app/docs/en/developer/api-reference/secrets/get-the-network-shared-public-key Uses the net/http package to send a GET request with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/secrets/encryption-key" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-uuid Uses net/http to GET player data and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/id" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Ruby example for get player by name Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-name Ruby example using net/http to GET /v0/players/name. Sets the required headers and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://controller.simplecloud.app/v0/players/name") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Network-ID"] = '' request["X-Network-Credential"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Go example to list blueprints Source: https://simplecloud.app/docs/en/developer/api-reference/blueprints/list-blueprints Uses net/http to send a GET request to /v0/blueprints with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/blueprints" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example for listing plugin assignments Source: https://simplecloud.app/docs/en/developer/api-reference/plugin-assignments/list-plugin-assignments Uses the net/http package to send a GET request with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/plugin-assignments" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go GET /v0/serverhosts Source: https://simplecloud.app/docs/en/developer/api-reference/serverhosts/list-serverhosts Go example using net/http to list serverhosts. Sets the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/serverhosts" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Ruby example Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-uuid Uses net/http to GET player data and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://controller.simplecloud.app/v0/players/id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Network-ID"] = '' request["X-Network-Credential"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Ruby Net::HTTP example for listing player profiles Source: https://simplecloud.app/docs/en/developer/api-reference/players/list-player-profiles Ruby example using Net::HTTP to GET /v0/players/profiles. Sets the required headers and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://controller.simplecloud.app/v0/players/profiles") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Network-ID"] = '' request["X-Network-Credential"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Java Unirest example for listing player profiles Source: https://simplecloud.app/docs/en/developer/api-reference/players/list-player-profiles Java example using Unirest to GET /v0/players/profiles. Sets the required headers and returns the response as a string. ```java HttpResponse response = Unirest.get("https://controller.simplecloud.app/v0/players/profiles") .header("X-Network-ID", "") .header("X-Network-Credential", "") .asString(); ``` -------------------------------- ### Ruby example to list blueprints Source: https://simplecloud.app/docs/en/developer/api-reference/blueprints/list-blueprints Uses net/http to send a GET request to /v0/blueprints with the required headers and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://controller.simplecloud.app/v0/blueprints") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Network-ID"] = '' request["X-Network-Credential"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Go: List plugin collection installations Source: https://simplecloud.app/docs/en/developer/api-reference/plugin-collection-assignments/list-plugin-collection-installations Uses net/http to GET the plugin-collection-assignments endpoint with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/plugin-collection-assignments" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### JavaScript fetch example for listing player profiles Source: https://simplecloud.app/docs/en/developer/api-reference/players/list-player-profiles JavaScript example using fetch to GET /v0/players/profiles. Includes the required headers and logs the JSON response or error. ```javascript const options = { method: 'GET', headers: {'X-Network-ID': '', 'X-Network-Credential': ''} }; fetch('https://controller.simplecloud.app/v0/players/profiles', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Start Prefixes on Minestom (Java) Source: https://simplecloud.app/docs/en/manual/plugin/prefixes Java example showing how to start Prefixes after MinecraftServer.init(). The builder is configured with a permission check that grants access to players with permission level >= 4. The shutdown task is registered to cleanly stop Prefixes. ```java import app.simplecloud.prefixes.minestom.PrefixesMinestom; import net.minestom.server.MinecraftServer; import java.nio.file.Path; public final class Server { public static void main(String[] args) { MinecraftServer server = MinecraftServer.init(); PrefixesMinestom prefixes = PrefixesMinestom.builder(Path.of("prefixes")) .permission((player, permission) -> player.getPermissionLevel() >= 4) .enable(); MinecraftServer.getSchedulerManager().buildShutdownTask(prefixes::shutdown); server.start("0.0.0.0", 25565); } } ``` -------------------------------- ### Go GET request to /v0/players/profiles/latest Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-latest-player-profile Go example using net/http to call the endpoint. Prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/profiles/latest" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Python requests example for listing player profiles Source: https://simplecloud.app/docs/en/developer/api-reference/players/list-player-profiles Python example using the requests library to GET /v0/players/profiles. Sets the required X-Network-ID and X-Network-Credential headers and prints the response text. ```python import requests url = "https://controller.simplecloud.app/v0/players/profiles" headers = { "X-Network-ID": "", "X-Network-Credential": "" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### GET /v0/server-groups/start-queue Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/list-queued-server-group-starts Lists queued server starts aggregated by server group. Requires X-Network-Credential and X-Network-ID headers. ```APIDOC ## GET /v0/server-groups/start-queue ### Description Lists queued server starts aggregated by server group. ### Method GET ### Endpoint /v0/server-groups/start-queue ### Parameters #### Headers - **X-Network-Credential** (string) - Required - Network password or signed JWT. Password authentication also requires X-Network-ID and grants full access to that network, except the audit log. JWT permissions still apply. - **X-Network-ID** (string) - Required - Network ID ### Request Example ``` curl --request GET \ --url https://controller.simplecloud.app/v0/server-groups/start-queue \ --header 'X-Network-Credential: ' \ --header 'X-Network-ID: ' ``` ### Response #### Success Response (200) - **count** (integer) - Example: `2` - **failed_starts** (integer) - Example: `1` - **items** (object[]) - Show child attributes - **queued_starts** (integer) - Example: `2` - **total_starts** (integer) - Example: `3` #### Response Example ``` { "count": 2, "failed_starts": 1, "items": [ { "failed_starts": 1, "queued_starts": 2, "server_group_id": "123e4567-e89b-12d3-a456-426614174000", "server_group_name": "lobby", "starts": [ { "created_at": "2023-01-01T12:00:00Z", "failure_reason": "no capacity: group is at maximum servers", "id": "123e4567-e89b-12d3-a456-426614174000", "status": "pending" } ], "total_starts": 3 } ], "queued_starts": 2, "total_starts": 3 } ``` #### Error Responses - **401** - Unauthorized - Example: `{"error": ""}` - **500** - Internal Server Error - Example: `{"error": ""}` ``` -------------------------------- ### Go HTTP Request to List Plugin Collections Source: https://simplecloud.app/docs/en/developer/api-reference/plugin-collections/list-plugin-collections Go example using net/http to GET /v0/plugin-collections. Requires X-Network-ID and X-Network-Credential headers. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/plugin-collections" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example to list online players Source: https://simplecloud.app/docs/en/developer/api-reference/players/list-online-players Uses net/http to GET the online players endpoint and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/online" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Start Prefixes on Minestom (Kotlin) Source: https://simplecloud.app/docs/en/manual/plugin/prefixes Kotlin example showing how to start Prefixes after MinecraftServer.init(). The builder is configured with a permission check that grants access to players with permission level >= 4. The shutdown task is registered to cleanly stop Prefixes. ```kotlin import app.simplecloud.prefixes.minestom.PrefixesMinestom import net.minestom.server.MinecraftServer import java.nio.file.Path fun main() { val server = MinecraftServer.init() val prefixes = PrefixesMinestom.builder(Path.of("prefixes")) .permission { player, _ -> player.permissionLevel >= 4 } .enable() MinecraftServer.getSchedulerManager().buildShutdownTask { prefixes.shutdown() } server.start("0.0.0.0", 25565) } ``` -------------------------------- ### Go example for online player count Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-online-player-count Uses net/http to GET the online player count and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/online/count" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Start a server and list running servers Source: https://simplecloud.app/docs/en/manual/introduction/architecture/cli After creating a group, start a server and view the running servers with these commands. ```bash sc group start lobby ``` ```bash sc server list ``` -------------------------------- ### Go example for queueing a server group start Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/queue-a-server-group-start Uses net/http to POST the server group ID and name to the start-queue endpoint. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/server-groups/start-queue" payload := strings.NewReader("{\n \"server_group_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"server_group_name\": \"lobby\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Java Unirest example for get player by name Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-name Java example using Unirest to GET /v0/players/name. Sets the required headers and returns the response as a string. ```java HttpResponse response = Unirest.get("https://controller.simplecloud.app/v0/players/name") .header("X-Network-ID", "") .header("X-Network-Credential", "") .asString(); ``` -------------------------------- ### PHP cURL example for get player by name Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-name PHP example using cURL to GET /v0/players/name. Sets the required headers and outputs the response or a cURL error. ```php "https://controller.simplecloud.app/v0/players/name", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "X-Network-Credential: ", "X-Network-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Manage SimpleCloud on this machine Source: https://simplecloud.app/docs/en/manual/introduction/architecture/cli Use these commands to operate the local installation: start, stop, restart, check status, view serverhost logs, and open the serverhost console. ```bash sc start ``` ```bash sc stop ``` ```bash sc restart ``` ```bash sc status ``` ```bash sc logs serverhost ``` ```bash sc attach serverhost ``` -------------------------------- ### JavaScript fetch example for get player by name Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-name JavaScript example using fetch to GET /v0/players/name. Includes the required headers and logs the JSON response or error. ```javascript const options = { method: 'GET', headers: {'X-Network-ID': '', 'X-Network-Credential': ''} }; fetch('https://controller.simplecloud.app/v0/players/name', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Go example to update client settings Source: https://simplecloud.app/docs/en/developer/api-reference/players/update-client-settings Uses net/http to send a PUT request with the settings payload and prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/sessions/settings" payload := strings.NewReader("{\n \"chat_colors\": true,\n \"chat_mode\": \"ENABLED\",\n \"client_listing_allowed\": true,\n \"locale\": \"en_US\",\n \"main_hand\": \"RIGHT\",\n \"skin_parts\": [\n \"CAPE\",\n \"JACKET\"\n ],\n \"view_distance\": 12\n}") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Python requests example for get player by name Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-name Python example using the requests library to GET /v0/players/name. Sets the required headers and prints the response text. ```python import requests url = "https://controller.simplecloud.app/v0/players/name" headers = { "X-Network-ID": "", "X-Network-Credential": "" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### GET /v0/server-groups/start-queue Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/list-queued-server-group-starts Retrieves the list of queued server group starts. This endpoint returns counts of queued, failed, and total starts, along with detailed information about each start. ```APIDOC ## GET /v0/server-groups/start-queue ### Description Retrieves the list of queued server group starts. ### Method GET ### Endpoint https://controller.simplecloud.app/v0/server-groups/start-queue ### Parameters #### Headers - **X-Network-Credential** (string) - Required - API key for authentication. - **X-Network-ID** (string) - Required - Network identifier. ### Request Example No request body required. ### Response #### Success Response (200) - **count** (integer) - Total number of queued starts. - **failed_starts** (integer) - Number of failed starts. - **items** (array) - List of server group start items. - **failed_starts** (integer) - Number of failed starts for this server group. - **queued_starts** (integer) - Number of queued starts for this server group. - **server_group_id** (string) - Unique identifier of the server group. - **server_group_name** (string) - Name of the server group. - **starts** (array) - List of start records. - **created_at** (string) - Timestamp when the start was created. - **failure_reason** (string) - Reason for failure, if any. - **id** (string) - Unique identifier of the start. - **status** (string) - Status of the start (e.g., pending). - **total_starts** (integer) - Total number of starts for this server group. - **queued_starts** (integer) - Total number of queued starts. - **total_starts** (integer) - Total number of starts. #### Response Example { "count": 2, "failed_starts": 1, "items": [ { "failed_starts": 1, "queued_starts": 2, "server_group_id": "123e4567-e89b-12d3-a456-426614174000", "server_group_name": "lobby", "starts": [ { "created_at": "2023-01-01T12:00:00Z", "failure_reason": "no capacity: group is at maximum servers", "id": "123e4567-e89b-12d3-a456-426614174000", "status": "pending" } ], "total_starts": 3 } ], "queued_starts": 2, "total_starts": 3 } #### Error Responses - **401** - Unauthorized. Invalid or missing API key. - **error** (string) - Error message. - **500** - Internal server error. - **error** (string) - Error message. ``` -------------------------------- ### Go example for bulk create plugin assignments Source: https://simplecloud.app/docs/en/developer/api-reference/plugin-assignments/bulk-create-plugin-assignments Uses net/http to send a POST request with a JSON string payload. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/plugin-assignments/bulk-create" payload := strings.NewReader("{\n \"persistent_server_ids\": [\n \"\"\n ],\n \"plugins\": [\n {\n \"plugin_id\": \"\",\n \"plugin_name\": \"\",\n \"required\": true,\n \"source_type\": \"\",\n \"source_value\": \"\",\n \"version\": \"\"\n }\n ],\n \"server_group_ids\": [\n \"\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Success response for queueing a server group start Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/queue-a-server-group-start Example 202 response with a success message and queued start count. ```json { "message": "Server start queued successfully", "queued_starts": 3, "server_group_id": "123e4567-e89b-12d3-a456-426614174000", "server_group_name": "lobby" } ``` -------------------------------- ### Java Unirest GET example Source: https://simplecloud.app/docs/en/developer/api-reference/secrets/get-the-network-shared-public-key Uses the Unirest library to send a GET request with the required headers and returns the response as a string. ```java HttpResponse response = Unirest.get("https://controller.simplecloud.app/v0/secrets/encryption-key") .header("X-Network-ID", "") .header("X-Network-Credential", "") .asString(); ``` -------------------------------- ### Go: Bulk install plugin collection Source: https://simplecloud.app/docs/en/developer/api-reference/plugin-collection-assignments/bulk-install-a-plugin-collection-on-targets Uses net/http to POST the payload. Reads and prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/plugin-collection-assignments/bulk-create" payload := strings.NewReader("{\n \"persistent_server_ids\": [\n \"\"\n ],\n \"plugin_collection_id\": \"\",\n \"server_group_ids\": [\n \"\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### JavaScript fetch GET example Source: https://simplecloud.app/docs/en/developer/api-reference/secrets/get-the-network-shared-public-key Uses the fetch API to send a GET request with the required headers and logs the JSON response. ```javascript const options = { method: 'GET', headers: {'X-Network-ID': '', 'X-Network-Credential': ''} }; fetch('https://controller.simplecloud.app/v0/secrets/encryption-key', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Go example to connect player to server Source: https://simplecloud.app/docs/en/developer/api-reference/players/connect-player-to-server Uses the net/http package to send a POST request with the player connection payload. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/connect" payload := strings.NewReader("{\n \"persistent_server_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"selection_mode\": \"RANDOM\",\n \"server_group_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"server_id\": \"lobby-1\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Python requests GET example Source: https://simplecloud.app/docs/en/developer/api-reference/secrets/get-the-network-shared-public-key Uses the requests library to perform a GET request to the encryption-key endpoint, printing the response text. ```python import requests url = "https://controller.simplecloud.app/v0/secrets/encryption-key" headers = { "X-Network-ID": "", "X-Network-Credential": "" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Response: 200 OK Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/list-queued-server-group-starts Example successful response with a count of queued starts, failed starts, and items containing server group details. ```json { "count": 2, "failed_starts": 1, "items": [ { "failed_starts": 1, "queued_starts": 2, "server_group_id": "123e4567-e89b-12d3-a456-426614174000", "server_group_name": "lobby", "starts": [ { "created_at": "2023-01-01T12:00:00Z", "failure_reason": "no capacity: group is at maximum servers", "id": "123e4567-e89b-12d3-a456-426614174000", "status": "pending" } ], "total_starts": 3 } ], "queued_starts": 2, "total_starts": 3 } ``` -------------------------------- ### Go example to verify a serverhost Source: https://simplecloud.app/docs/en/developer/api-reference/serverhosts/verify-a-serverhost Uses net/http to send a POST request with the required headers and a JSON body, printing the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/serverhosts/verify" payload := strings.NewReader("{\n \"serverhost_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Ruby Net::HTTP GET example Source: https://simplecloud.app/docs/en/developer/api-reference/secrets/get-the-network-shared-public-key Uses the net/http library to send a GET request with the required headers and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://controller.simplecloud.app/v0/secrets/encryption-key") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Network-ID"] = '' request["X-Network-Credential"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### PHP cURL GET example Source: https://simplecloud.app/docs/en/developer/api-reference/secrets/get-the-network-shared-public-key Uses PHP cURL to perform a GET request to the encryption-key endpoint, handling errors and printing the response. ```php "https://controller.simplecloud.app/v0/secrets/encryption-key", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "X-Network-Credential: ", "X-Network-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Install the SimpleCloud CLI Source: https://simplecloud.app/docs/en/manual/introduction/architecture/cli Run this installer on the machine that will host SimpleCloud. After installation, verify the CLI is available with 'sc --version'. ```bash curl -fsSL https://get.simplecloud.app | bash ``` ```bash sc --version ``` -------------------------------- ### Go example for reapply plugin collection assignments Source: https://simplecloud.app/docs/en/developer/api-reference/plugin-collection-assignments/reapply-plugin-collection-assignments Uses the net/http package to send a POST request with the JSON payload and prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/plugin-collection-assignments/reapply" payload := strings.NewReader("{\n \"persistent_server_ids\": [\n \"\"\n ],\n \"plugin_collection_id\": \"\",\n \"server_group_ids\": [\n \"\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example to kick a player Source: https://simplecloud.app/docs/en/developer/api-reference/players/kick-a-player Uses the net/http package to send a POST request with the kick reason. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/players/kick" payload := strings.NewReader("{\n \"reason\": \"You have been kicked!\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### PHP cURL example for listing player profiles Source: https://simplecloud.app/docs/en/developer/api-reference/players/list-player-profiles PHP example using cURL to GET /v0/players/profiles. Sets the required headers and prints the response or a cURL error. ```php "https://controller.simplecloud.app/v0/players/profiles", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "X-Network-Credential: ", "X-Network-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Go example to list persistent servers Source: https://simplecloud.app/docs/en/developer/api-reference/persistent-servers/list-persistent-servers Uses net/http to send a GET request to the persistent-servers endpoint with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/persistent-servers" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Java Unirest GET rolling restart status Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/get-rolling-restart-status Use this Java Unirest example to get the rolling restart status. Replace the placeholder headers with your actual credentials. ```java HttpResponse response = Unirest.get("https://controller.simplecloud.app/v0/server-groups/rolling-restart") .header("X-Network-ID", "") .header("X-Network-Credential", "") .asString(); ``` -------------------------------- ### Go example to query logs Source: https://simplecloud.app/docs/en/developer/api-reference/metrics/query-logs-with-flexible-filters Use this Go program to POST to the /v0/metrics/logs/query endpoint. It constructs the request with the filter payload and prints the response. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/metrics/logs/query" payload := strings.NewReader("{\n \"cursor\": \"\",\n \"from\": \"\",\n \"limit\": 123,\n \"order\": \"\",\n \"persistent_server_ids\": [\n \"\"\n ],\n \"search\": \"\",\n \"server_group_ids\": [\n \"\"\n ],\n \"server_ids\": [\n \"\"\n ],\n \"serverhost_ids\": [\n \"\"\n ],\n \"severities\": [\n \"\"\n ],\n \"tags\": [\n \"\"\n ],\n \"to\": \"\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### JavaScript fetch GET rolling restart status Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/get-rolling-restart-status Use this JavaScript fetch example to get the rolling restart status. Replace the placeholder headers with your actual credentials. ```javascript const options = { method: 'GET', headers: {'X-Network-ID': '', 'X-Network-Credential': ''} }; fetch('https://controller.simplecloud.app/v0/server-groups/rolling-restart', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Go example for registering network shared public key Source: https://simplecloud.app/docs/en/developer/api-reference/secrets/register-the-network-shared-public-key Uses net/http to POST the public key and serverhost ID. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/secrets/encryption-key" payload := strings.NewReader("{\n \"public_key_pem\": \"-----BEGIN PUBLIC KEY-----...\",\n \"serverhost_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example to add a plugin to a plugin collection Source: https://simplecloud.app/docs/en/developer/api-reference/plugin-collection-plugins/add-a-plugin-to-a-plugin-collection Uses net/http to send a POST request with a JSON payload. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/plugin-collection-plugins" payload := strings.NewReader("{\n \"plugin_collection_id\": \"\",\n \"plugin_id\": \"\",\n \"plugin_name\": \"\",\n \"required\": true,\n \"source_type\": \"\",\n \"source_value\": \"\",\n \"version\": \"\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go: List environment variables Source: https://simplecloud.app/docs/en/developer/api-reference/environment-variables/list-environment-variables Uses the net/http package to send a GET request with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/environment-variables" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Install only the CLI with curl Source: https://simplecloud.app/docs/en/manual/setup/installation Run this command on a Linux or macOS machine to install only the SimpleCloud CLI. This does not connect the machine as a serverhost; use a dashboard-generated setup command to run Minecraft servers. ```bash curl -fsSL https://get.simplecloud.app | bash ``` -------------------------------- ### Go example for querying metrics Source: https://simplecloud.app/docs/en/developer/api-reference/metrics/query-current-metric-values Uses the net/http package to send a GET request to the metrics query endpoint with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/metrics/query" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example for rolling restart Source: https://simplecloud.app/docs/en/developer/api-reference/server-groups/start-a-rolling-restart Uses net/http to send a POST request with the server group ID. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://controller.simplecloud.app/v0/server-groups/rolling-restart" payload := strings.NewReader("{\n \"server_group_id\": \"\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Network-ID", "") req.Header.Add("X-Network-Credential", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Java Unirest example Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-uuid Uses Unirest to GET player data and returns the response as a string. ```java HttpResponse response = Unirest.get("https://controller.simplecloud.app/v0/players/id") .header("X-Network-ID", "") .header("X-Network-Credential", "") .asString(); ``` -------------------------------- ### JavaScript fetch example Source: https://simplecloud.app/docs/en/developer/api-reference/players/get-player-by-uuid Uses fetch to GET player data and logs the JSON response. ```javascript const options = { method: 'GET', headers: {'X-Network-ID': '', 'X-Network-Credential': ''} }; fetch('https://controller.simplecloud.app/v0/players/id', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Manual plugin JAR installation Source: https://simplecloud.app/docs/en/manual/plugin/overview Place a plugin JAR into the plugins/ folder of the matching template to install it manually. ```bash cp my-plugin.jar templates/lobby/plugins/ ``` -------------------------------- ### Switch between networks Source: https://simplecloud.app/docs/en/manual/introduction/architecture/cli The CLI saves each network as a context and sends network commands to the active one. Setup creates your first context automatically. Use 'sc context list' to list contexts and 'sc context use ' to switch. ```bash sc context list ``` ```bash sc context use ```