cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
johnagillespie
Advocate I
Advocate I

Accessing Statuscake data

Sucessfully accessed our data in statuscake https://www.statuscake.com/

 

First created a function that gets the uptime intervals data for each test 

 

let GetTestPeriods = (TestID as text) =>

let
Source = Web.Contents("https://www.statuscake.com/API/Tests/Periods", [Headers=[#"API"="xxxxxxxxxx",#"Username"="xxxxxx"], Query=[#"TestID"=TestID]]),
#"Imported JSON" = Json.Document(Source),
#"Converted to Table" = Table.FromList(#"Imported JSON", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Status", "StatusID", "Start", "End", "Period", "Additional"}, {"Status", "StatusID", "Start", "End", "Period", "Additional"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Column1",{{"Start", type datetime}, {"End", type datetime}})
in
#"Changed Type"
in

GetTestPeriods

 

And then a query that gets a list of all the tests and then iterates through them using the GetData function to get the data from each website.

 

let
Source = Json.Document(Web.Contents("https://www.statuscake.com/API/Tests/", [Headers=[#"API"="xxxxxxxxxx",#"Username"="xxxxx"]])),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"TestID", "Paused", "TestType", "WebsiteName", "ContactGroup", "ContactID", "Public", "Status", "NormalisedResponse", "Uptime"}, {"TestID", "Paused", "TestType", "WebsiteName", "ContactGroup", "ContactID", "Public", "Status", "NormalisedResponse", "Uptime"}),
#"Filtered Removed Paused" = Table.SelectRows(#"Expanded Column1", each ([Paused] = false)),
#"Sorted Rows" = Table.Sort(#"Filtered Removed Paused",{{"Uptime", Order.Ascending}}),
#"Changed Type" = Table.TransformColumnTypes(#"Sorted Rows",{{"TestID", type text}}),
#"Added Interval Data" = Table.AddColumn(#"Changed Type", "Custom", each GetTestPeriods([TestID])),
#"Expanded Interval Data" = Table.ExpandTableColumn(#"Added Interval Data", "Custom", {"Status", "StatusID", "Start", "End", "Period", "Additional"}, {"Status.1", "StatusID", "Start", "End", "Period", "Additional"}),
#"Changed to DateTime" = Table.TransformColumnTypes(#"Expanded Interval Data",{{"Start", type datetime}, {"End", type datetime}}),
#"Added Invterval Column" = Table.AddColumn(#"Changed to DateTime", "Interval", each [End]-[Start])
in
#"Added Invterval Column"

 

1 REPLY 1
nickwilliams999
New Member

Hi,

 

I know it has been some time since you posted this, but would you mind describing exactly how you set this up? 

 

Kind regards

Nick 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors