← Inicio

API REST

Conecta dispositivos móviles, marcadores físicos o integraciones a tu organización. Toda la API es multi-tenant: cada solicitud está aislada al tenant del token JWT.

Autenticación

Inicia sesión por API y guarda el token. Envíalo en cada request en el headerAuthorization: Bearer <token>.

# Crear cuenta + tenant (devuelve token)
curl -X POST http://localhost:3000/api/auth/signup \
  -H 'content-type: application/json' \
  -d '{
    "organizationName": "Club Halcones",
    "name": "Carlos Pérez",
    "email": "carlos@example.com",
    "password": "supersecret"
  }'

# Login
curl -X POST http://localhost:3000/api/auth/login \
  -H 'content-type: application/json' \
  -d '{ "email": "carlos@example.com", "password": "supersecret" }'

# Usar token
curl http://localhost:3000/api/auth/me \
  -H 'Authorization: Bearer eyJhbGciOi...'

Equipos

GET/api/v1/teams
Listar equipos del tenant
POST/api/v1/teams
Crear equipo
{
  "name": "Halcones",
  "shortName": "HAL",
  "color": "#f97316"
}
GET/api/v1/teams/{id}
Detalle con jugadores
PATCH/api/v1/teams/{id}
Actualizar equipo
DELETE/api/v1/teams/{id}
Eliminar equipo

Jugadores

GET/api/v1/players?teamId=…
Listar jugadores (opcional por equipo)
POST/api/v1/players
Crear jugador
{
  "teamId": "…",
  "fullName": "Juan Pérez",
  "jerseyNumber": 23,
  "position": "SG",
  "heightCm": 195
}
PATCH/api/v1/players/{id}
Actualizar jugador
DELETE/api/v1/players/{id}
Eliminar jugador

Torneos

GET/api/v1/tournaments
Listar torneos
POST/api/v1/tournaments
Crear torneo
{
  "name": "Liga 2026",
  "format": "LEAGUE",
  "teamIds": [
    "team_a",
    "team_b"
  ]
}
GET/api/v1/tournaments/{id}
Detalle con equipos y partidos
GET/api/v1/tournaments/{id}/standings
Tabla de posiciones
GET/api/v1/tournaments/{id}/leaders
Líderes estadísticos
POST/api/v1/tournaments/{id}/teams
Inscribir equipo
{
  "teamId": "…"
}

Partidos

GET/api/v1/games?tournamentId=…&status=LIVE
Listar partidos
POST/api/v1/games
Crear partido
{
  "homeTeamId": "…",
  "awayTeamId": "…",
  "tournamentId": "…(opcional)"
}
GET/api/v1/games/{id}
Detalle con rosters
POST/api/v1/games/{id}/start
Marcar como LIVE
POST/api/v1/games/{id}/finish
Finalizar
POST/api/v1/games/{id}/quarter
Cambiar cuarto
{
  "quarter": 2
}

Eventos del partido (canastas, faltas, etc.)

El endpoint principal para registrar acciones desde el móvil.

GET/api/v1/games/{id}/events
Histórico de eventos
POST/api/v1/games/{id}/events
Registrar evento
{
  "type": "POINT_2",
  "teamId": "…",
  "playerId": "…(opcional)",
  "quarter": 1,
  "gameClockSec": 543
}
DELETE/api/v1/games/{id}/events/{eventId}
Deshacer evento

Tipos válidos:

POINT_1POINT_2POINT_3FOUL_PERSONALFOUL_TECHNICALFOUL_FLAGRANTREBOUNDASSISTSTEALBLOCKTURNOVERTIMEOUT

Estadísticas

GET/api/v1/games/{id}/stats
Stats de equipo y por jugador para el partido