Forum Discussion
UK Gov Coronavirus Data
- 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
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
- rkw9275 years agoNew Member
Fantastic! I tend to understand a lot better backward-engineering this than starting from the slightly obtuse documentation, this is perfect 🙂 Really helped me a load thanks!