Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/danielsl4/TFG_DAM_2526/llms.txt

Use this file to discover all available pages before exploring further.

FutsalManager collects statistics at three levels: the entire season (global aggregates), each team (performance rankings), and each player (individual rankings). There is also a separate user leaderboard based on match prediction points. All endpoints accept a season_id query parameter; when it is omitted the active season is used automatically.

Global season statistics

The GET /statistics endpoint starts by computing season-wide numbers from finalized matches.

matchesPlayed

Total number of matches with status = 'finalizado' in the season.

totalGoals

Sum of all goals scored across every finalized match (home_goals + away_goals).

avgGoals

Average goals per match, rounded to two decimal places.

totalYellows

Sum of yellow_cards across all team_stats rows for the season.

totalReds

Sum of red_cards across all team_stats rows for the season.

totalCleanSheets

Count of finalized matches where at least one side finished with zero goals conceded.

Team performance rankings

The same endpoint returns five team ranking lists, each showing the top 5 teams sorted by a different metric. Every entry includes the team ID, name, logo URL, and the relevant stat fields.
RankingSort keyDescription
mostWinswon DESCTeams with the most victories in the season
mostLosseslost DESCTeams with the most defeats
mostDrawsdrawn DESCTeams with the most drawn matches
bestOffensegoals_for DESCTeams that have scored the most goals
bestDefensegoals_against ASCTeams that have conceded the fewest goals
All five lists draw from the same team_stats query and are sorted in application code, so they share a single round-trip to the database.

Individual player rankings

Three player ranking lists are returned alongside the team rankings, each limited to the top 5 players.
Players ordered by goals DESC from player_stats. Every row includes the player’s name, photo URL, current team name, and goal count. All players with any season registration appear, including those with zero goals.
Players ordered by yellow_cards DESC. Only players with at least one yellow card appear (yellow_cards > 0).
Players ordered by red_cards DESC. Only players with at least one red card appear (red_cards > 0).
Each player entry in these lists is joined to team_players and teams to resolve the team name for the current season. Players who appear in multiple seasons are shown with the team name that matches the requested (or active) season.

User porra leaderboard

Separate from the per-season statistics, FutsalManager maintains a global prediction leaderboard based on users.points. Points accumulate across all seasons — each correct match vote earns 1 point.
GET /statistics/user-ranking returns the top 10 users ordered by points DESC, username ASC. No authentication is required.
example response
[
  { "id": 5, "username": "carlos_r", "points": 24 },
  { "id": 12, "username": "ana_m", "points": 19 }
]
Use the personal stats endpoint to build a user profile page showing voting history alongside the global rank badge.

Season filtering

Every statistics query defaults to the active season when no season_id is provided. The active season is resolved with a subquery:
(SELECT id FROM seasons WHERE is_active = true LIMIT 1)
Pass ?season_id=<id> to retrieve statistics for any past season. This makes it straightforward to display archived season data without changing anything else in the frontend.

Statistics API reference

Full request and response schema for all statistics endpoints.

Match voting (porra)

How users vote on matches and how points are awarded at finalization.

Player profiles

Individual player stat pages and season-by-season breakdowns.

League standings

Group-stage league tables and tie-breaking rules.

Build docs developers (and LLMs) love