Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/adrianaarang/climapp/llms.txt

Use this file to discover all available pages before exploring further.

The /api/registrar endpoint accepts a JSON body containing a manually entered climate observation and persists it to the local data/registros_climaticos.json file. This allows users to log their own measurements independently of the live AEMET feed. If the municipio field is omitted or sent as "null", ClimApp automatically resolves the municipality name from the internal station lookup table using the provided estacion_id. Every record saved through this endpoint is tagged with "fuente": "manual" so it can be distinguished from AEMET-sourced data when filtering.

Endpoint

POST /api/registrar
Content-Type: application/json

Request body

estacion_id
string
required
AEMET station identifier for the measurement location (e.g. "3195" for Madrid-Retiro).
municipio
string
Municipality name associated with the station. If omitted or set to "null", ClimApp resolves the name automatically from the station lookup table using estacion_id.
fecha
string
required
Date of the observation in DD/MM/YYYY format (e.g. "29/04/2026"). See the date format warning below.
temperatura
number
required
Air temperature in degrees Celsius (°C). Accepted range: -50 to 60.
humedad
number
required
Relative humidity as a percentage (%). Accepted range: 0 to 100.
viento
number
required
Wind speed in kilometres per hour (km/h). Must be ≥ 0.
lluvia
number
required
Accumulated rainfall in millimetres (mm). Must be ≥ 0.

Example request

curl -X POST http://localhost:5000/api/registrar \
  -H "Content-Type: application/json" \
  -d '{"estacion_id": "3195", "municipio": "Madrid", "fecha": "29/04/2026", "temperatura": 22.5, "humedad": 45, "viento": 15, "lluvia": 0}'

Success response

On success the endpoint returns HTTP 201 with the saved record echoed back in the data field.
{
  "status": "success",
  "message": "✔ Registro guardado correctamente",
  "data": {
    "estacion_id": "3195",
    "fecha": "29/04/2026",
    "temperatura": 22.5,
    "humedad": 45.0,
    "viento": 15.0,
    "lluvia": 0.0,
    "municipio": "Madrid",
    "fuente": "manual"
  }
}

Error responses

StatusConditionResponse body
400Request body is empty or Content-Type is not JSON{"error": "No se recibió el paquete de datos"}
400Validation fails (e.g. wrong date format, out-of-range values){"status": "error", "message": "❌ Datos no válidos. Asegúrate de usar el formato de fecha correcto."}
500An error occurs while writing to the JSON storage file{"error": "Error al escribir en el JSON"}

Stored record fields

Each record written to data/registros_climaticos.json contains the following fields:
estacion_id
string
AEMET station identifier provided in the request.
fecha
string
Observation date in DD/MM/YYYY format, exactly as supplied in the request.
temperatura
number
Temperature in °C, cast to float.
humedad
number
Relative humidity %, cast to float.
viento
number
Wind speed in km/h, cast to float.
lluvia
number
Rainfall in mm, cast to float.
municipio
string
Municipality name, either provided in the request or resolved automatically from the station lookup table.
fuente
string
Always "manual" for records saved through this endpoint. Used by the filter and comparison features to distinguish manual entries from AEMET data.

Date format

The fecha field must use DD/MM/YYYY format. Sending an ISO 8601 date such as "2026-04-29" will fail validation and return a 400 error. The front-end JavaScript layer is responsible for converting the HTML date input (YYYY-MM-DD) to DD/MM/YYYY before posting to this endpoint.

Build docs developers (and LLMs) love