# API: Get coupon details
# getPromoDetailsByCode
Return coupon details by its code
# Required parameters
Parameter | Description |
---|---|
code | Coupon code to find |
# Request
GET /admin/api.php?api_id=API_ID&api_key=API_KEY&call=getPromoDetailsByCode&code=CODE
# PHP Samples
$url = 'http://url_to_hb.com/admin/api.php';
$post = [
'call' => 'getPromoDetailsByCode',
'api_id' => $API_ID,
'api_key' => $API_KEY,
'code' => $CODE,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);
$return = json_decode($data, true);
print_r($return);
include 'class.hbwrapper.php';
HBWrapper::setAPI('http://url_to_hb.com/admin/api.php','API ID','API Key');
$params = [
'code' => $CODE,
];
$return = HBWrapper::singleton()->getPromoDetailsByCode($params);
print_r($return);
/* Use this method to access HostBill api from HostBill modules */
$api = new ApiWrapper();
$params = [
'code' => $CODE,
];
$return = $api->getPromoDetailsByCode($params);
print_r($return);
# Response
{
"success": true,
"coupon": {
"id": "68",
"batch_id": "2",
"active": "1",
"code": "XO-PAFEQTS34ULN",
"status": "Active",
"coupon_type": "cart",
"type": "percent",
"applyto": "price",
"cycle": "once",
"options": "0",
"value": "1.00",
"cycles": {
"Monthly": "Monthly"
},
"products": false,
"categories": {
"42": "42"
},
"upgrades": "all",
"addons": false,
"domains": false,
"forms": false,
"expires": "0000-00-00",
"max_usage": "0",
"num_usage": "0",
"clients": "all",
"client_id": "0",
"notes": "",
"max_client_usage": "0",
"increase_in_days": "0",
"min_cart_amount": "0.00",
"prompt_cart_amount": "0.00",
"lastname": "",
"firstname": ""
},
"call": "getPromoDetailsByCode",
"server_time": 1696493853
}