Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/elenacarino-max/mas-climapp/llms.txt

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

The /api/clima endpoint queries the AEMET observation network for the weather station nearest to the supplied coordinates. Raw AEMET data is normalized into a consistent schema — field names are standardized, numeric types are enforced, and trace-precipitation values (ip) are converted to 0.0. Before the response is returned, the alert engine evaluates the record and appends a list of active alert codes. The record is also persisted automatically so it appears in historical queries.

Request

GET /api/clima?lat={lat}&lon={lon}
lat
string
required
Latitude of the target location in decimal degrees. Example: 40.4168 for Madrid.
lon
string
required
Longitude of the target location in decimal degrees. Example: -3.7038 for Madrid.

Example request

curl "http://localhost:5000/api/clima?lat=40.4168&lon=-3.7038"

Response

Success — 200 OK

ciudad
string
Human-readable place name sourced from the AEMET ubi field. Falls back to "Ubicación Detectada" when the field is absent.
estacion
string
AEMET station name. Identical to ciudad in the current normalization schema.
fecha
string
Observation timestamp in ISO 8601 format as returned by AEMET (fint field). Example: "2026-05-07T14:00:00".
temperatura
number
Air temperature in degrees Celsius, sourced from the AEMET ta field.
humedad
number
Relative humidity as a percentage (0–100), sourced from the AEMET hr field.
viento
number
Wind speed in km/h, sourced from the AEMET vv field.
presion
number
Atmospheric pressure in hPa, sourced from the AEMET pres field.
lluvia
number
Precipitation in mm. Trace values (ip) are normalized to 0.0, sourced from the AEMET prec field.
alertas
string[]
List of active alert codes produced by the ClimApp alert engine. Returns ["VERDE"] when no thresholds are exceeded. Possible codes:
CodeCondition
VERDENo active alerts
NARANJA_CALORTemperature ≥ 35 °C
ROJA_CALORTemperature ≥ 40 °C
NARANJA_FRIOTemperature ≤ 0 °C
ROJA_FRIOTemperature ≤ −5 °C
NARANJA_VIENTOWind speed > 40 km/h
ROJA_VIENTOWind speed > 70 km/h
NARANJA_LLUVIAPrecipitation > 10 mm
ROJA_LLUVIAPrecipitation > 30 mm
NARANJA_HUMEDADRelative humidity ≥ 90 %
fuente
string
Data source identifier. Always "aemet" for responses from this endpoint.

Example response

{
  "ciudad": "Madrid - Retiro",
  "estacion": "Madrid - Retiro",
  "fecha": "2026-05-07T14:00:00",
  "temperatura": 22.4,
  "humedad": 45.0,
  "viento": 18.0,
  "presion": 1012.3,
  "lluvia": 0.0,
  "alertas": ["VERDE"],
  "fuente": "aemet"
}

Error responses

400 Bad Request — returned when lat or lon are missing from the query string.
{
  "error": "Faltan coordenadas"
}
500 Internal Server Error — returned when the AEMET connection fails or data cannot be normalized.
{
  "error": "Connection timeout",
  "temperatura": 0,
  "ciudad": "Error de conexión",
  "humedad": 0
}
The 500 response always includes temperatura, ciudad, and humedad keys set to safe defaults so client-side rendering does not break on missing fields.

Build docs developers (and LLMs) love