CORALINA API Documentation

API REST para el manejo de datos de pozos y piezómetros de CORALINA

Version: 1.0.0

Overview

This API provides access to water resource management data for CORALINA (Corporación para el Desarrollo Sostenible del Archipiélago de San Andrés, Providencia y Santa Catalina). It allows you to retrieve, create, update, and delete information about water wells (pozos), piezometers, and calculate water usage fees (TUA).

Base URL

http://mrd2.co/Coralina-Back-End/services/

1. Pozos (Wells) Endpoints

GET /pozos/get.php

Retrieves a list of all wells in the system.

Example Request:

http://mrd2.co/Coralina-Back-End/services/pozos/get.php

GET /pozos/getById.php?id={id}

Retrieves details of a specific well by its internal ID.

Parameters:

  • id (integer) - The internal ID of the well

Example Request:

http://mrd2.co/Coralina-Back-End/services/pozos/getById.php?id=1

GET /pozos/getByIdPozo.php?id_pcozo={id_pcozo}

Retrieves details of a specific well by its PCOZO ID.

Parameters:

  • id_pcozo (string) - The PCOZO ID of the well

Example Request:

http://mrd2.co/Coralina-Back-End/services/pozos/getByIdPozo.php?id_pcozo=PC3

POST /pozos/create.php

Creates a new well record.

Request Body (JSON):

{
    "id_pcozo": "PC123",
    "tipo_pozo": 1,
    "cota": 19.790,
    "latitud": 12.570280,
    "longitud": -81.709290,
    "responsable": "Juan Antonio González",
    "fm_acuifera": "Fm San Luis",
    "cmp": 2.5,
    "rb": 24.0,
    "observaciones": "Nuevo pozo de prueba"
}

PUT /pozos/update.php?id={id}

Updates an existing well record.

Parameters:

  • id (integer) - The internal ID of the well to update

Request Body (JSON):

Same as create.php

DELETE /pozos/delete.php?id={id}

Deletes a well record.

Parameters:

  • id (integer) - The internal ID of the well to delete

GET /pozos/getHistorico.php

Retrieves historical data for all wells.

GET /pozos/getLastTwoHistoric.php?id_pozo={id_pozo}

Retrieves the last two historical records for a specific well by internal ID.

Parameters:

  • id_pozo (integer) - The internal ID of the well

GET /pozos/getLastTwoHistoricByIdPozoCoralina.php?id_pcozo={id_pcozo}

Retrieves the last two historical records for a specific well by PCOZO ID.

Parameters:

  • id_pcozo (string) - The PCOZO ID of the well

2. Piezómetros (Piezometers) Endpoints

GET /piezometros/get.php

Retrieves a list of all piezometers in the system.

GET /piezometros/getHistorico.php

Retrieves historical data for all piezometers.

PUT /piezometros/update.php?id={id}

Updates an existing piezometer record by internal ID.

Parameters:

  • id (integer) - The internal ID of the piezometer

Request Body (JSON):

{
    "nombre_comun": "Piezometro Test",
    "red": "Red Principal",
    "cota": 123.45,
    "alto_pto_toma": 45.67,
    "profundidad": 89.12,
    "tipo_fuente": "Tipo A",
    "x_utm": 123456.78,
    "y_utm": 987654.32,
    "x_local": 234.56,
    "y_local": 789.01
}

PUT /piezometros/updateByIdPiezometro.php?id_piezometro={id_piezometro}

Updates an existing piezometer record by piezometer ID.

Parameters:

  • id_piezometro (string) - The ID of the piezometer

Request Body (JSON):

Same as update.php

3. TUA (Tasa por Uso de Agua) Endpoints

GET /TUA/getTUA.php

Calculates the water usage fee based on provided parameters.

Parameters:

  • tmLastYear (float) - Tasa mínima del año anterior
  • ipc (float) - Índice de precios al consumidor
  • cpmLastYear (float) - Costo del programa de monitoreo del año anterior
  • nbi (float) - Necesidades básicas insatisfechas
  • cu1 (float) - Coeficiente de uso 1
  • cu2 (float) - Coeficiente de uso 2

Example Request:

http://mrd2.co/Coralina-Back-End/services/TUA/getTUA.php?tmLastYear=1.5&ipc=0.05&cpmLastYear=1000&nbi=25&cu1=0.8&cu2=0.5

GET /TUA/getMADS.php?vigencia={year}

Retrieves the MADS (Ministerio de Ambiente y Desarrollo Sostenible) report for a specific year.

Parameters:

  • vigencia (integer) - The year for which to generate the report

How to Use This API

Making Requests

You can make requests to this API using any HTTP client, such as:

Example: Retrieving All Wells

To retrieve all wells, make a GET request to:

http://mrd2.co/Coralina-Back-End/services/pozos/get.php

Example: Creating a New Well

To create a new well, make a POST request to:

http://mrd2.co/Coralina-Back-End/services/pozos/create.php

With a JSON body containing the well data (see the endpoint documentation above).

Response Format

All API responses are in JSON format with the following structure:

{
    "status": "success" or "error",
    "data": [...] or {...},  // Present when status is "success"
    "message": "Error message"  // Present when status is "error"
}

Error Handling

When an error occurs, the API will return a JSON response with status "error" and a message describing the error.

{
    "status": "error",
    "message": "Description of the error"
}

Common error scenarios include: