Sendbit API


All API calls are implemented as HTTP Post. Requests must be made to our API endpoint located at https://sendbit.io/api/[METHOD]

An incredibly easy method for websites to receive bitcoin payments, this service is completely free and secure. Perfect for business or personal use.

Our API consists of two methods, which will enable you to accept and send cryptocurrency payments
.



Accept Payments on your website

Download our library - sendbit.inc.php

include_once("sendbit.inc.php");

define("API_KEY", "YOUR_API_KEY");
define("API_SECRET", "YOUR_API_SECRET");

$callback_url = "https://site.com/IPN.php?user=2450";
$api_client = new SendBitApi(API_KEY, API_SECRET);
$api_client->setCoin("BTC"); // set coin (BTC, LTC, BCH, DASH) https://www.sendbit.io/page/coins_accepted
$api_client->setField("callback_url", $callback_url);
$api_client->setMethod("generate-address");
$response = $api_client->process();

if($response["response_code"] != 200) {

exit($response["response_message"]);

} else {

$address = $response["address"];
$qr_code_url = $response["qr_code"];

}

The following details will be sent to your call-back URL upon receiving payments. Payment notifications are sent every minute up until the transaction gets three confirmations.

$address = $_POST["address"];
$amount = $_POST["amount"];
$confirmations = $_POST["confirmations"];
$hash = $_POST["hash"];
$auth_hmac = $_POST["auth_hmac"]; 
To handle call-backs we have made a small useful code to log payments into your database


include_once("sendbit.inc.php"); //libaray

define("API_KEY", "YOUR_API_KEY");
define("API_SECRET", "YOUR_API_SECRET");

$transaction_id = $_POST["transaction_id"];
$address = $_POST["address"];
$amount = $_POST["amount"];
$confirmations = $_POST["confirmations"];
$hash = $_POST["hash"];
$auth_hmac = $_POST["auth_hmac"]; 

$api_client = new SendBitApi(API_KEY, API_SECRET);
$valid = $api_client->validatePayment($hash, $auth_hmac);

if($valid == true) {

// Process the payment.

// We recommend you add a parameter here to check if payment record exists
// so you dont log the same payment each time you get a callback notification.
// callback notifications are sent every minute up until three confirmations.


} else {

exit("Could not verify the payment.");

// Log for manual verification

}

Send Payments via API

Use our API to send payments using your API key and API secret. This can be modified to your needs and is great for mass payments.

include_once("sendbit.inc.php"); //libaray

define("API_KEY", "YOUR_API_KEY");
define("API_SECRET", "YOUR_API_SECRET");
$hash = "$2y$12$SeCkgzINScl2DWSzs2ofYO2604UO6U.kI3mCWfoGYuCpvvbpzp9HG"; //Do not change this hash, or else API becomes invalid.

$address = "1tkh8ENwHr8Uoo6PWFM31T5ub2cQiFGbm";
$amount = 0.00000000; // amount to send (amount in selected coin)
$fee = 0.000055; // total fee for your transaction (amount in selected coin)

$api_client = new SendBitApi(API_KEY, API_SECRET);
$api_client->setCoin("BTC"); // set coin (BTC, LTC, BCH, DASH) https://www.sendbit.io/page/coins_accepted
$api_client->setField("recipient", $address);
$api_client->setField("amount", $amount);
$api_client->setField("fee", $fee);
$api_client->setField("akhami_hash", $hash);
$api_client->setMethod("send-payment");
$response = $api_client->process();

if($response["response_code"] != 200) {

exit($response["response_message"]);

} else {

$transaction_id = $response["transaction_id"]; //Shows TXN

}


Response codes

Response codes

500 - Unknown internal error

401 - Invalid API details

403 - You do not have permissions to access used API

404 - Wrong coin abbreviation used

200 - Success, check other parameters

17 - API limit reached, please upgrade API plan

19 - Invalid callback or success URL used

21 - Amount too small

30 - Fee too small

28 - Amount exceeds your balance


It's easy as that! Thank you for using sendbit.io. If you don't understand something or if you have any questions, you can always email us at support[at]sendbit.io. To upgrade your API plan please click here