Why use API Keys?
API Keys are the best way for server-side scripts, CI/CD pipelines, and Minecraft plugins to interact with our API. Unlike JWTs, API keys provide persistent access and do not expire.
Generating a Key
Follow these steps to create your first API key:
- Dashboard: Go to your Account Settings.
- Creation: Navigate to the API Keys tab and click on “Create New Key”.
- Storage: Copy the key immediately. For security reasons, it will never be shown again in its full form.
To use your API key, include it in the X-API-Key HTTP header:
curl -X GET https://api.craftingstudiopro.de/v1/plugins/my-plugin/latest \
-H "X-API-Key: YOUR_API_KEY_HERE"
Java Implementation Example
If you are developing a Minecraft plugin, here is a simple way to check for updates using Java’s HttpClient:
public void checkUpdate(String slug, String apiKey) {
try {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.craftingstudiopro.de/v1/plugins/" + slug + "/latest"))
.header("X-API-Key", apiKey)
.GET()
.build();
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(json -> {
// The API responds with the latest version info
System.out.println("Update info: " + json);
});
} catch (Exception e) {
e.printStackTrace();
}
}
Best Practice: Never hardcode your API key directly in your source code. Instead, create a config.yml for your plugin so users can enter their own keys.