Overview
The Ciudades (Cities) API manages city records with geographic location data stored as JSON for Google Maps integration.Model Structure
The Ciudad model represents cities with country associations and Google Maps location data.Fields
Primary key. Auto-incremented unique identifier for the city.
Foreign key reference to the Pais (Country) model. Links the city to its country.
City name. Maximum 80 characters.
JSON field containing Google Maps location data. Stores latitude, longitude, and optional place information.Default:
{}Endpoints
List Cities
Query Parameters
Optional. Filter cities by country ID.
Response
Unique identifier for the city
ID of the country this city belongs to
Name of the city
Example Response
Get City
Path Parameters
The unique identifier of the city to retrieve
Response
Unique identifier for the city
ID of the country this city belongs to
Name of the city
Google Maps location data
Example Response
Create City
Request Body
ID of the country this city belongs to
Name of the city. Maximum 80 characters.
Google Maps location data. If not provided, defaults to empty object
{}.Latitude coordinate
Longitude coordinate
Google Maps Place ID (optional)
Formatted address string (optional)
Example Request
Response
Unique identifier for the newly created city
ID of the country
Name of the city
Google Maps location data
Update City
Path Parameters
The unique identifier of the city to update
Request Body
ID of the country this city belongs to
Updated name of the city. Maximum 80 characters.
Example Request
Partial Update City
Path Parameters
The unique identifier of the city to update
Request Body
Any subset of the city fields can be provided.Example Request
Delete City
Path Parameters
The unique identifier of the city to delete
Response
Returns 204 No Content on successful deletion.Google Maps Location Structure
Theubicacion_google_maps field is a flexible JSON field that typically contains:
Basic Structure
Extended Structure
Common Fields
Latitude coordinate (decimal degrees)
Longitude coordinate (decimal degrees)
Google Maps Place ID for precise location identification
Human-readable address string
Recommended zoom level for map display (typically 10-15 for cities)
Relationships
The Ciudad model is referenced by:- Usuario: Users are located in specific cities
- Chofer: Drivers operate in specific cities
- Cliente: Clients are based in specific cities
- Empresa: Companies may be registered in specific cities
- CampanaPublicitaria: Campaigns target specific cities
- Sector: Geographic sectors belong to cities
- TallerBrandeo: Branding workshops are located in cities
- RecorridoRealizado: Routes are tracked within cities
- MovimientoCapital: Financial transactions are city-specific
Usage Notes
- A city must belong to a valid country (Pais)
- The
ubicacion_google_mapsfield is required and should contain at minimumlatandlngcoordinates - Deleting a city will cascade delete all related records
- When integrating with Google Maps, use the
place_idfor precise location lookups - Coordinates should use WGS84 datum (standard for GPS and Google Maps)
- Latitude ranges from -90 to 90, longitude from -180 to 180