StatusCake

StatusCake API Quick Guides – Listing tests and detailed settings

statuscake

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.

PHP Example 1 – Get all tests

[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]

PHP Example 2 – Get detailed data on a single test

[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]

Bash Example 1 – Get all tests

[blockquote align=”left” reverse=”off”]

curl -H “API: [APIKey]” -H “Username: [Username]” -X GET https://app.statuscake.com/API/Tests/Details/?TestID=TESTIDHERE[/blockquote]

Bash Example 2 – Get all tests

[blockquote align=”left” reverse=”off”]

curl H “API: [APIKey]” H “Username: [Username]” X GET https://app.statuscake.com/API/Tests/[/blockquote]

Python Example 1 – Get all tests

[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]

Python Example 2 – Get detailed data on a single test

[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]

Postman Example 1 – Get all tests

pmALL

Postman Example 2 – Get detailed data on a single test

PMalltests

Share this

More from StatusCake

DNS
Engineering

What’s new in Chrome Devtools?

3 min read For any web developer, DevTools provides an irreplaceable aid to debugging code in all common browsers. Both Safari and Firefox offer great solutions in terms of developer tools, however in this post I will be talking about the highlights of the most recent features in my personal favourite browser for coding, Chrome DevTools. For something

Engineering

How To Create An Animated 3D Button From Scratch

6 min read There has certainly been a trend recently of using animations to elevate user interfaces and improve user experiences, and the more subtle versions of these are known as micro animations. Micro animations are an understated way of adding a little bit of fun to everyday user interactions such as hovering over a link, or clicking

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

*By providing your email address, you agree to our privacy policy and to receive marketing communications from StatusCake.