Overview

Aemet OpenData is Spain's official meteorological agency API providing weather forecasts, observations, and climate data for Spanish territory including the Canary Islands and Balearics. You register for a free API key and use it to request municipal forecasts, historical station data, and severe weather alerts. It is ideal for weather apps targeting Spain or for academic climate research projects.

Beginner Tip

API responses are returned in two steps: the first call gives you a temporary data URL and the second call fetches the actual JSON payload from that URL. Make sure your code follows both steps or you will only receive metadata, not the actual weather data.

Available Data

The kind of data this API exposes, based on its documentation. We could not call the endpoint to confirm the exact field names.

temperature
weather conditions
humidity
wind speed
forecast data

Example Response

Illustrative shape only — we were not able to call this endpoint (it requires credentials or exposes no public sample URL), so the fields below show the kind of data this API returns rather than a recorded response.

JSON Response · Illustrative
{
  "location": "Tokyo",
  "temperature": {
    "current": 22,
    "feels_like": 24,
    "min": 18,
    "max": 26
  },
  "condition": "Partly Cloudy",
  "humidity": 65,
  "wind": {
    "speed": 12,
    "direction": "NE"
  },
  "forecast": [
    {
      "date": "2025-01-16",
      "high": 25,
      "low": 17,
      "condition": "Sunny"
    }
  ]
}

Field Reference

estado HTTP-style status code returned within the Aemet response envelope (200 = OK).
datos URL where the actual data payload can be fetched; always follow this link for real results.
nombre Name of the municipality for which the forecast data applies.
prediccion.dia Array of daily forecast objects each containing temperature, precipitation, and wind data.
temperatura.maxima Maximum temperature forecast for the day in degrees Celsius.
probPrecipitacion Probability of precipitation for each time period of the day, as a percentage.

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://opendata.aemet.es/opendata/api/prediccion/especifica/municipio/diaria/28079";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

401 Unauthorized The api_key header is missing or the key is not yet activated.
Register at https://opendata.aemet.es, confirm your email, then include your key in the api_key header on every request.
Empty data or unexpected URL in response Aemet returns a datos URL in the first response, and beginners often forget to fetch that second URL.
Parse the datos field from the first response and make a second GET request to that URL to retrieve the actual weather data.
404 for a municipality code The municipality code (INE code) is incorrect or not covered by Aemet.
Look up valid Spanish municipality INE codes from the official INE website or the Aemet documentation list.

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth API Key
HTTPS REQUIRED
CORS UNKNOWN
Category Weather
Difficulty Intermediate
Listing details not endpoint-verified

Related Tags

Similar APIs

View All →