Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
PaulDBrown
Community Champion
Community Champion

Using REST Api: help please

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:

https://opendata.aemet.es/dist/index.html?#!/valores-climatologicos/Inventario_de_estaciones_valores...

 

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:

Estaciones API.JPG

 

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!





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

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"

 

 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

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"

 

 

@lbendlin 

 

Thanks! Worked like a charm!

PS: Yes, sorry about the "key" ...(corrected it now)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors