Krak Multiplayer API
Show your worlds' status in Discord, Telegram or on your website, and let your bot start and stop a world that runs on Krak Server. Plain HTTPS requests, JSON answers and a personal key from the app.
What the API can do
- Read the status of your worlds: online or offline, players and the player limit, the Minecraft version, the address players join by, the invite link and the rating.
- Start, stop and restart a world that runs on Krak Server.
- Show one world that is open in the catalog without any key, for status widgets on websites.
What it does not do
- It never starts the Minecraft server itself. Krak Server shares a server that already runs on your machine, so start means switching hosting of the world on.
- Worlds hosted from a phone or PC app can only be read, not started or stopped.
- Restart restarts Krak's hosting of the world, not your Minecraft server.
- It never shows the IP addresses of players or hosts. The address is the world's Krak address (ending in .krakmc.cc) or the address the owner of an External server entered.
Get a key
- Open Krak Multiplayer and go to Settings > For developers.
- Tap Create key and give it a name, for example Discord bot.
- Turn on Can start and stop my worlds if your bot should start and stop worlds. Without it the key can only read.
- Copy the key (it starts with krak_). The app shows it only once.
An account can have up to 5 keys. Changing or resetting your password, signing out everywhere, a ban or deleting the account revokes all of them.
Keep the key secret: anyone who has it can read your worlds and, with the switch on, start and stop them. Never put it in code you share; let your bot read it from an environment variable. If it leaks, delete it in the same place in the app and it stops working at once.
Requests
Every endpoint is under this address:
https://krak-mp.cc/api/public/v1
Send your key in the Authorization header of every request (only GET /worlds/{id} needs none):
Authorization: Bearer krak_k7q4m2xp_…
Answers are JSON. Every id is a string of digits and times are Unix milliseconds. An error comes with its HTTP status and a body like this; rely on code, the message may change:
{"error": {"code": "world_not_found", "message": "…"}}
Endpoints
GET /me
Any key
Who the key belongs to: your account's id and nickname, and the key with its scopes. A quick way to check that a key works.
Request
curl https://krak-mp.cc/api/public/v1/me \
-H "Authorization: Bearer krak_k7q4m2xp_…"
Answer 200 OK
{
"id": "100123",
"nickname": "MrKrak",
"key": {"id": "7", "name": "Discord bot", "prefix": "krak_k7q4m2xp", "scopes": ["read", "control"]}
}
GET /me/worlds
Any key
Your worlds, at most 50, the most recently changed first. The id of a world is what the endpoints below take: call this once to find yours.
Request
curl https://krak-mp.cc/api/public/v1/me/worlds \
-H "Authorization: Bearer krak_k7q4m2xp_…"
Answer 200 OK
{
"items": [
{
"id": "12",
"name": "§aSky §lIsland",
"namePlain": "Sky Island",
"type": "local",
"visibility": "public",
"status": "online",
"online": true,
"players": 3,
"maxPlayers": 10,
"editions": ["bedrock"],
"version": "1.26.52",
"javaVersion": null,
"hosting": {
"kind": "server",
"state": "live",
"platform": null,
"server": {"id": "9", "name": "Home box", "online": true, "enabled": true}
},
"address": {
"bedrock": {"host": "k7q4m2xp.krakmc.cc", "port": 19132},
"java": null
},
"inviteUrl": "https://krak-mp.cc/j/KRK-7Q4MX2PA",
"rating": {"avg": 4.6, "count": 7},
"onlineSince": 1762600000000
}
]
}
GET /me/worlds/{id}
Any key
One of your worlds with onlinePlayers: the Krak nicknames of the players in the world now. Players who joined the server directly count in players but are not named.
Request
curl https://krak-mp.cc/api/public/v1/me/worlds/12 \
-H "Authorization: Bearer krak_k7q4m2xp_…"
Answer 200 OK
{
"id": "12",
"name": "§aSky §lIsland",
"namePlain": "Sky Island",
"type": "local",
"visibility": "public",
"status": "online",
"online": true,
"players": 3,
"maxPlayers": 10,
"editions": ["bedrock"],
"version": "1.26.52",
"javaVersion": null,
"hosting": {
"kind": "server",
"state": "live",
"platform": null,
"server": {"id": "9", "name": "Home box", "online": true, "enabled": true}
},
"address": {
"bedrock": {"host": "k7q4m2xp.krakmc.cc", "port": 19132},
"java": null
},
"inviteUrl": "https://krak-mp.cc/j/KRK-7Q4MX2PA",
"rating": {"avg": 4.6, "count": 7},
"onlineSince": 1762600000000,
"onlinePlayers": ["Alex", "Steve"]
}
World fields
POST /me/worlds/{id}/start
A key with Can start and stop my worlds
Switches hosting of the world on, on the Krak Server it is assigned to. Within seconds hosting.state becomes starting, then live once your Minecraft server answers. A world that is already on is answered as it is.
The answer has the world as GET /me/worlds/{id} returns it (shortened here). Refused with not_on_server, agent_offline, host_limit or room_blocked: see Errors.
Request
curl -X POST https://krak-mp.cc/api/public/v1/me/worlds/12/start \
-H "Authorization: Bearer krak_k7q4m2xp_…"
Answer 200 OK
{
"ok": true,
"world": {
"id": "12",
"namePlain": "Sky Island",
"status": "offline",
"online": false,
"players": 0,
"hosting": {
"kind": "server",
"state": "starting",
"platform": null,
"server": {"id": "9", "name": "Home box", "online": true, "enabled": true}
},
…
}
}
POST /me/worlds/{id}/stop
A key with Can start and stop my worlds
Switches hosting of the world off. It works even while the Krak Server is offline.
Request
curl -X POST https://krak-mp.cc/api/public/v1/me/worlds/12/stop \
-H "Authorization: Bearer krak_k7q4m2xp_…"
Answer 200 OK
{
"ok": true,
"world": {
"id": "12",
"namePlain": "Sky Island",
"status": "offline",
"online": false,
"players": 0,
"hosting": {
"kind": "server",
"state": "disabled",
"platform": null,
"server": {"id": "9", "name": "Home box", "online": true, "enabled": false}
},
…
}
}
POST /me/worlds/{id}/restart
A key with Can start and stop my worlds
Restarts Krak's hosting of the world: the connection between your Minecraft server and the relay. It never restarts the Minecraft server, and the result is not reported back. If hosting is off, start the world first (not_hosting).
Request
curl -X POST https://krak-mp.cc/api/public/v1/me/worlds/12/restart \
-H "Authorization: Bearer krak_k7q4m2xp_…"
Answer 202 Accepted
{"ok": true, "commandIds": ["f3Kq9xY2LmPa0bCd"]}
GET /worlds/{id}
No key
No key: the public status of a world that anyone sees in the catalog, for widgets and status pages. Worlds for friends or by invite only, hidden and unknown worlds answer 404 world_not_found.
No host details and no player names. The answer is cached for 15 seconds, and web pages on any site may read it (CORS is open).
Request
curl https://krak-mp.cc/api/public/v1/worlds/12
Answer 200 OK
{
"id": "12",
"name": "§aSky §lIsland",
"namePlain": "Sky Island",
"type": "local",
"online": true,
"players": 3,
"maxPlayers": 10,
"editions": ["bedrock"],
"version": "1.26.52",
"javaVersion": null,
"address": {
"bedrock": {"host": "k7q4m2xp.krakmc.cc", "port": 19132},
"java": null
},
"rating": {"avg": 4.6, "count": 7}
}
Errors
The HTTP status and the code of every error the API answers:
Limits
- 60 requests per minute per key, 120 per minute for all of your keys together.
- Start, stop and restart: also 10 per minute per account and 200 per key per day (UTC).
- Wrong keys: after 30 failed requests in a minute from one IP address, that address gets 429.
- GET /worlds/{id}: 60 requests per minute per IP address. The answer is cached for 15 seconds, so asking more often brings nothing new.
Bot examples
Two small bots in Python. Both read the key and the world id from environment variables, so the key never sits in the code.
To find your world's id, call GET /me/worlds once (the curl request above) and take the id of your world.
For /status a key without the switch is enough; to start and stop, the key needs Can start and stop my worlds. Only admins can start and stop: on Discord members with the Manage Server permission (by default), on Telegram the user ids you list.
Discord bot
Commands /status, /start and /stop (discord.py 2). Create an application with a bot in the Discord Developer Portal, invite it to your server with the bot and applications.commands scopes, then run it:
export KRAK_API_KEY="krak_k7q4m2xp_…"
export KRAK_WORLD_ID="12"
export DISCORD_TOKEN="…"
python discord_bot.py
# pip install discord.py
import os
import aiohttp
import discord
from discord import app_commands
API = "https://krak-mp.cc/api/public/v1"
KRAK_KEY = os.environ["KRAK_API_KEY"] # the key from the app: Settings > For developers
WORLD_ID = os.environ["KRAK_WORLD_ID"] # the "id" of your world in GET /me/worlds
DISCORD_TOKEN = os.environ["DISCORD_TOKEN"]
client = discord.Client(intents=discord.Intents.default())
tree = app_commands.CommandTree(client)
async def krak(method, path):
headers = {"Authorization": f"Bearer {KRAK_KEY}"}
async with aiohttp.ClientSession(headers=headers) as http:
async with http.request(method, API + path) as resp:
data = await resp.json(content_type=None)
if resp.status >= 400:
raise RuntimeError(data["error"]["code"])
return data
def describe(w):
state = "online" if w["online"] else "offline"
lines = [f"{w['namePlain']}: {state}, {w['players']}/{w['maxPlayers']} players"]
for edition, a in (w["address"] or {}).items():
if a:
lines.append(f"{edition.title()}: {a['host']}:{a['port']}")
return "\n".join(lines)
@tree.command(description="Show the world's status")
async def status(interaction: discord.Interaction):
try:
w = await krak("GET", f"/me/worlds/{WORLD_ID}")
await interaction.response.send_message(describe(w))
except RuntimeError as e:
await interaction.response.send_message(f"Could not read the status: {e}", ephemeral=True)
@tree.command(description="Start the world on Krak Server")
@app_commands.default_permissions(manage_guild=True)
async def start(interaction: discord.Interaction):
try:
await krak("POST", f"/me/worlds/{WORLD_ID}/start")
await interaction.response.send_message("Starting the world...")
except RuntimeError as e:
await interaction.response.send_message(f"Could not start: {e}", ephemeral=True)
@tree.command(description="Stop the world")
@app_commands.default_permissions(manage_guild=True)
async def stop(interaction: discord.Interaction):
try:
await krak("POST", f"/me/worlds/{WORLD_ID}/stop")
await interaction.response.send_message("The world is stopping.")
except RuntimeError as e:
await interaction.response.send_message(f"Could not stop: {e}", ephemeral=True)
@client.event
async def on_ready():
await tree.sync()
client.run(DISCORD_TOKEN)
Discord shows /start and /stop only to members with the Manage Server permission; an admin can change that in Server Settings > Integrations.
Telegram bot
Commands /status, /startworld and /stopworld (python-telegram-bot 21). They are not /start and /stop because Telegram itself sends /start when someone opens a bot. Create the bot with @BotFather, then run it:
export KRAK_API_KEY="krak_k7q4m2xp_…"
export KRAK_WORLD_ID="12"
export TELEGRAM_TOKEN="…"
export TELEGRAM_ADMINS="123456789"
python telegram_bot.py
# pip install python-telegram-bot
import os
import httpx
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes
API = "https://krak-mp.cc/api/public/v1"
KRAK_KEY = os.environ["KRAK_API_KEY"] # the key from the app: Settings > For developers
WORLD_ID = os.environ["KRAK_WORLD_ID"] # the "id" of your world in GET /me/worlds
TELEGRAM_TOKEN = os.environ["TELEGRAM_TOKEN"]
ADMINS = {int(x) for x in os.environ.get("TELEGRAM_ADMINS", "").split(",") if x} # user ids
async def krak(method, path):
async with httpx.AsyncClient(timeout=15) as http:
r = await http.request(method, API + path, headers={"Authorization": f"Bearer {KRAK_KEY}"})
data = r.json()
if r.is_error:
raise RuntimeError(data["error"]["code"])
return data
def describe(w):
state = "online" if w["online"] else "offline"
lines = [f"{w['namePlain']}: {state}, {w['players']}/{w['maxPlayers']} players"]
for edition, a in (w["address"] or {}).items():
if a:
lines.append(f"{edition.title()}: {a['host']}:{a['port']}")
return "\n".join(lines)
async def status(update: Update, context: ContextTypes.DEFAULT_TYPE):
try:
w = await krak("GET", f"/me/worlds/{WORLD_ID}")
await update.effective_message.reply_text(describe(w))
except RuntimeError as e:
await update.effective_message.reply_text(f"Could not read the status: {e}")
async def control(update: Update, action: str, done: str):
if update.effective_user.id not in ADMINS:
await update.effective_message.reply_text("Only admins can do that.")
return
try:
await krak("POST", f"/me/worlds/{WORLD_ID}/{action}")
await update.effective_message.reply_text(done)
except RuntimeError as e:
await update.effective_message.reply_text(f"Could not {action}: {e}")
async def start_world(update: Update, context: ContextTypes.DEFAULT_TYPE):
await control(update, "start", "Starting the world...")
async def stop_world(update: Update, context: ContextTypes.DEFAULT_TYPE):
await control(update, "stop", "The world is stopping.")
app = Application.builder().token(TELEGRAM_TOKEN).build()
app.add_handler(CommandHandler("status", status))
app.add_handler(CommandHandler("startworld", start_world))
app.add_handler(CommandHandler("stopworld", stop_world))
app.run_polling()
Only the Telegram user ids in TELEGRAM_ADMINS (separated by commas) can start and stop the world.
Questions or ideas about the API? Ask on our Discord server or write to support@krak-mp.cc.