Overview
TheGET /game/{id} endpoint retrieves the current state of a Blackjack game, including player and dealer hands, scores, and game status.
Endpoint
Path Parameters
The unique identifier of the game
Response
Returns a200 OK status with the following fields:
The unique identifier for the game
The unique identifier for the player
Current game status. Possible values:
IN_PROGRESS- Game is activePLAYER_BUST- Player exceeded 21DEALER_BUST- Dealer exceeded 21PLAYER_WINS- Player won the gameDEALER_WINS- Dealer won the gamePUSH- Game ended in a tie
The current score of the player’s hand (0-21 or higher if bust)
The dealer’s score. Important: If the game is still
IN_PROGRESS, this only shows the value of the dealer’s visible card, not their full hand score.Array of card objects in the player’s hand. Each card has:
rank(string): Card rank (e.g., “ACE”, “KING”, “SEVEN”)suit(string): Card suit (“HEARTS”, “DIAMONDS”, “CLUBS”, “SPADES”)hidden(boolean): Alwaysfalsefor player cards
Array of card objects in the dealer’s hand. Important: While the game is
IN_PROGRESS, only the first card is visible. Hidden cards have null rank and suit with hidden: true.Card Visibility Rules
The API implements standard Blackjack card visibility rules:During Active Game (status = IN_PROGRESS)
- Player cards: All cards are visible
- Dealer cards: Only the first card is visible, remaining cards are hidden
- Dealer score: Only shows the value of the first visible card
After Game Ends (any final status)
- Player cards: All cards visible
- Dealer cards: All cards visible
- Dealer score: Shows the full hand score
GameStateMapper.java:15-34, where the dealer’s cards and score are conditionally hidden based on game status.
Example Requests
Example Responses
Game In Progress
- The dealer’s second card is hidden (
rankandsuitarenull,hiddenistrue) - The
dealerScoreonly reflects the visible card (10)
Game Finished (Player Wins)
- All dealer cards are now visible
- The
dealerScoreshows the complete hand value (19) - The
statusindicates the final outcome
Game Finished (Push/Tie)
Error Responses
404 Not Found
Returned when the game doesn’t exist:Implementation Details
TheGetGameStateUseCase retrieves the game and maps it to the response format (GetGameStateUseCase.java:20-24):
GameStateMapper handles the card visibility logic, ensuring dealer cards are properly hidden during active gameplay.
Response Schema
Use Cases
- Check the current state before making your next move
- Display the game to the player in a UI
- Verify the outcome after the game has ended
- See which cards have been dealt
- Monitor your score and the dealer’s visible card
Next Steps
- Play a move (HIT or STAND)
- Delete the game when finished
- Create a new game to play again