Skip to main content
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

Query parameters

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

Response fields

string
Name of the nearest AEMET observation station. Mapped from the raw ubi field in the AEMET payload.
string
Observation timestamp as returned by AEMET. Mapped from the raw fint field (ISO 8601 format).
number
Air temperature in degrees Celsius (°C). Mapped from the raw ta field. Defaults to 0 if the field is absent.
number
Relative humidity as a percentage (%). Mapped from the raw hr field. Defaults to 0 if the field is absent.
number
Wind speed in kilometres per hour (km/h). Mapped from the raw vv field. Defaults to 0 if the field is absent.
number
Atmospheric pressure in hectopascals (hPa). Mapped from the raw pres field. Defaults to 0 if the field is absent.
number
Accumulated rainfall in millimetres (mm). Mapped from the raw prec field. Defaults to 0 if the field is absent.
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

Example response

Error responses

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.