Skip to main content
Saves the user’s guesses for a specific date, calculates geographic relationships, and manages session state. This endpoint handles both creating new sessions and updating existing progress.

Endpoint

Request body

string
required
The game date in YYYY-MM-DD format
Country[]
required
Array of country guesses. Each guess should include basic country data that will be enriched with calculated fields.

Response

boolean
required
Indicates if the progress was saved successfully
string
required
The user’s session ID (UUID v4 format)
boolean
required
Whether the user has won the game (guessed correctly)
Country[]
required
The enriched array of guesses with calculated fields

Geographic calculations

The endpoint enriches each guess with calculated geographic data: Distance calculation uses the Haversine formula:
From app/api/progress/route.ts:39 Bearing calculation computes the angle from guess to target:
From app/api/progress/route.ts:40 Connection logic determines geographic relationships:
From app/api/progress/route.ts:44-49

Session management

The endpoint automatically creates and manages user sessions:
  1. Checks for existing geo_session cookie
  2. Generates new UUID v4 session ID if not present
  3. Sets HTTP-only cookie with 10-year expiration
  4. Associates all progress with the session ID
From app/api/progress/route.ts:20-22

Win detection

The game is marked as won when the newest guess matches the target country name (case-insensitive):
From app/api/progress/route.ts:65-68

Example request

Example response

The guesses array in the response is enriched with distance, bearing, and connection fields calculated on the server.

Error responses

Invalid payload:
Status: 400 This occurs when:
  • date is missing
  • guesses is not an array
Failed to save:
Status: 500 This occurs when the database operation fails.

Code example


GET /api/progress

Retrieves the user’s progress for a specific date, including guess history and personal statistics.

Endpoint

Query parameters

string
required
The game date in YYYY-MM-DD format.Validation: Must match the pattern ^\d{4}-\d{2}-\d{2}$

Authentication

Requires geo_session cookie. If no session exists, returns empty progress.

Response

Country[]
required
Array of the user’s guesses for this date (enriched with distance/bearing/connection)
boolean
required
Whether the user won this game
object
required
User’s overall statistics across all games

Example request

Example response

With existing progress:
No session or no progress:

Error responses

Invalid date:
Status: 400 Server error:
Status: 500

Code example