Overview
The Vacation Statistics API provides administrators with comprehensive analytics about employee vacation usage. These endpoints offer aggregated statistics, distribution by department, and detailed employee listings.
All endpoints in this section require Admin or RRHH role permissions.
Endpoints
Statistics Get overall vacation statistics
Distribution View vacation distribution by department
Employee List Access detailed employee vacation data
Get Statistics
GET /api/vacaciones/admin/stats
curl -X GET "https://api.example.com/api/vacaciones/admin/stats" \
-H "Authorization: Bearer YOUR_TOKEN"
Retrieves overall vacation statistics including total employees, vacation usage, and pending requests.
Response
{
"status" : "success" ,
"data" : {
"totalEmpleados" : 250 ,
"totalDiasDisponibles" : 3500 ,
"totalDiasUsados" : 1840 ,
"totalDiasPendientes" : 1660 ,
"solicitudesPendientes" : 12 ,
"solicitudesAprobadas" : 145 ,
"solicitudesRechazadas" : 8 ,
"porcentajeUso" : 52.57 ,
"promedioVacacionesPorEmpleado" : 7.36
}
}
Response Fields
Total number of employees in the system
Total vacation days available across all employees
Total vacation days already used
Total vacation days remaining
Number of pending vacation requests awaiting approval
Number of approved vacation requests
Number of rejected vacation requests
Percentage of total vacation days used
promedioVacacionesPorEmpleado
Average vacation days used per employee
Get Distribution
GET /api/vacaciones/admin/distribucion
curl -X GET "https://api.example.com/api/vacaciones/admin/distribucion" \
-H "Authorization: Bearer YOUR_TOKEN"
Retrieves vacation distribution statistics grouped by department/area.
Response
{
"status" : "success" ,
"data" : [
{
"id_area" : 1 ,
"nombre_area" : "Recursos Humanos" ,
"totalEmpleados" : 15 ,
"diasDisponibles" : 210 ,
"diasUsados" : 98 ,
"diasPendientes" : 112 ,
"porcentajeUso" : 46.67
},
{
"id_area" : 2 ,
"nombre_area" : "Tecnología" ,
"totalEmpleados" : 45 ,
"diasDisponibles" : 630 ,
"diasUsados" : 342 ,
"diasPendientes" : 288 ,
"porcentajeUso" : 54.29
},
{
"id_area" : 3 ,
"nombre_area" : "Ventas" ,
"totalEmpleados" : 60 ,
"diasDisponibles" : 840 ,
"diasUsados" : 456 ,
"diasPendientes" : 384 ,
"porcentajeUso" : 54.29
},
{
"id_area" : 4 ,
"nombre_area" : "Operaciones" ,
"totalEmpleados" : 80 ,
"diasDisponibles" : 1120 ,
"diasUsados" : 623 ,
"diasPendientes" : 497 ,
"porcentajeUso" : 55.63
}
]
}
Response Fields
Each department object contains:
Department/area unique identifier
Number of employees in this department
Total vacation days available for this department
Total vacation days used by this department
Total vacation days remaining for this department
Percentage of vacation days used in this department
Get Employee List
GET /api/vacaciones/admin/listado-global
curl -X GET "https://api.example.com/api/vacaciones/admin/listado-global?page=1&limit=20&id_area=2&search=John" \
-H "Authorization: Bearer YOUR_TOKEN"
Retrieves a paginated list of employees with their vacation details, with optional filtering.
Query Parameters
Search term to filter by employee name or ID
Filter by clinic/location ID
Filter by department/area ID
Page number for pagination
Number of results per page
Response
{
"status" : "success" ,
"data" : {
"empleados" : [
{
"id_empleado" : 42 ,
"nombre" : "John Doe" ,
"email" : "[email protected] " ,
"id_area" : 2 ,
"nombre_area" : "Tecnología" ,
"id_clinica" : 1 ,
"nombre_clinica" : "Sede Central" ,
"diasDisponibles" : 14 ,
"diasUsados" : 7 ,
"diasPendientes" : 7 ,
"solicitudesPendientes" : 1 ,
"ultimaSolicitud" : "2024-02-28T10:00:00Z"
},
{
"id_empleado" : 58 ,
"nombre" : "Jane Smith" ,
"email" : "[email protected] " ,
"id_area" : 2 ,
"nombre_area" : "Tecnología" ,
"id_clinica" : 1 ,
"nombre_clinica" : "Sede Central" ,
"diasDisponibles" : 14 ,
"diasUsados" : 10 ,
"diasPendientes" : 4 ,
"solicitudesPendientes" : 0 ,
"ultimaSolicitud" : "2024-01-15T14:30:00Z"
}
],
"pagination" : {
"currentPage" : 1 ,
"totalPages" : 5 ,
"totalRecords" : 45 ,
"recordsPerPage" : 10
}
}
}
Response Structure
Array of employee vacation data objects
Pagination metadata Total number of employee records
Number of records per page
Usage Example
const getVacationStats = async () => {
try {
// Get overall statistics
const statsResponse = await fetch (
'https://api.example.com/api/vacaciones/admin/stats' ,
{
headers: {
'Authorization' : `Bearer ${ token } `
}
}
);
const stats = await statsResponse . json ();
// Get distribution by department
const distributionResponse = await fetch (
'https://api.example.com/api/vacaciones/admin/distribucion' ,
{
headers: {
'Authorization' : `Bearer ${ token } `
}
}
);
const distribution = await distributionResponse . json ();
// Get filtered employee list
const employeesResponse = await fetch (
'https://api.example.com/api/vacaciones/admin/listado-global?id_area=2&page=1&limit=20' ,
{
headers: {
'Authorization' : `Bearer ${ token } `
}
}
);
const employees = await employeesResponse . json ();
return { stats , distribution , employees };
} catch ( error ) {
console . error ( 'Error fetching vacation data:' , error );
}
};
Implementation Reference
Source files:
Routes: src/routes/vacacionesRoutes.js:15-17
Controller: src/controllers/vacacionesAdminController.js:3-54