HTTP API
Served under /api, on the same port as the app. Live game state goes through the WebSocket protocol.
Errors
Section titled “Errors”Every error body is a translation key, to use as an error code:
{ "error": "errors:quizz.notFound" }| Case | Status | Key |
|---|---|---|
| Unknown route | 404 |
errors:api.notFound |
| Missing or invalid body | 400 |
errors:invalidRequest |
| Server error | 500 |
errors:api.serverError |
| Failed validation | 400 |
The key of the first failing rule |
DELETE routes answer 204 with no body.
Authentication
Section titled “Authentication”Sessions are JWTs, sent as Authorization: Bearer <token>. Player tokens last 30 days, manager tokens 12 hours.
| Route | Body | Returns |
|---|---|---|
POST /api/auth/session |
{ token? } |
{ token, clientId, role, expiresAt } |
POST /api/auth/manager |
{ password } |
Same, with role manager |
POST /api/auth/logout |
Same, back to role player |
/api/auth/session always answers 200:
| Token sent | Result |
|---|---|
| None or invalid | New session, new clientId |
| Valid | Same token |
| Expired | New token, same clientId, role player |
/api/auth/manager errors: 401 errors:manager.invalidPassword, 403 errors:manager.passwordNotConfigured. Logout doesn’t revoke the old manager token: it stays valid until it expires.
Manager routes
Section titled “Manager routes”Need a manager bearer, otherwise 401 errors:auth.unauthorized.
| Route | Returns |
|---|---|
GET /api/quizz |
{ quizz: [{ id, subject }] } |
GET /api/quizz/:id |
The quiz |
POST /api/quizz |
201 { id } |
PATCH /api/quizz/:id |
{ id } |
DELETE /api/quizz/:id |
204 |
GET /api/results |
{ results: [meta] } |
GET /api/results/:id |
The result |
DELETE /api/results/:id |
204 |
GET /api/media |
{ media: [{ name, url, type }] }, newest first |
POST /api/media |
201 { name, url, type } |
DELETE /api/media/:name |
204 |
POST /api/games |
201 { gameId, inviteCode } |
PATCH /api/games/:gameId/settings |
{ settings } |
- Quizzes are validated like the files in
config/quizz: see Quiz format. Unknown ids get404. - Media:
multipart/form-datawith afilefield. Max 100 MB (413). PNG, JPEG, WebP, GIF, MP3, OGG, WAV, MP4 or WebM, detected from the content (415otherwise). - Games: the manager then joins with
manager:reconnect { gameId }on the socket. Unused games expire after about 5 minutes. - Settings can be changed until the game starts (
409 errors:game.alreadyStartedafter). Send only what changes:
{ generatedUsernames?: boolean answersOnly?: boolean autoAdvance?: { enable: boolean, responsesDelay: number, leaderboardDelay: number } // delays: 3-600 s}Public routes
Section titled “Public routes”| Route | Auth | Body | Returns |
|---|---|---|---|
GET /api/health |
{ status: "ok" } |
||
POST /api/games/check |
{ inviteCode } |
{ generatedUsernames } |
|
POST /api/games/join |
Any bearer | { inviteCode, username? } |
{ gameId, ticket, username } |
inviteCodeis the 6-digit PIN. It is sent in a body to keep it out of logs and caches.usernameis 1 to 24 characters, ignored when the game generates nicknames (username: nullin the answer).ticketis valid 5 minutes, and is sent to the socket withplayer:login. It isnullif you already have a seat.
| Error | When |
|---|---|
404 errors:game.notFound |
Unknown PIN |
403 errors:game.locked |
Room locked by the host |
403 errors:game.managerCannotJoin |
You are the game’s manager |