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/clima endpoint accepts GPS coordinates and returns a normalized snapshot of current weather conditions from the nearest AEMET observation station. ClimApp performs a two-step fetch internally: first it queries the AEMET metadata API to locate the closest station and retrieve a secondary data URL, then it fetches the actual observation payload from that URL. The raw AEMET fields are mapped to human-readable keys and enriched with an active alerts array before the response is returned to the caller.

Endpoint

GET /api/clima

Query parameters

lat
string
required
GPS latitude of the user’s location, in decimal degrees (e.g. 40.4168).
lon
string
required
GPS longitude of the user’s location, in decimal degrees (e.g. -3.7038).

Response fields

estacion
string
Name of the nearest AEMET observation station. Mapped from the raw ubi field in the AEMET payload.
fecha
string
Observation timestamp as returned by AEMET. Mapped from the raw fint field (ISO 8601 format).
temperatura
number
Air temperature in degrees Celsius (°C). Mapped from the raw ta field. Defaults to 0 if the field is absent.
humedad
number
Relative humidity as a percentage (%). Mapped from the raw hr field. Defaults to 0 if the field is absent.
viento
number
Wind speed in kilometres per hour (km/h). Mapped from the raw vv field. Defaults to 0 if the field is absent.
presion
number
Atmospheric pressure in hectopascals (hPa). Mapped from the raw pres field. Defaults to 0 if the field is absent.
lluvia
number
Accumulated rainfall in millimetres (mm). Mapped from the raw prec field. Defaults to 0 if the field is absent.
alertas
string[]
List of active alert labels generated by the internal AlertService based on the observation values. Examples: ["NARANJA", "VIENTO_FUERTE"]. Returns an empty array when no thresholds are exceeded.

Example request

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

Example response

{
  "estacion": "MADRID - RETIRO",
  "fecha": "2026-04-29T14:00:00",
  "temperatura": 18.4,
  "humedad": 52.0,
  "viento": 11.0,
  "presion": 1012.3,
  "lluvia": 0.0,
  "alertas": []
}

Error responses

StatusConditionResponse body
400lat or lon query parameter is missing{"error": "Faltan las coordenadas GPS (lat/lon)"}
500AEMET connection fails or an unexpected error occurs during fetch or normalization{"error": "<error message>"}

How the two-step AEMET fetch works

ClimApp uses a two-step fetch for every /api/clima request. First, WeatherAPIService._obtener_datos_crudos() calls the AEMET observations endpoint. AEMET responds with a metadata object containing a datos URL. A second request to that URL retrieves all current station observations as a JSON array. obtener_clima_por_coordenadas() then iterates this array, computes the Haversine distance for each station, and returns the single observation dict for the nearest station. That dict is passed directly to normalizar_datos_aemet(), which maps AEMET field names to the response fields documented above.

Build docs developers (and LLMs) love