Skip to main content

Overview

This endpoint returns the user’s progress through their current weekly workout routine, including which day they’re on, how many days completed, and the current cycle number.
This endpoint does not require explicit JWT authentication in the route definition, but should be protected in production.

Endpoint

GET /api/rutina/:userId/progreso

Path Parameters

userId
string
required
The MongoDB ObjectId of the user whose progress to retrieve

Response

success
boolean
Indicates if the request was successful
data
object
Progress information for the user’s routine

Code Examples

const userId = '507f1f77bcf86cd799439011';
const response = await fetch(`https://api.fitaiid.com/api/rutina/${userId}/progreso`, {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json'
  }
});

const data = await response.json();
console.log('Current day:', data.data.diaActualNombre);
console.log('Days completed:', data.data.diasCompletados);
console.log('Current cycle:', data.data.cicloActual);

Response Example

{
  "success": true,
  "data": {
    "diaActualIndex": 2,
    "diaActualNombre": "miércoles",
    "totalDias": 7,
    "diasCompletados": 2,
    "cicloActual": 1,
    "diaActualData": {
      "nombre": "Miércoles",
      "esDescanso": false,
      "enfoque": "Piernas y glúteos",
      "completado": false,
      "duracionTotal": 60,
      "caloriasEstimadas": 400,
      "ejercicios": [
        {
          "nombre": "Sentadillas",
          "series": 4,
          "repeticiones": "12-15",
          "descanso": "60 segundos"
        },
        {
          "nombre": "Peso muerto rumano",
          "series": 3,
          "repeticiones": "12-15",
          "descanso": "60 segundos"
        },
        {
          "nombre": "Zancadas",
          "series": 3,
          "repeticiones": "10-12 por pierna",
          "descanso": "45 segundos"
        }
      ]
    }
  }
}

Error Responses

400 Bad Request
object
Invalid user ID format
{
  "success": false,
  "message": "ID de usuario inválido"
}
404 Not Found
object
User not found or no routine assigned
{
  "success": false,
  "message": "No hay rutina asignada"
}

Implementation Details

Progress Tracking System

The progress system tracks users through their weekly routine with automatic cycling:
1

Day Tracking

The system maintains a diaActualIndex (0-6) to track which day of the week the user is on.
2

Completion Tracking

Each day has a completado boolean flag that indicates whether it has been finished.
3

Automatic Cycling

When a user completes the last day (day 6), the system automatically resets to day 0 and increments the cicloActual counter.
4

Historical Data

Completed workouts are saved to fitnessStats.workoutHistory for analytics and achievements.

User Model Methods

This endpoint uses the following User model methods (defined in src/models/User.js):
// Returns progress information
user.getProgresoRutina()
// Returns: { diaActualIndex, diaActualNombre, totalDias, diasCompletados, cicloActual, diaActualData }
If a user has no routine assigned (rutinaSemanal is empty), this endpoint will return a 404 error.

Use Cases

Dashboard Widget

Display current workout progress on the user’s dashboard

Mobile App Sync

Keep mobile app synchronized with user’s routine progress

Progress Analytics

Track completion rates and adherence over time

Motivation Features

Show streaks and achievements based on progress

Generate Routine

Generate a new AI-powered routine

Workout History

Get complete workout history

User Statistics

View detailed workout statistics

Best Practices

Performance: This endpoint is lightweight and safe to call frequently (e.g., every time the user opens their workout screen).
Caching: Consider caching this data client-side and only refreshing after completing a workout or when the user explicitly requests an update.

Build docs developers (and LLMs) love