StatusCake

StatusCake API Quick Guides – Listing tests and detailed settings

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.get(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

How To

Using Social Media for Affiliate Marketing

7 min read Today, social media uses a wide range of different social networking platforms to help its users with the creation and sharing of ideas, information, personal interests and hobbies by establishing virtual networks. Affiliates can benefit from these groups that use web-based applications to communicate, interact and connect.

man-and-woman-on-website
How To

How to Improve User Experience

4 min read One of the biggest eCommerce questions – how do you improve user experience? Here are all the top tips for a better UX design to help you drive revenue.

woman-astronaut-flying
Product & Updates

How Page Speed Affects SEO

2 min read We all know page speed is crucial but not just for you brand – it affects SEO so hugely that it can make your pages drop in ranking.

short-reads

How to Reduce Bounce Rate

5 min read Learn what bounce rate is and how it is measured, what a good bounce rate looks like, and the actionable steps you can take to improve the bounce rate on your website.

man-on-bike
short-reads

What Causes Website Downtime?

3 min read Website downtime no longer needs to be this big mystery that keeps you up at night. Here are the top causes for website downtime AND how to fix them.

short-reads

Over 40% of Online Advertisements are Too Large and Slow Down Websites

2 min read Large ads have been a major issue with online publishers who have been struggling with how to curtail what many call “fat ads.” The oversized ads have a major impact on the ability of website visitors to see them as they can’t view them if they don’t load properly.