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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.