Introduction
The C.A.R. 911 API is built on Laravel 8.x and provides a RESTful interface for managing police resources, equipment, cameras, vehicles, and operational data. The API follows Laravel conventions and uses JSON for request and response payloads.Architecture
The API is structured around Laravel’s resource-based routing and follows MVC (Model-View-Controller) architecture:- Routes: Defined in
routes/api.phpfor API endpoints androutes/web.phpfor web-based endpoints - Controllers: Handle business logic and request processing
- Models: Eloquent ORM models for database interaction
- Middleware: Authentication, authorization, and request validation
Authentication Layer
The application uses Laravel Sanctum for API token authentication, enabling both SPA authentication and simple token-based API access.Laravel Sanctum is configured in
config/sanctum.php and provides lightweight authentication for SPAs and mobile applications.Base URL
Configure your base URL in the.env file:
API Prefix
API routes are automatically prefixed with/api by Laravel’s RouteServiceProvider. All API endpoints should be accessed through this prefix.
Response Formats
Success Response
Successful API responses typically return JSON with the requested data:Error Response
Error responses include appropriate HTTP status codes and error messages:Validation Error Response
Validation errors return a 422 status code with detailed field errors:HTTP Status Codes
The API uses standard HTTP status codes to indicate success or failure:| Status Code | Description |
|---|---|
200 | OK - Request succeeded |
201 | Created - Resource created successfully |
204 | No Content - Request succeeded with no response body |
400 | Bad Request - Invalid request format |
401 | Unauthorized - Authentication required |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Resource not found |
422 | Unprocessable Entity - Validation failed |
500 | Internal Server Error - Server error |
Content Type
All API requests should include the following headers:Rate Limiting
API routes are protected by Laravel’s default rate limiting middleware, which limits requests to prevent abuse. The default configuration allows:- 60 requests per minute for authenticated users
- Throttle limits can be customized in
app/Http/Kernel.php
429 Too Many Requests response:
Available Resources
The C.A.R. 911 API provides access to the following resource categories:Core Resources
- Users & Authentication - User management and authentication
- Roles & Permissions - Role-based access control using Spatie
- Equipment (Equipos) - Equipment tracking and management
- Vehicles (Vehiculos) - Vehicle fleet management
- Dependencies (Dependencias) - Organizational structure management
Operational Resources
- Cameras (Camaras) - Surveillance camera management
- Bodycams - Body camera inventory and assignments
- Tasks (Tareas) - Task management system
- Resources (Recursos) - General resource allocation
Specialized Systems
- CECOCO Integration - Real-time mobile and call tracking
- Audio Transcription - Audio file transcription services
- Password Vault - Secure credential management
- Building Plans (Plano Edificio) - Device positioning and management
- Patrimony (Patrimonio) - Asset management system
Detailed documentation for each resource endpoint will be provided in separate sections.
Data Formats
Dates and Timestamps
All timestamps follow ISO 8601 format:Pagination
For list endpoints, Laravel provides built-in pagination:CORS Configuration
The API usesfruitcake/laravel-cors package for Cross-Origin Resource Sharing (CORS) support, allowing frontend applications to communicate with the API from different domains.