Forum Discussion

wkeicher's avatar
wkeicher
Icon for Helper III rankHelper III
6 years ago

How to Get Data From Web API using list of parameters

I am new to getting datat from an API. There are a few challenges I am facing.

1) I can get the data using specific paramaters, but want to use a reference table to call the API for each parameter such as date. 

2) I am trying to get multiple dates and associated records into one table - Dont want to do this manually. Is there a function that can use a table as a list to replace the value and add each API call as a record in teh same table

 

 

let
Source = Json.Document(Web.Contents("https://api.sportsdata.io/v3/nba/projections/json/DfsSlatesByDate/2020-MAR-08?key=###MYKEY###")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"SlateID", "Operator", "OperatorSlateID", "OperatorName", "OperatorDay", "OperatorStartTime", "NumberOfGames", "IsMultiDaySlate", "RemovedByOperator", "OperatorGameType", "SalaryCap", "SlateRosterSlots", "DfsSlateGames", "DfsSlatePlayers"}, {"Column1.SlateID", "Column1.Operator", "Column1.OperatorSlateID", "Column1.OperatorName", "Column1.OperatorDay", "Column1.OperatorStartTime", "Column1.NumberOfGames", "Column1.IsMultiDaySlate", "Column1.RemovedByOperator", "Column1.OperatorGameType", "Column1.SalaryCap", "Column1.SlateRosterSlots", "Column1.DfsSlateGames", "Column1.DfsSlatePlayers"})
in
#"Expanded Column1"

 

My Second Challenge is calling the API when there are two variables such as date and ID, Even when I do this for one manual API call the data table needs to be pivoted so the field names are columns.

1)Need to dynamically pass dates and ID's into the API Call basedon an existing tables as the list of values for each

2)Need to pivot the results as columns

let
Source = Json.Document(Web.Contents("https://api.sportsdata.io/v3/nba/projections/json/PlayerGameProjectionStatsByPlayer/2020-MAR-08/20000877?key=###MYKEY###"))
in
Source