Want to know how much website downtime costs, and the impact it can have on your business?
Find out everything you need to know in our new uptime monitoring whitepaper 2021
In this post, we’ll take you through how to list tests from your account, and their detailed settings through the API. There are two functions involved here, first is the function that lists ALL tests on the account with important settings, and second is a more detailed call for a single test. As usual, we’ll take you through this process for both of these using PHP, bash, Python, and Postman.
[blockquote align=”left” reverse=”off”]
<?php
// Auth the request
$API = “l6OxVJilcD2cETMoNRvn”;
$Username = “StatusCake”;
// Create the CURL
$ch = curl_init(“https://app.statuscake.com/API/Tests/”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
“API: “.$API,
“Username: “.$Username
));
// For Debugging
$Response = curl_exec($ch);
$Response = json_decode($Response);
// Check for success
if (!empty($Response->Success) && $Response->Success == 1) {
echo ‘Here’s the detailed data!’;
echo $Response;
echo ‘Here’s the data!’;
echo $Response;
} else {
echo ‘Something Went Wrong Grabbing the Data<BR>’;
echo $Response->Message;
}
?> [/blockquote]
[blockquote align=”left” reverse=”off”]
<?php
// Auth the request
$API = “l6OxVJilcD2cETMoNRvn”;
$Username = “StatusCake”;
$TestID = TESTIDHERE;
// Create the CURL
$ch = curl_init(“https://app.statuscake.com/API/Tests/Details/?TestID=” . $TestID);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
“API: “.$API,
“Username: “.$Username
));
// For Debugging
$Response = curl_exec($ch);
$Response = json_decode($Response);
// Check for success
if (!empty($Response->Success) && $Response->Success == 1) {
echo ‘Here’s the detailed data!’;
echo $Response;
} else {
echo ‘Something Went Wrong Grabbing the details<BR>’;
echo $Response->Message;
}
?>
[/blockquote]
[blockquote align=”left” reverse=”off”]
curl -H “API: [APIKey]” -H “Username: [Username]” -X GET https://app.statuscake.com/API/Tests/Details/?TestID=TESTIDHERE[/blockquote]
[blockquote align=”left” reverse=”off”]
curl –H “API: [APIKey]” –H “Username: [Username]” –X GET https://app.statuscake.com/API/Tests/[/blockquote]
[blockquote align=”left” reverse=”off”]
# -*- coding: utf-8 -*-
import requests
headers = {‘API’: ‘APIKEYHERE’,’Username’: ‘USERNAMEHERE’}
url = ‘https://app.statuscake.com/API/Tests/’
r = requests(url, headers=headers)
print(r.text)[/blockquote]
[blockquote align=”left” reverse=”off”]
# -*- coding: utf-8 -*-
import requests
headers = {‘API’: ‘APIKEYHERE’,’Username’: ‘USERNAMEHERE’}
url = ‘https://app.statuscake.com/API/Tests/Details/?TestID=TESTIDHERE’
r = requests.get(url, headers=headers)
print(r.text) [/blockquote]
Share this
2 min read Read about the latest websites that have experienced downtime including Netflix, Twitter, Facebook and more inside!
2 min read Read about how Google suffered an outage due to the soaring temperatures in the UK in July and how they rectified it right here!
3 min read See the results of our website downtime survey to see some of the most shocking and surprising stats! You won’t be disappointed.
6 min read Find out everything you need to know about Dark Mode and what you can do, as a developer, to make it easier to use.
4 min read Want to know how you can pass Core Web Vitals with the do’s and don’ts of front end development? Find out everything you need to know here!
3 min read Want to know how to get your customers using your SaaS product to ensure they don’t churn? Here’s all our top tips to help you out!
Find out everything you need to know in our new uptime monitoring whitepaper 2021