MinecraftStatus
Documentation

Check Minecraft status with JavaScript

Copy this example, set an optional MINECRAFTSTATUS_API_KEY in the environment, and pass an edition plus address. The example preserves pending, quota and freshness boundaries.

Source

JavaScript · anonymous by default
const baseUrl = process.env.MINECRAFTSTATUS_API_BASE ?? "https://minecraftstatus.com";
const edition = process.argv[2] ?? "java";
const address = process.argv[3] ?? "play.example.net";
const headers = { accept: "application/json" };
if (process.env.MINECRAFTSTATUS_API_KEY) headers.authorization = `Bearer ${process.env.MINECRAFTSTATUS_API_KEY}`;

const response = await fetch(`${baseUrl}/api/v1/status/${edition}?address=${encodeURIComponent(address)}`, { headers });
const body = await response.json();
if (response.status === 429) {
  console.error(`Rate limited. Retry after ${response.headers.get("retry-after")} seconds.`);
  process.exitCode = 75;
} else if (response.status === 202) {
  console.log("Observation pending:", body.pollUrl);
} else if (!response.ok) {
  throw new Error(`MinecraftStatus API HTTP ${response.status}: ${body.error?.message ?? "request failed"}`);
} else {
  console.log(JSON.stringify(body, null, 2));
  if (body.freshness !== "fresh") console.error(`Current claim is ${body.freshness}; observe again before presenting it as current.`);
}

Run with an address argument such as java play.example.net. The source files are versioned alongside this documentation under examples/api/javascript/status.mjs.

Choose another language

Contract boundary

Every example branches on HTTP status first, prints a queued job receipt for 202, respects Retry-After for 429, and refuses to present stale or missing freshness as current.