Skip to main content

Overview

The Países (Countries) API manages country records used throughout the system for location-based operations.

Model Structure

The Pais model represents countries with basic identification and naming.

Fields

id_pais
integer
required
Primary key. Auto-incremented unique identifier for the country.
nombre
string
required
Country name. Maximum 50 characters.

Endpoints

List Countries

GET /api/paises/
Retrieves all countries in the system.

Response

id_pais
integer
Unique identifier for the country
nombre
string
Name of the country

Example Response

[
  {
    "id_pais": 1,
    "nombre": "Ecuador"
  },
  {
    "id_pais": 2,
    "nombre": "Colombia"
  },
  {
    "id_pais": 3,
    "nombre": "Perú"
  }
]

Get Country

GET /api/paises/{id_pais}/
Retrieves a specific country by ID.

Path Parameters

id_pais
integer
required
The unique identifier of the country to retrieve

Response

id_pais
integer
Unique identifier for the country
nombre
string
Name of the country

Example Response

{
  "id_pais": 1,
  "nombre": "Ecuador"
}

Create Country

POST /api/paises/
Creates a new country.

Request Body

nombre
string
required
Name of the country. Maximum 50 characters.

Example Request

{
  "nombre": "Argentina"
}

Response

id_pais
integer
Unique identifier for the newly created country
nombre
string
Name of the country

Update Country

PUT /api/paises/{id_pais}/
Updates an existing country.

Path Parameters

id_pais
integer
required
The unique identifier of the country to update

Request Body

nombre
string
required
Updated name of the country. Maximum 50 characters.

Example Request

{
  "nombre": "República del Ecuador"
}

Delete Country

DELETE /api/paises/{id_pais}/
Deletes a country from the system.

Path Parameters

id_pais
integer
required
The unique identifier of the country to delete

Response

Returns 204 No Content on successful deletion.

Relationships

The Pais model is referenced by:
  • Ciudad: Cities belong to countries
  • Usuario: Users are associated with countries
  • Empresa: Companies operate in specific countries
  • CampanaPublicitaria: Advertising campaigns target specific countries
  • Chofer: Drivers are registered in specific countries
  • Cliente: Clients are located in specific countries

Usage Notes

  • Countries are foundational data and should be created before cities
  • Deleting a country will cascade delete all related cities and other dependent records
  • The nombre field should use the Spanish name of the country

Build docs developers (and LLMs) love