Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Danielsl4/TFG_DAM_2526_Consulta2/llms.txt

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

The voting system lets authenticated users predict the outcome of upcoming matches. Each user can vote once per match, but may update their vote at any time while the match is still pendiente. When a match is finalized, every user whose vote matched the actual result receives 1 point added to their season ranking.
Voting closes the moment the match status changes away from pendiente. Make sure to cast your vote before the match starts.

Cast or update a vote

POST /matches/:id/vote
Inserts a new vote or updates an existing one (upsert). Returns the updated community voting statistics immediately after recording the vote.

Authentication

Required. Any authenticated user (user, referee, or admin role) may vote.

Path parameters

id
integer
required
Match ID to vote on.

Body parameters

vote
string
required
Predicted outcome. Must be one of:
ValueMeaning
localHome team wins
empateDraw
visitanteAway team wins

Restrictions

  • The match status must be pendiente. Voting on a match that is en_curso or finalizado returns 400.
  • Both homeTeam and awayTeam must be assigned (not null). Voting on a match with unresolved team slots returns 400.

Response

{
  "message": "Voto registrado correctamente",
  "votingStats": {
    "local": 15,
    "draw": 5,
    "away": 3,
    "total": 23
  }
}
message
string
Confirmation message.
votingStats
object
Updated aggregate vote counts after recording the vote.

Error responses

StatusCondition
400vote value is not local, empate, or visitante
400Match is not in pendiente status
400One or both teams are not yet assigned
404Match not found
401No token provided or token invalid

Point award logic

When a referee calls PUT /matches/:id/finish, the server:
  1. Determines the result: local (home goals > away goals), visitante (away goals > home goals), or empate (equal).
  2. Marks all matching votes with points_awarded = 1.
  3. Increments the points counter in user_points for every correct voter for the current season.
No manual action is needed — points are applied atomically as part of match finalization.

Examples

curl --request POST \
  --url 'https://api.example.com/matches/42/vote' \
  --header 'Authorization: Bearer <your_token>' \
  --header 'Content-Type: application/json' \
  --data '{ "vote": "local" }'
{
  "message": "Voto registrado correctamente",
  "votingStats": {
    "local": 15,
    "draw": 6,
    "away": 3,
    "total": 24
  }
}

Get last global activity

GET /matches/last-activity
Public endpoint. Returns the Unix timestamp (milliseconds) of the most recent change to any match — useful for polling clients to detect when they should refresh their local data.

Authentication

None required.

Response

{ "timestamp": 1747782061000 }
timestamp is null when no activity has been recorded yet.

Build docs developers (and LLMs) love