Skip to content

REST API

weiqi-server exposes everything under the /api prefix. All endpoints require an authenticated session unless marked public.

Session cookie: better-auth.session_token. The __Secure- prefix is tried first. The guard lives in apps/weiqi-server/src/modules/accounts/presentation/guards/auth.guard.ts:30.

Roles (passed to Auth(...roles) decorator):

RoleNotes
userDefault for any signed-in account.
modChallenge moderation queue access.
adminAdmin console access.
super_adminReserved for emergency overrides.
MethodPathAuthNotes
GET/accounts/meYesCurrent user profile.
PATCH/accounts/meYesUpdate display name etc.
MethodPathAuthNotes
POST/gamesYesCreate a PvP game record.
GET/gamesYesList games for the caller.
GET/games/:idYesGame metadata.
PATCH/games/:idYesUpdate metadata (e.g. archive).
POST/games/:id/movesYesAppend a move; validates with weiqi-engine.
GET/games/:id/movesYesMove history.
MethodPathAuthNotes
GET/game/bot/levelsYesCatalog of the ten levels. See Bot Ladder.
POST/game/bot/gamesYesStart a new bot game.
GET/game/bot/games/:idYesGame state.
GET/game/bot/games/:id/movesYesMove list.
GET/game/bot/games/:id/reviewYesLatest KataGo review.
POST/game/bot/games/:id/moveYesPlayer move; bot replies.
POST/game/bot/games/:id/resignYesResign.
POST/game/bot/games/:id/hintYesOne-move hint. Entitlement-gated.
POST/game/bot/games/:id/undoYesUndo last move.
GET/game/bot/ladder/meYesCaller’s ladder state.
POST/game/bot/ladder/opt-inYesToggle ladder participation.
GET/game/bot/ladder/history?limit=50YesRecent rating deltas.
MethodPathAuthNotes
POST/analysis/games/:id/runFullReviewYesOne-call whole-game review. See KataGo Review.
GET/analysis/games/:id/snapshotsYesPer-node KataGo snapshots.
GET/analysis/games/:id/graphYesWinrate / score-lead series.
MethodPathAuthNotes
POST/challengesYesSubmit a new challenge.
GET/challengesPublicBrowse approved challenges.
POST/challenges/:id/solution-attemptsYesSubmit a solution.
GET/challenges/moderation/listmodModerator queue.
POST/challenges/moderation/approvemodApprove a submission.
POST/challenges/moderation/rejectmodReject a submission.
GET/challenges/my-submissions/listYesCaller’s own submissions.
MethodPathAuthNotes
POST/agent/runadminRun a natural-language analytics query.
GET/agent/tasks/:idadminPoll status of an agent task.

Socket.IO endpoint at /socket.io/ on the same origin. Auth is via the same session cookie. Events emitted: gameState, botMove, classified, gameEnded, plus analysis:turn while a runFullReview is in progress.

All errors share the same envelope:

{
"statusCode": 400,
"error": "Bad Request",
"message": "GameMessages.YOU_CANT_PLACE_STONE_ON_THIS_POSITION",
"code": "INVALID_MOVE"
}

code is a stable, machine-readable identifier. message is human-readable and may change between versions. Clients should branch on code.