This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Good afternoon,
I am trying to set up a query in Power BI to retrieve data from REST API references in this page:
https://opendata.aemet.es/dist/index.html?
and in particular from references included here:
https://opendata.aemet.es/dist/index.html?#/valores-climatologicos
Since I'm trying to work out how to write the REST API I am hoping some kind soul could help me understand what I need to do to set up the query in PBI Power Query.
I have tried with the following:
For
https://opendata.aemet.es/dist/index.html?#!/valores-climatologicos/Climatolog%C3%ADas_diarias_1
I have tried the following code:
= let
Api_Key = "xxxxxxxyyyyyyyzzzzzzzz",
Source = Json.Document(Web.Contents("https://opendata.aemet.es/opendata/api/valores/climatologicos/diarios/datos/fechaini/2020-01-01/fechafin/2020-07-01/todasestaciones",[Headers = [api_key=Api_Key]])),
issues = Source[issues]
in
Source
but I get a "No data fulfills this request message" (status 404). I'm wondering if the date inputs are correct, or what is wrong with the code.
I have also tried:
for here:
The following code:
let
Api_Key = "xxxxxxyyyyyyyzzzzzzzz",
Source = Json.Document(Web.Contents("https://opendata.aemet.es/opendata/api/valores/climatologicos/inventarioestaciones/todasestaciones",
[Headers = [api_key=Api_Key]]))
in
Source
but I get this:
I'm new to REST APIs so I'm pretty lost as to what I need to do. As I say, my idea is to set up a query in Power BI to retrieve the data daily.
Thanks in advance for your time and help.
Best regards!
Proud to be a Super User!
Paul on Linkedin.
Solved! Go to Solution.
You completed the first step, logging in to the API. It replied with 200 (all good) and gave you the download URL. Now you need to extract the data from there. Since this is technically a second source the code will force you to choose privacy settings - I guess you can set them to public or ignore.
And please, for the love of $deity, do not post API keys here !
let
Api_Key = "your key",
Source = Json.Document(Web.Contents("https://opendata.aemet.es/opendata/api/valores/climatologicos/inventarioestaciones/todasestaciones",
[Headers = [api_key=Api_Key]])),
Source2 = Json.Document(Web.Contents(Source[datos], [Headers = [api_key=Api_Key]]),TextEncoding.Windows),
#"Converted to Table" = Table.FromList(Source2, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"latitud", "provincia", "altitud", "indicativo", "nombre", "indsinop", "longitud"}, {"latitud", "provincia", "altitud", "indicativo", "nombre", "indsinop", "longitud"})
in
#"Expanded Column1"
You completed the first step, logging in to the API. It replied with 200 (all good) and gave you the download URL. Now you need to extract the data from there. Since this is technically a second source the code will force you to choose privacy settings - I guess you can set them to public or ignore.
And please, for the love of $deity, do not post API keys here !
let
Api_Key = "your key",
Source = Json.Document(Web.Contents("https://opendata.aemet.es/opendata/api/valores/climatologicos/inventarioestaciones/todasestaciones",
[Headers = [api_key=Api_Key]])),
Source2 = Json.Document(Web.Contents(Source[datos], [Headers = [api_key=Api_Key]]),TextEncoding.Windows),
#"Converted to Table" = Table.FromList(Source2, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"latitud", "provincia", "altitud", "indicativo", "nombre", "indsinop", "longitud"}, {"latitud", "provincia", "altitud", "indicativo", "nombre", "indsinop", "longitud"})
in
#"Expanded Column1"
Thanks! Worked like a charm!
PS: Yes, sorry about the "key" ...(corrected it now)
Proud to be a Super User!
Paul on Linkedin.
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.