Get Active Trips (Passenger)
GET /viajes/get_active_trips.php
Retrieve all active trips for a passenger.
Query Parameters
Response
List of active trips (status: pendiente, aceptado, en_ruta, en_curso)
Request Example
curl -X GET "https://76.13.114.194/viajes/get_active_trips.php?usuario_id=456" \
-H "Accept: application/json"
Response Example
{
"success": true,
"trips": [
{
"id": 789,
"usuario_id": 456,
"conductor_id": 25,
"tipo_servicio": "motocicleta",
"estado": "en_curso",
"origen": {
"direccion": "Carrera 15 #85-30",
"latitud": 4.6814,
"longitud": -74.0479
},
"destino": {
"direccion": "Calle 72 #10-20",
"latitud": 4.6533,
"longitud": -74.0602
},
"precio_estimado": 18500,
"fecha_solicitud": "2024-03-15T14:30:00.000Z"
}
]
}
Get Trip History (Passenger)
GET /viajes/get_trip_history.php
Retrieve completed and cancelled trip history for a passenger.
Query Parameters
Response
List of historical trips (status: completado or cancelado)
Request Example
curl -X GET "https://76.13.114.194/viajes/get_trip_history.php?usuario_id=456" \
-H "Accept: application/json"
Response Example
{
"success": true,
"trips": [
{
"id": 788,
"usuario_id": 456,
"conductor_id": 20,
"tipo_servicio": "motocicleta",
"estado": "completado",
"origen": {
"direccion": "Calle 100 #15-20",
"latitud": 4.6900,
"longitud": -74.0450
},
"destino": {
"direccion": "Carrera 7 #50-30",
"latitud": 4.6350,
"longitud": -74.0650
},
"precio_estimado": 22000,
"precio_final": 22000,
"distancia_km": 5.8,
"fecha_solicitud": "2024-03-14T10:15:00.000Z",
"fecha_aceptacion": "2024-03-14T10:17:00.000Z",
"fecha_inicio": "2024-03-14T10:25:00.000Z",
"fecha_fin": "2024-03-14T10:45:00.000Z",
"calificacion_conductor": 5,
"comentario_conductor": "Excelente servicio"
},
{
"id": 787,
"usuario_id": 456,
"conductor_id": null,
"tipo_servicio": "auto",
"estado": "cancelado",
"motivo_cancelacion": "Cambio de planes",
"fecha_solicitud": "2024-03-13T15:30:00.000Z"
}
]
}
Get Active Trips (Driver)
GET /viajes/get_conductor_active_trips.php
Retrieve all active trips for a driver.
Query Parameters
Response
List of driver’s active trips
Request Example
curl -X GET "https://76.13.114.194/viajes/get_conductor_active_trips.php?conductor_id=25" \
-H "Accept: application/json"
Get Trip History (Driver)
GET /viajes/get_conductor_history.php
Retrieve trip history for a driver.
Query Parameters
Response
List of driver’s completed and cancelled trips
Request Example
curl -X GET "https://76.13.114.194/viajes/get_conductor_history.php?conductor_id=25" \
-H "Accept: application/json"
Response Example
{
"success": true,
"trips": [
{
"id": 789,
"usuario_id": 456,
"conductor_id": 25,
"tipo_servicio": "motocicleta",
"estado": "completado",
"precio_final": 19000,
"distancia_km": 4.5,
"fecha_solicitud": "2024-03-15T14:30:00.000Z",
"fecha_fin": "2024-03-15T15:00:00.000Z",
"calificacion_usuario": 5,
"comentario_usuario": "Muy buen conductor"
}
]
}
Filter and Sort Options
Currently, the API returns all trips without pagination or filtering. For large datasets, consider implementing client-side filtering.
Client-Side Filtering Example
List<Trip> filterTripsByDate(
List<Trip> trips,
DateTime startDate,
DateTime endDate,
) {
return trips.where((trip) {
return trip.fechaSolicitud.isAfter(startDate) &&
trip.fechaSolicitud.isBefore(endDate);
}).toList();
}
List<Trip> filterByServiceType(
List<Trip> trips,
String serviceType,
) {
return trips.where((trip) => trip.tipoServicio == serviceType).toList();
}
List<Trip> sortByDate(List<Trip> trips, {bool descending = true}) {
trips.sort((a, b) {
final comparison = a.fechaSolicitud.compareTo(b.fechaSolicitud);
return descending ? -comparison : comparison;
});
return trips;
}
Trip Statistics
Calculate statistics from trip history:
class TripStatistics {
final List<Trip> trips;
TripStatistics(this.trips);
int get totalTrips => trips.length;
int get completedTrips => trips.where((t) => t.estado == 'completado').length;
int get cancelledTrips => trips.where((t) => t.estado == 'cancelado').length;
double get totalSpent {
return trips
.where((t) => t.precioFinal != null)
.fold(0.0, (sum, trip) => sum + trip.precioFinal!);
}
double get averageTripCost {
final completed = trips.where((t) => t.precioFinal != null).toList();
if (completed.isEmpty) return 0.0;
return totalSpent / completed.length;
}
double get totalDistance {
return trips
.where((t) => t.distanciaKm != null)
.fold(0.0, (sum, trip) => sum + trip.distanciaKm!);
}
}
Error Responses
Server error retrieving trips
See Also