Krak Multiplayer API
내 월드의 상태를 Discord, Telegram이나 내 웹사이트에 보여 주고, Krak Server에서 돌아가는 월드를 봇이 시작하고 멈추게 할 수 있어요. 평범한 HTTPS 요청, JSON 응답, 앱에서 만드는 개인 키만 있으면 돼요.
API로 할 수 있는 것
- 내 월드의 상태 읽기: 온라인 여부, 플레이어 수와 최대 인원, Minecraft 버전, 플레이어가 접속하는 주소, 초대 링크, 평점.
- Krak Server에서 돌아가는 월드 시작, 정지, 재시작.
- 카탈로그에 공개된 월드 하나를 키 없이 보여 주기(웹사이트의 상태 위젯용).
API가 하지 않는 것
- Minecraft 서버 자체를 시작하지는 않아요. Krak Server는 컴퓨터에서 이미 돌아가고 있는 서버를 공유하므로, 시작은 월드의 호스트를 켠다는 뜻이에요.
- 휴대폰이나 PC 앱에서 호스트하는 월드는 읽기만 할 수 있고, 시작하거나 멈출 수는 없어요.
- 재시작은 Krak의 월드 호스트를 다시 시작할 뿐, Minecraft 서버를 다시 시작하지 않아요.
- 플레이어나 호스트의 IP 주소는 절대 보여 주지 않아요. 주소는 월드의 Krak 주소(.krakmc.cc로 끝나요)나 외부 서버 주인이 입력한 주소예요.
키 받기
- Krak Multiplayer를 열고 ‘설정’ > ‘개발자용’으로 가세요.
- ‘키 만들기’를 탭하고 이름을 정하세요(예: Discord 봇).
- 봇이 월드를 시작하고 멈추게 하려면 ‘내 월드를 시작하고 멈출 수 있음’을 켜세요. 끄면 키는 읽기만 할 수 있어요.
- 키(krak_로 시작해요)를 복사하세요. 앱은 키를 한 번만 보여 줘요.
계정 하나에 키는 최대 5개까지 만들 수 있어요. 비밀번호를 바꾸거나 재설정하거나, 모든 기기에서 로그아웃하거나, 밴을 받거나, 계정을 삭제하면 모든 키가 취소돼요.
키는 비밀로 지키세요. 키가 있는 사람은 누구나 내 월드를 읽을 수 있고, 스위치가 켜져 있으면 시작하고 멈출 수도 있어요. 공유하는 코드에는 절대 넣지 말고, 봇이 환경 변수에서 읽게 하세요. 유출됐다면 앱의 같은 곳에서 키를 삭제하세요. 바로 작동을 멈춰요.
요청
모든 엔드포인트는 이 주소 아래에 있어요:
https://krak-mp.cc/api/public/v1
모든 요청의 Authorization 헤더에 키를 넣어 보내세요(GET /worlds/{id}만 키가 필요 없어요):
Authorization: Bearer krak_k7q4m2xp_…
응답은 JSON이에요. 모든 id는 숫자로 된 문자열이고, 시간은 Unix 밀리초예요. 오류는 HTTP 상태와 이런 본문으로 와요. code를 기준으로 판단하세요(message는 바뀔 수 있어요):
{"error": {"code": "world_not_found", "message": "…"}}
엔드포인트
GET /me
아무 키나
키의 주인: 내 계정의 id와 닉네임, 그리고 키와 그 범위(scope)예요. 키가 작동하는지 빠르게 확인할 때 좋아요.
요청
curl https://krak-mp.cc/api/public/v1/me \
-H "Authorization: Bearer krak_k7q4m2xp_…"
응답 200 OK
{
"id": "100123",
"nickname": "MrKrak",
"key": {"id": "7", "name": "Discord bot", "prefix": "krak_k7q4m2xp", "scopes": ["read", "control"]}
}
GET /me/worlds
아무 키나
내 월드 목록(최대 50개, 최근에 바뀐 순서)이에요. 아래 엔드포인트에는 월드의 id가 필요해요. 한 번 호출해서 내 월드의 id를 찾으세요.
요청
curl https://krak-mp.cc/api/public/v1/me/worlds \
-H "Authorization: Bearer krak_k7q4m2xp_…"
응답 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}
아무 키나
내 월드 하나와 onlinePlayers(지금 월드에 있는 플레이어의 Krak 닉네임)예요. 서버에 직접 접속한 플레이어는 players에는 세지만 이름은 나오지 않아요.
요청
curl https://krak-mp.cc/api/public/v1/me/worlds/12 \
-H "Authorization: Bearer krak_k7q4m2xp_…"
응답 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"]
}
월드 필드
POST /me/worlds/{id}/start
‘내 월드를 시작하고 멈출 수 있음’이 켜진 키
월드가 배정된 Krak Server에서 월드의 호스트를 켜요. 몇 초 안에 hosting.state가 starting이 되고, Minecraft 서버가 응답하면 live가 돼요. 이미 켜진 월드는 그대로 응답해요.
응답에는 GET /me/worlds/{id}가 주는 것과 같은 월드가 들어 있어요(여기서는 줄였어요). not_on_server, agent_offline, host_limit, room_blocked로 거부될 수 있어요. ‘오류’를 보세요.
요청
curl -X POST https://krak-mp.cc/api/public/v1/me/worlds/12/start \
-H "Authorization: Bearer krak_k7q4m2xp_…"
응답 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
‘내 월드를 시작하고 멈출 수 있음’이 켜진 키
월드의 호스트를 꺼요. Krak Server가 오프라인일 때도 작동해요.
요청
curl -X POST https://krak-mp.cc/api/public/v1/me/worlds/12/stop \
-H "Authorization: Bearer krak_k7q4m2xp_…"
응답 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
‘내 월드를 시작하고 멈출 수 있음’이 켜진 키
Krak의 월드 호스트, 즉 내 Minecraft 서버와 릴레이 사이의 연결을 다시 시작해요. Minecraft 서버 자체는 절대 다시 시작하지 않고, 결과도 알려 주지 않아요. 호스트가 꺼져 있으면 먼저 월드를 시작하세요(not_hosting).
요청
curl -X POST https://krak-mp.cc/api/public/v1/me/worlds/12/restart \
-H "Authorization: Bearer krak_k7q4m2xp_…"
응답 202 Accepted
{"ok": true, "commandIds": ["f3Kq9xY2LmPa0bCd"]}
GET /worlds/{id}
키 필요 없음
키 없이: 카탈로그에서 누구나 볼 수 있는 월드의 공개 상태로, 위젯과 상태 페이지에 쓸 수 있어요. 친구 전용이나 초대 전용 월드, 숨겨진 월드, 알 수 없는 월드는 404 world_not_found로 응답해요.
호스트 정보도 플레이어 이름도 없어요. 응답은 15초 동안 캐시되고, 어떤 사이트의 웹 페이지든 읽을 수 있어요(CORS가 열려 있어요).
요청
curl https://krak-mp.cc/api/public/v1/worlds/12
응답 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}
}
오류
API가 응답하는 모든 오류의 HTTP 상태와 코드예요:
제한
- 키당 1분에 60개 요청.
- 시작, 정지, 재시작은 추가로 계정당 1분에 10번, 키당 하루(UTC) 200번까지.
- 잘못된 키: IP 주소 하나에서 1분에 30번 실패하면 그 주소는 429를 받아요.
- GET /worlds/{id}: IP 주소당 1분에 60개 요청. 응답은 15초 동안 캐시되니 더 자주 물어봐도 새로운 건 없어요.
봇 예제
Python으로 만든 작은 봇 두 개예요. 둘 다 키와 월드 id를 환경 변수에서 읽어서 코드에 키가 들어가지 않아요.
내 월드의 id를 찾으려면 GET /me/worlds를 한 번 호출하고(위의 curl 요청) 내 월드의 id를 쓰세요.
/status만 쓴다면 스위치가 꺼진 키로 충분해요. 시작하고 멈추려면 ‘내 월드를 시작하고 멈출 수 있음’이 켜진 키가 필요해요. 시작과 정지는 관리자만 할 수 있어요: Discord에서는 ‘서버 관리하기’ 권한이 있는 멤버(기본값), Telegram에서는 내가 적은 사용자 id예요.
Discord 봇
명령어는 /status, /start, /stop이에요(discord.py 2). Discord Developer Portal에서 봇이 있는 애플리케이션을 만들고, bot과 applications.commands 범위로 내 서버에 초대한 다음 실행하세요:
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는 /start와 /stop을 ‘서버 관리하기’ 권한이 있는 멤버에게만 보여 줘요. 관리자는 ‘서버 설정’ > ‘연동’에서 바꿀 수 있어요.
Telegram 봇
명령어는 /status, /startworld, /stopworld예요(python-telegram-bot 21). /start와 /stop이 아닌 이유는 누군가 봇을 열면 Telegram이 직접 /start를 보내기 때문이에요. @BotFather로 봇을 만든 다음 실행하세요:
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()
월드를 시작하고 멈출 수 있는 사람은 TELEGRAM_ADMINS(쉼표로 구분)에 적은 Telegram 사용자 id뿐이에요.
API에 대한 질문이나 아이디어가 있나요? Discord 서버에서 물어보거나 support@krak-mp.cc로 메일을 보내 주세요.