SUMMARY [GET/POST]: Get Delivery Summary for a Given Period
End Point
https://otp.ng/api/summary/
Submit OTP summary requests to the end point. All the requests are submitted through HTTPS POST/GET method. Although you can use HTTP protocol, we strongly recommend you to submit all requests to API over HTTPS so the traffic is encrypted and the privacy is ensured.
PULLING OTP SUMMARY PARAMETERS
Parameter | Type | Description |
---|---|---|
apikey | String | The unique string to authenticate request. Generate, validate and manage apikeys API Tokens |
range | String |
The range from which you want to pull summary. Allowed range parameters are (1h,3h,6h,12h,2h). |
OTP Request Format (HTTPS POST Method)
Sample Code to pull OTP summary through HTTPS POST call to the OTP API
<?php
$endpoint = 'https://otp.ng/api/summary?';
$summaryArray = array (
'range'=> '1h', //1h,3h,6h,12h,2h
'apikey' => 'API_KEY_HERE',
);
$params = http_build_query($summaryArray);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch); curl_close($ch);
echo $response; // response code
?>
OTP Request Format (HTTPS GET Method)
Snippet to pull OTP summary through HTTPS GET call to the API
<?php
$range = '1h';//1h,3h,6h,12h,2h
$endpoint = 'https://otp.ng/api/summary/';
$pull_summary = $endpoint.'&apikey='.$apikey.'&range='.$range;
$response = file_get_contents($pull_summary);
echo $response;
?>
OTP Response Format
All response are in the format below:
{json data}
Possible Response Codes
On Success
{
"success":true,
"data":{
"summary":{
"count":{
"sent":5,
"delivered":5,
"pending":0,
"failed":0
},
"percentage":{
"delivered":"100%",
"pending":0,
"failed":0
}
}
},
"comment":"Data loaded successfully"
}
Parameters | Type | Description |
success | Boolean | Sets to true |
data | Object | Contains the summary data |
count | Object | Summary of OTP history in numbers (sent,delivered,pending,failed) |
percentage | Object | Summary of OTP history in percentages (delivered,pending,failed) |
comment | String | The status of the pull request |
On Failure
{
"success": "false",
"comment": "Reason for error",
}
Parameters | Type | Description |
success | Boolean | Sets to false |
comment | String | Description for failure |