We'll take you through the steps required, so that you can start accepting Crypto in your projects today.


Let us tell you exactly how BlockchainAPI works.
The way it works is like this:
  1. 1.
    The developer creates an address using BlockchainAPI's BTC or ETH endpoint. This will return a unique address for your customers to pay to. (Because it's unique, it means we can track it).
  2. 2.
    When a payment is sent to an address generated by BlockchainAPI, our system will automatically notice the in-coming funds and forward them to the destination address you supplied when creating a unique address through our endpoint.
  3. 3.
    At the stage the payment is forwarded and hits 1 confirmation, data is sent to your callback URL you supplied when generating a unique address.
  4. 4.
    From there, you can dig into the values of the data sent by BlockchainAPI to make sure the payment amount is correct, the destination address is correct, etc.
It's really simple. No long, tiring pieces of code. No registration. Straight to the point.
Within 1 single GET request, you can have customers paying you.
If you'd like to catch the payment information sent back to you, you'll need 1 extra piece of code in your projects... the callback checker.

Generating an address

Like we said above, the first thing to do is generate a unique address for your customers to pay to.
The following code uses CURL to send a GET request to BlockchainAPI's create endpoint.
$secret = "7j0ap91o99cxj8k9";
$my_address = "1LisLsZd3bx8U1NYzpNHqpo8Q6UCXKMJ4z";
$addressType = "bech32"; // bech32 | legacy | p2sh-segwit
$my_callback_url = "" . $secret;
$api_base = "";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $api_base . "?method=create&address_type=".$addressType."address=" . $my_address . "&callback=" . $my_callback_url
$response = curl_exec($curl);
$http_status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($http_status_code == 200) {
$decoded = json_decode($response, true);
echo "Please send the payment to the following Bitcoin address: " . $decoded["success"]["input_address"];
echo "The current estimated fee is: ".$decoded["success"]["estimated_transaction_fee"].' BTC';
} else {
echo "Sorry, an error occurred: " . $response["error"];
Use the below image to help you understand which parameters are required and which are optional.
We can see that the only 2 required parameters are address and callback... the rest have default values in place for if no values are entered.
Running the above code, returned this to us in json.
We can see that we have a value called input_address.
The input_address is the unique address that was generated by BlockchainAPI's system.
The destination_address is the address we supplied in the code above under address. It's the address that payments will be forwarded to once they've been received by BlockchainAPI.
From this point, you can fully accept Crypto into your applications.
If however, you would like to get notified about the payments sent to your unique address, you'll need some additional code... not much but a little bit more. (See the section below).
"success": {
"fee_percent": 1,
"destination": "3EfVLg7GiUcrW9PMMB7ktqL5yTk4VFjBda",
"input_address": "3JCUUPmbGeg2tJtYV77JJjhc8VLn3VnAgp",
"callback_url": "",
"estimated_transaction_fee": "0.00001000",
"miners_fee": "0.00002200",
"tor": "false",
"setting": "catch_instant"

Checking Callbacks

So with the above code, you'll be able to fully accept Crypto into your projects... however, you will not be able to check the payment details such as the amount sent, the address sent to, the fees sent etc.
This is where the callback checker comes into play.
When BlockchainAPI forwards a payment, it sends data along with it, to the callback URL supplied when creating the unique address in step 1.
Let's check an example of the data that is sent to us from BlockchainAPI.
Everything in the left column are POST values that're sent to your callback URL when a payment is forwarded to you. It is up to you if you wish to use all of these values but they're there for reasons such as confirming the amount sent or confirming the destination address matches yours.
You'll need to make a callback file and place something like the following inside it:
// Payment Settings
$my_address = "1LisLsZd3bx8U1NYzpNHqpo8Q6UCXKMJ4z";
$desiredConfirmations = 3;
// If you're using a secret, put it in here
$secret = "7j0ap91o99cxj8k9";
// Start of checks
if(!isset($_GET['secret'])) {
die('No secret found.');
if ($_GET["secret"] !== $secret) die();
// Make sure we have all the POST variables we want to get
if(!isset($_POST['input_address']) || !isset($_POST['input_transaction_hash']) || !isset($_POST['transaction_hash']) || !isset($_POST['value']) || !isset($_POST['confirmations']) || !isset($_POST['destination_address'])) {
die('One of more of the POST variables was not set in the request to our callback url.');
if ($_POST["destination_address"] !== $my_address) die();
// Now we can show them the 200 status code as they've passed our checks
$input_address = $_POST["input_address"];
$input_transaction_hash = $_POST["input_transaction_hash"];
$transaction_hash = $_POST["transaction_hash"];
$value_in_btc = $_POST["value"];
$confirmations = $_POST["confirmations"];
// Confirmation check to make sure the confirmations is above our desired amount
if($confirmations >= $desiredConfirmations) {
// We should store the payment as soon as we receive it inside this callback file
// We can later update details such as confirms if needed
// {{ Do your magic here }}
} else {
// Transaction has not reached our desired number of confirmations.
// Keep waiting for confirmations to be larger
Checking the code, we can see that we define my_address and secret so we can make sure the values here match the values we set when creating a unique address in step 1.
Let's call it some sort of security measure.
Looking further down the code, we can see that we parse a 200 http response code after our checks. We can tell the server "Yeah good mate, all checks passed!".
In the final step of the code, we can see that we check the confirmations value.
With Bitcoin, payments are not Completed until they've reached 6 confirmations.
BlockchainAPI gives you the ability to set this to whatever you want... we'll post the confirmations integer for you to check whatever you like.

It's that easy. 1....2..... done!