Skip to main content

Get User Profile

Retrieve the authenticated user’s profile information.

Authentication

Authorization
string
required
Bearer JWT token obtained from login

Response

success
boolean
Indicates if the request was successful
user
object
User profile object

Example Request

curl -X GET 'https://api.fitaiid.com/api/users/profile' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN'

Example Response

{
  "success": true,
  "user": {
    "_id": "507f1f77bcf86cd799439011",
    "firstName": "Juan",
    "lastName": "Pérez",
    "email": "[email protected]",
    "fotoPerfil": "/uploads/profile-1234567890.jpg",
    "fitnessProfile": {
      "gender": "hombre",
      "age": 28,
      "height": 175,
      "weight": 75,
      "fitnessLevel": "intermedio",
      "mainGoal": "ganar masa muscular",
      "trainingLocation": "gym",
      "trainingDaysPerWeek": 4
    },
    "fitnessStats": {
      "totalWorkouts": 45,
      "totalExercises": 340,
      "totalMinutes": 2250,
      "currentStreak": 12,
      "maxStreak": 18,
      "achievements": [
        {
          "achievementId": "first_workout",
          "unlockedAt": "2024-01-15T10:30:00.000Z"
        },
        {
          "achievementId": "week_streak",
          "unlockedAt": "2024-02-01T18:45:00.000Z"
        }
      ]
    },
    "createdAt": "2024-01-15T08:00:00.000Z"
  }
}

Update Profile Photo

Upload a new profile photo for the authenticated user.

Authentication

Authorization
string
required
Bearer JWT token obtained from login

Request Body

fotoPerfil
file
required
Image file (JPEG, PNG, GIF). Uploaded as multipart/form-data.

Response

success
boolean
Indicates if the upload was successful
message
string
Success message
user
object
Updated user object with new photo URL

Example Request

const formData = new FormData();
formData.append('fotoPerfil', fileInput.files[0]);

const response = await fetch('https://api.fitaiid.com/api/users/profile/photo', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`
  },
  body: formData
});

const data = await response.json();

Example Response

{
  "success": true,
  "message": "Foto de perfil actualizada correctamente",
  "user": {
    "_id": "507f1f77bcf86cd799439011",
    "firstName": "Juan",
    "lastName": "Pérez",
    "fotoPerfil": "/uploads/profile-1710345678.jpg",
    "email": "[email protected]"
  }
}

Error Responses

400
error
No image file uploaded
{
  "success": false,
  "message": "No se subió ninguna imagen"
}
401
error
Invalid or missing JWT token
{
  "success": false,
  "message": "No autorizado"
}
404
error
User not found
{
  "success": false,
  "message": "Usuario no encontrado"
}

Update Profile

Update user profile information

User Statistics

Get detailed workout statistics

Achievements

View unlocked achievements

Build docs developers (and LLMs) love