Forum Discussion

rkw927's avatar
rkw927
New Member
5 years ago
Solved

UK Gov Coronavirus Data

 Trying to use the UK govs official data source https://coronavirus.data.gov.uk/developers-guide   An idea where to start on this? I am admittedly extremely basic on APIs, I've followed some guide...
  • PhilipTreacy's avatar
    5 years ago

    Hi rkw927 ,

     

    The first thing you need to do is read the API documentation to understand what data it provides, then decide what data you want.

     

    Getting the data requires constructing a URL and sending that to the website.  As an example,this URL will return data about cases and deaths since the start of 2020

     

     

    https://api.coronavirus.data.gov.uk/v1/data?filters=areaType=nation;areaName=england&structure={"date":"date","areaName":"areaName","areaCode":"areaCode","newCasesByPublishDate":"newCasesByPublishDate","cumCasesByPublishDate":"cumCasesByPublishDate","newDeathsByDeathDate":"newDeathsByDeathDate","cumDeathsByDeathDate":"cumDeathsByDeathDate"}

     

     

    The following query will retrieve this data and put it into a table

     

     

     

    let
        Source = Json.Document(Web.Contents("https://api.coronavirus.data.gov.uk/v1/data?filters=areaType=nation;areaName=england&structure={""date"":""date"",""areaName"":""areaName"",""areaCode"":""areaCode"",""newCasesByPublishDate"":""newCasesByPublishDate"",""cumCasesByPublishDate"":""cumCasesByPublishDate"",""newDeathsByDeathDate"":""newDeathsByDeathDate"",""cumDeathsByDeathDate"":""cumDeathsByDeathDate""}")),
        data = Source[data],
        #"Converted to Table" = Table.FromList(data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"date", "areaName", "areaCode", "newCasesByPublishDate", "cumCasesByPublishDate", "newDeathsByDeathDate", "cumDeathsByDeathDate"}, {"date", "areaName", "areaCode", "newCasesByPublishDate", "cumCasesByPublishDate", "newDeathsByDeathDate", "cumDeathsByDeathDate"})
    in
        #"Expanded Column1"

     

     

     

     

    Create a new blank query and copy/paste the above query.

     

    Phil