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.

FutsalLeague Manager exposes a statistics API that surfaces season-wide numbers at three levels: global aggregates for the whole competition, per-team rankings across five performance dimensions, and individual player leaderboards for goals and cards. All figures are scoped to a single season and update automatically as matches are finalized. Registered users also have access to a personal stats view that shows their prediction game score and full vote history.

Global statistics

The global block in the statistics response summarises the entire season in six figures.
FieldDescription
matchesPlayedTotal number of finalized matches in the season.
totalGoalsSum of all goals scored across every finalized match.
avgGoalsAverage goals per finalized match, rounded to two decimal places.
totalYellowsSum of all yellow cards issued, aggregated from team_stats.
totalRedsSum of all red cards issued, aggregated from team_stats.
totalCleanSheetsNumber of finalized matches where at least one side kept a clean sheet (home goals = 0 or away goals = 0).

Team rankings

The teamRankings block contains five separate top-5 lists, each ranking teams by a different metric.
RankingSorted by
mostWinsMost matches won (won DESC).
mostLossesMost matches lost (lost DESC).
mostDrawsMost matches drawn (drawn DESC).
bestOffenseMost goals scored (goals_for DESC).
bestDefenseFewest goals conceded (goals_against ASC).
Each entry in these lists includes the team’s id, name, logo_url, and the raw stat values (won, lost, drawn, goals_for, goals_against).

Individual player rankings

The individualRankings block contains three top-5 player lists.
RankingSorted by
topScorersMost goals scored in regular time (goals DESC). Penalty-shootout goals are excluded.
topYellowCardsMost yellow cards received (yellow_cards DESC). Only players with at least one yellow card appear.
topRedCardsMost red cards received (red_cards DESC). Only players with at least one red card appear.
Each entry includes the player’s id, name, photo_url, their current team_name, and the value (the raw stat count).

Season filtering

All statistics are scoped to a season. Pass season_id to query any historical season.
GET /statistics?season_id=2
If season_id is omitted, the endpoint resolves the active season automatically (is_active = true).

Statistics response

{
  "global": {
    "matchesPlayed": 38,
    "totalGoals": 214,
    "avgGoals": 5.63,
    "totalYellows": 47,
    "totalReds": 6,
    "totalCleanSheets": 9
  },
  "teamRankings": {
    "mostWins": [
      { "id": 11, "name": "CD Fuenlabrada FS", "logo_url": "...", "won": 10, "lost": 1, "drawn": 1, "goals_for": 48, "goals_against": 12 },
      { "id": 3,  "name": "Rayo Vallecano FS",  "logo_url": "...", "won": 9,  "lost": 2, "drawn": 1, "goals_for": 41, "goals_against": 18 }
    ],
    "mostLosses": [
      { "id": 19, "name": "FC Alcobendas",      "logo_url": "...", "won": 1,  "lost": 9, "drawn": 2, "goals_for": 14, "goals_against": 39 }
    ],
    "mostDraws": [
      { "id": 7,  "name": "Atlético Pinto FS",  "logo_url": "...", "won": 4,  "lost": 3, "drawn": 5, "goals_for": 22, "goals_against": 21 }
    ],
    "bestOffense": [
      { "id": 11, "name": "CD Fuenlabrada FS",  "logo_url": "...", "won": 10, "lost": 1, "drawn": 1, "goals_for": 48, "goals_against": 12 }
    ],
    "bestDefense": [
      { "id": 11, "name": "CD Fuenlabrada FS",  "logo_url": "...", "won": 10, "lost": 1, "drawn": 1, "goals_for": 48, "goals_against": 12 }
    ]
  },
  "individualRankings": {
    "topScorers": [
      { "id": 22, "name": "Carlos Martínez", "photo_url": "...", "team_name": "Rayo Vallecano FS", "value": 17 },
      { "id": 44, "name": "Sergio Moreno",   "photo_url": "...", "team_name": "CD Fuenlabrada FS", "value": 14 }
    ],
    "topYellowCards": [
      { "id": 35, "name": "Javier López",    "photo_url": "...", "team_name": "Atlético Pinto FS", "value": 6 }
    ],
    "topRedCards": [
      { "id": 41, "name": "Miguel Sánchez",  "photo_url": "...", "team_name": "FC Alcobendas",     "value": 2 }
    ]
  }
}

Voting leaderboard

A separate endpoint returns the top 10 users ranked by prediction game points for the season.
GET /statistics/user-ranking?season_id=3
The response is an ordered array of user objects. Only accounts with the user role are included.
[
  { "id": 5,  "username": "futsal_fan_01", "points": 24 },
  { "id": 12, "username": "predictor_pro", "points": 21 },
  { "id": 8,  "username": "golazo",        "points": 19 }
]
Users with zero points still appear as long as they have a user_points row for the season; users who have never predicted correctly are not shown.

Personal stats

Authenticated users can retrieve their own prediction game summary via a protected endpoint.
GET /statistics/user-stats?season_id=3
Authorization: Bearer <token>
{
  "totalPoints": 19,
  "globalRank": 3,
  "history": [
    {
      "match_id": 15,
      "home_team_name": "Rayo Vallecano FS",
      "away_team_name": "Atlético Pinto FS",
      "home_goals": 3,
      "away_goals": 2,
      "status": "finalizado",
      "my_prediction": "local",
      "real_result": "local",
      "points_awarded": 1
    },
    {
      "match_id": 16,
      "home_team_name": "CD Fuenlabrada FS",
      "away_team_name": "FC Alcobendas",
      "home_goals": 5,
      "away_goals": 1,
      "status": "finalizado",
      "my_prediction": "empate",
      "real_result": "local",
      "points_awarded": 0
    }
  ]
}
The history array contains the last 20 matches the user voted on for the season, ordered by match date descending. Each entry shows the prediction made (my_prediction), the actual result (real_result), and whether a point was awarded (points_awarded: 1 for correct, 0 or null for incorrect or still pending).

Build docs developers (and LLMs) love