Endpoint
Returns the ranking of all players ordered by score (wins minus losses) with tie-breakers applied.Response
Returns an array of ranking entries, each containing:The player’s rank position (1-based index)
Unique identifier (UUID) of the player
The player’s display name
Number of games won by the player
Number of games lost by the player
Calculated score (
wins - losses) used for rankingRanking Calculation
Players are ranked based on their score, which is calculated as:- Primary sort: Score (descending) - higher scores rank first
- Tie-breaker: Applied by the repository implementation when scores are equal
Players with the same score may have their relative positions determined by tie-breaking rules implemented at the database level.
Example Request
Example Response
Response (200 OK)
Empty Rankings
If no players have been created yet, the endpoint returns an empty array:Response (200 OK)
Understanding Scores
Positive Score
A player with more wins than losses has a positive score and ranks higher.Example: 10 wins, 3 losses = score of 7
Negative Score
A player with more losses than wins has a negative score and ranks lower.Example: 2 wins, 5 losses = score of -3
Zero Score
A player with equal wins and losses has a score of 0.Example: 5 wins, 5 losses = score of 0
New Players
New players start with 0 wins and 0 losses, giving them a score of 0.Example: 0 wins, 0 losses = score of 0
Implementation Details
The ranking endpoint is implemented using reactive programming with Project Reactor:Fetch Ranked Players
The repository’s
findRanking() method returns players sorted by score (descending):Map to Result
Each player is converted to a
RankingEntryResult with position (1-based), player details, and calculated score:Use Cases
The ranking endpoint is useful for:- Leaderboards: Display the top players in your application
- Player Profiles: Show a player’s current rank and compare with others
- Analytics: Track player performance over time
- Gamification: Encourage competition by showcasing rankings
Related Endpoints
Player Overview
Learn about the Player aggregate and statistics
Change Player Name
Update a player’s display name