GET /rest/v2/message-hub/stats
Returns aggregated Message Hub statistics, including total views, total clicks, total opens, and the overall click-through rate (CTR).
Resource Information
Method
GET
URL
https://api.pushalert.co/rest/v2/message-hub/stats
Requires authentication?
Yes
Response Parameters
Parameter
Type
Description
viewed
Integer
Total number of campaign views to date.
opened
Integer
Total number of campaign opens recorded.
clicked
Integer
Total number of clicks generated across all campaigns.
ctr
Double
Overall click-through rate (CTR), calculated from total clicks and opens to date.
Example
cURL
PHP
curl https://api.pushalert.co/rest/v2/message-hub/stats \
-H "Authorization: api_key=<insert api key here>"
<?php
$notfID = 11;
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v2/message-hub/stats";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Views: {$output["views"]}, Clicks: {$output["clicks"]}, Emails: {$output["emails"]} and CTR: {$output["ctr"]}%";
}
else {
//Others like bad request
}
?>
Copy
Output
JSON
{
"success": true,
"viewed": 6433,
"clicked": 1235,
"opened": 382,
"ctr": "19.20%",
}
Copy
GET /rest/v2/message-hub/stats/$CAMPAIGN_ID
Retrieve consolidated statistics for a specific campaign, including total views, total clicks, total message opens, and the overall click-through rate (CTR).
Resource Information
Method
POST
URL
https://api.pushalert.co/rest/v2/message-hub/stats/$CAMPAIGN_ID
Requires authentication?
Yes
Method Parameters
Parameter
Type
Description
$CAMPAIGN_ID
Integer
ID of the campaign.
Response Parameters
Parameter
Type
Description
viewed
Integer
Total number of views recorded for this campaign.
clicked
Integer
Total number of clicks generated from this campaign.
opened
Integer
Total number of times the campaign message was opened.
ctr
Double
Click-through rate (CTR) for this campaign, calculated from total clicks and opens.
Example
cURL
PHP
curl https://api.pushalert.co/rest/v2/message-hub/stats/19 \
-H "Authorization: api_key=<insert api key here>"
<?php
$campaignID = 19;
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v2/message-hub/stats/$campaignID";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Views: {$output["viewed"]}, Clicks: {$output["cliked"]}, Opened: {$output["opened"]} and CTR: {$output["ctr"]}%";
}
else {
//Others like bad request
}
?>
Copy
Output
JSON
{
"success": true,
"views": 843,
"clicks": 181,
"emails": 61,
"ctr": "21.47%",
}
Copy
GET /rest/v2/message-hub/update/$CAMPAIGN_ID
Change a campaign's state to Publish or Unpublish.
Resource Information
Method
POST
URL
https://api.pushalert.co/rest/v2/message-hub/update/$CAMPAIGN_ID
Requires authentication?
Yes
Method Parameters
Parameter
Type
Description
$CAMPAIGN_ID
Integer
ID of the campaign.
Request Parameters
Parameter
Type
Description
status
Integer
Required 1 = Publish, 0 = Unpublish.
Response Parameters
Parameter
Type
Description
success
boolean
true if the status was changed successfully, otherwise false .
Example
cURL
PHP
curl https://api.pushalert.co/rest/v2/message-hub/update/15 \
-H "Authorization: api_key=<insert api key here>" \
-d "status=1"
<?php
$campaign_id = 2024; //Your campaign ID
$new_status = 1;
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v2/message-hub/update/$campaign_id";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array(
"status" => $new_status
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Subscribers added successfully";
}
else {
//Others like bad request
}
?>
Copy
Output
JSON
{
"success": true,
}
Copy