openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: game description: EmbeddinGuessr game operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /game/daily: get: operationId: getDailyPuzzle tags: [game] summary: Get today's puzzle description: Returns today's puzzle with clue words and their 3D positions. Target position is revealed but word is hidden. responses: "200": description: Today's puzzle content: application/json: schema: $ref: "#/components/schemas/Puzzle" "503": description: Embeddings model not ready yet content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /game/endless: post: operationId: createEndlessPuzzle tags: [game] summary: Create a random endless-mode puzzle description: Generates a fresh random puzzle on every call. Intended for endless/practice mode — not the daily challenge. responses: "200": description: A freshly generated random puzzle content: application/json: schema: $ref: "#/components/schemas/Puzzle" "503": description: Embeddings model not ready yet content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /game/endless/leaderboard: get: operationId: getEndlessLeaderboard tags: [game] summary: Get endless mode leaderboard description: Returns top players ranked by fewest average guesses across all their endless games responses: "200": description: Endless leaderboard entries content: application/json: schema: type: array items: $ref: "#/components/schemas/EndlessLeaderboardEntry" /game/endless/leaderboard/submit: post: operationId: submitEndlessScore tags: [game] summary: Submit an endless mode score description: Records a completed endless game. Registers the player if username is new, or verifies password if returning. Returns updated leaderboard entry. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/EndlessSubmitRequest" responses: "200": description: Submission result with updated rank content: application/json: schema: $ref: "#/components/schemas/EndlessLeaderboardEntry" "401": description: Wrong password for existing username content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /game/guess: post: operationId: submitGuess tags: [game] summary: Submit a guess description: Submit a word guess for the current puzzle. Returns the 3D position of the guess, distance to target, and a temperature hint. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GuessRequest" responses: "200": description: Guess result content: application/json: schema: $ref: "#/components/schemas/GuessResult" "400": description: Invalid word or puzzle not available content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /game/leaderboard: get: operationId: getLeaderboard tags: [game] summary: Get top scores description: Returns the top players ranked by fewest guesses to solve the puzzle responses: "200": description: Leaderboard entries content: application/json: schema: type: array items: $ref: "#/components/schemas/LeaderboardEntry" /game/leaderboard/submit: post: operationId: submitLeaderboardScore tags: [game] summary: Submit score to leaderboard description: Attaches a player name to a solved session. Idempotent — returns existing entry if already submitted. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LeaderboardSubmitRequest" responses: "200": description: Updated leaderboard entry content: application/json: schema: $ref: "#/components/schemas/LeaderboardEntry" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Session not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /game/session: post: operationId: createSession tags: [game] summary: Create or resume a game session description: Creates a new game session for the daily puzzle. Returns existing session if one exists for this device. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateSessionRequest" responses: "200": description: Game session content: application/json: schema: $ref: "#/components/schemas/GameSession" /game/session/{sessionId}/submit: post: operationId: submitSessionGuess tags: [game] summary: Submit a guess in a session description: Submit a word guess within a tracked session. Persists guess history and detects win. parameters: - in: path name: sessionId required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GuessRequest" responses: "200": description: Guess result with session state content: application/json: schema: $ref: "#/components/schemas/SessionGuessResult" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Session not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /game/stats: get: operationId: getGameStats tags: [game] summary: Get game statistics description: Returns aggregate stats for today's puzzle (total players, average guesses, solve rate) responses: "200": description: Game statistics content: application/json: schema: $ref: "#/components/schemas/GameStats" /game/streak/{deviceId}: get: operationId: getStreak tags: [game] summary: Get player streak description: Returns the current and longest daily streak for a device parameters: - in: path name: deviceId required: true schema: type: string responses: "200": description: Streak info content: application/json: schema: $ref: "#/components/schemas/StreakInfo" components: schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object properties: error: type: string required: - error EmbeddingPoint: type: object properties: word: type: string x: type: number y: type: number z: type: number isClue: type: boolean similarityScore: type: number description: Cosine similarity to the target word (0–1). Present for clue words, absent for the target itself. required: - word - x - y - z - isClue Puzzle: type: object properties: id: type: integer date: type: string clues: type: array items: $ref: "#/components/schemas/EmbeddingPoint" target: $ref: "#/components/schemas/EmbeddingPoint" modelReady: type: boolean required: - id - date - clues - target - modelReady GuessRequest: type: object properties: word: type: string puzzleId: type: integer required: - word - puzzleId GuessResult: type: object properties: word: type: string x: type: number y: type: number z: type: number distanceToTarget: type: number temperature: type: string enum: [freezing, cold, cool, warm, hot, correct] isCorrect: type: boolean similarityScore: type: number required: - word - x - y - z - distanceToTarget - temperature - isCorrect - similarityScore CreateSessionRequest: type: object properties: deviceId: type: string puzzleId: type: integer required: - deviceId - puzzleId GameSession: type: object properties: id: type: string puzzleId: type: integer deviceId: type: string guesses: type: array items: $ref: "#/components/schemas/GuessResult" solved: type: boolean attemptCount: type: integer playerName: type: string nullable: true description: Set once the player submits their name to the daily leaderboard createdAt: type: string required: - id - puzzleId - deviceId - guesses - solved - attemptCount - createdAt SessionGuessResult: type: object properties: guess: $ref: "#/components/schemas/GuessResult" session: $ref: "#/components/schemas/GameSession" required: - guess - session LeaderboardEntry: type: object properties: rank: type: integer playerName: type: string isVerified: type: boolean attemptCount: type: integer solvedAt: type: string alreadySubmitted: type: boolean description: True when the session already had a name — submission was idempotent required: - rank - playerName - isVerified - attemptCount - solvedAt LeaderboardSubmitRequest: type: object properties: sessionId: type: string playerName: type: string required: - sessionId - playerName EndlessLeaderboardEntry: type: object properties: rank: type: integer username: type: string gamesPlayed: type: integer totalGuesses: type: integer avgGuesses: type: number lastPlayedAt: type: string required: - rank - username - gamesPlayed - totalGuesses - avgGuesses - lastPlayedAt EndlessSubmitRequest: type: object properties: guessCount: type: integer playerName: type: string description: Display name from the authenticated Clerk user. required: - guessCount - playerName StreakInfo: type: object properties: deviceId: type: string currentStreak: type: integer longestStreak: type: integer lastSolvedDate: type: string nullable: true required: - deviceId - currentStreak - longestStreak GameStats: type: object properties: totalPlayers: type: integer solvedCount: type: integer averageGuesses: type: number solveRate: type: number puzzleDate: type: string required: - totalPlayers - solvedCount - averageGuesses - solveRate - puzzleDate