Search code examples
pythonpowerbipowerquery

Is there a way to open multiple API links in Power BI at once without the need to do multiple get requests (get data from web)


I have around 10 API links that I want to open in power bi, but I was asked if there is a way to open those links at once instead of having to insert each link on it's own. whether it is with a Python script, M query or whatever works, as long as the method supports data refresh.

I tried creating a parameter and storing my APIs in a list to load them but I kept getting multiple errors.


Solution

  • hereunder a PowerQuery example, you basically pass the code of an individual call to each row of a table. this will give you a "table" in each row of the new col that you can expand:

        let
            GetUrl = (url) => 
            let
                Source = Web.Page(Web.Contents(url)),
                Data0 = Source{0}[Data]
            in
                Data0,
            
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WyigpKSi20tcvLy/XS8qsys4s0EvOz9VXLijKz0pNLlGK1cGtJjEpvxSoIhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [url = _t]),
            #"Added Custom" = Table.AddColumn(Source, "Custom", each GetUrl([url]))
        in
            #"Added Custom"