Overview
The CECOCO Resources API provides access to real-time positioning data for emergency resources (vehicles, units) and active service incidents. You can use these endpoints to display resources and services on live monitoring maps.Get Resources and Services
Retrieves the latest GPS positions for all active resources and ongoing service incidents within a specified time window.Response Structure
The endpoint returns a JSON object containing two main arrays:Array of resource objects with current GPS positions
Unique identifier for the GPS position record
Reference to the resource entity
Resource name/identifier (e.g., “MOVIL-101”)
Latitude coordinate in radians (requires conversion)
Longitude coordinate in radians (requires conversion)
Latitude converted to decimal degrees (ready to use)
Longitude converted to decimal degrees (ready to use)
Current speed of the resource
Timestamp of the GPS position
Type of resource (e.g., “Patrullero”, “Ambulancia”)
Resource type identifier
Array of active service incidents with location data
Unique service identifier
Reference to the service record
Service creation timestamp
Service location latitude
Service location longitude
Service type (e.g., “Robo”, “Accidente”, “Emergencia Médica”)
Service incident description
Service incident address
Response Example
Coordinate Conversion: GPS coordinates are stored in radians in the database. The API automatically converts them to decimal degrees by dividing by 0.0174533. You can use the
latitud_decimal and longitud_decimal fields directly for mapping.Get Historical Services
Retrieves historical service incidents for heat map and analytics purposes, filtered by date range and incident type.Query Parameters
Start date for the historical query in format
Y-m-d H:i:sEnd date for the historical query in format
Y-m-d H:i:sService type to filter by (e.g., “Robo”, “Hurto”, “Accidente”, “Arrebato”)
Response Example
Implementation Details
Data Source
The CECOCO endpoints connect to a secondary database (mysql_second) that contains the operational data from the emergency coordination center:
- ultimasposicionesgps: Latest GPS positions for all resources
- recursos: Resource master data (vehicles, units)
- tiposrecurso: Resource type classifications
- servicios/servicios_historico: Active and historical service incidents
- posicionamientosmapaservicio: Service location data for map display
Time Window
The/getRecursosCecoco endpoint uses a 100-minute lookback window from the reference timestamp to capture recent resource movements and active services. You can see this implementation in CecocoController.php:85-88:
Development Note: The current implementation uses a hardcoded reference date. In production, you should replace this with
Carbon::now() to get real-time data.Filtering Logic
The resources query excludes invalid GPS positions where coordinates are exactly0.0, 0.0, ensuring only valid location data is returned:
Error Handling
Both endpoints return standardized error responses:- Database connection failures to the CECOCO secondary database
- Invalid coordinate data
- Missing required parameters for historical queries
Use Cases
Real-Time Resource Monitoring
Use/getRecursosCecoco to build live tracking dashboards that display current positions of patrol vehicles, ambulances, and other emergency resources.
Heat Maps
Use/getServiciosCecoco with date ranges to generate crime heat maps and incident density visualizations for operational planning and analysis.