Generate Address

This function generates an unique crypto address to which the customer may send payments. This address works without an expiry date or transaction limit.

Bitcoin animated logo

Contents

You can generate addresses for one-time payments or for periodic payments as a linked address to a user account. For example, if a customer re-uses it to buy the same product again or to top up the account balance with bitcoins.

Request:

JSON Schema description

Use POST string request containing the object in JSON format.

{WalletID} Wallet Identificator Required
{addr-type} Bitcoin address type.
"p2pkh" - It’s the most common script used for locking an output to someone’s public key.
"p2wpkh" - Segwit address has prefix bc1.
"p2sh-p2wpkh" - Segwit comparable address has prefix 3.
Apirone generates "p2sh-p2wpkh" addresses by default.
Optional
Callback URL

Callback is an array of callback URL and user's Data parameters.

{callback:url}
string,
=< 1024 chars

Callback URL
Your server's callback URL to receive data about the payment. This must be a valid URL.

Optional
{callback:data}
array

Data
The associative array is based on key-value pairs. You can use as additional identification or secure a generated bitcoin address.

For example 'secret' = '7j0ap91o99cxj8k9' or 'invoice_id'='1234'

Optional

Request example:
{
    "addr-type": "p2sh-p2wpkh",
    "callback":{                    #Callback and Callback's Data are Optional fields
      "url",
      "data":{
         "invoice_id": 1234,
         "secret": "7j0ap91o99cxj8k9",
         "data3": "text3",
		 ... #any user parameters
      }
   }
}

Success Response Reference:

Success response returns next parameters in JSON format:
{address} The generated bitcoin address to receive a payment from a customer. string, 32 chars
{callback} Your server callback URL to receive data about the payment. string, max. 1024 chars
{type} Type of address. string
Response example:
{
   "wallet": "btc-1aee83487b65b690305201fb4b42a081",
   "address": "1FEGJSLDJJ6oSuJwur3fCD7TtQbYUjBV4z",
   "created": "2020-12-20T12:20:20.193984",
   "type": "p2sh-p2wpkh",
   "callback":{
      "method": "POST",
      "url":"http://example.com/callback",
      "data":{
         "invoice_id":1234,
         "secret":"7j0ap91o99cxj8k9"
      }
   }
}

Error Response

Playground and Code examples:

Wallet ID
Callback URL KeyValue

+

{
   "callback":{
      "url" :  "http://example.com/callback"
   }
}
  
<?php
  $json_data = array (
    "callback" => array(
        'url'=> 'http://example.com/callback',
		'data'=> array (
            'invoice_id'=> "1234",
            'secret'=> "7j0ap91o99cxj8k9"
        )
    )
  );
  
  $wallet = "btc-1aee83487b65b690305201fb4b42a081";
  $api_base = "https://apirone.com/api/v2/wallets/". $wallet ."/addresses";
 
  $curl = curl_init($api_base);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json_data));
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  $http_status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  $response = curl_exec($curl);
  curl_close($curl);
 

  $decoded = json_decode($response, true);
  echo "Please send the payment to the following bitcoin address: " .
  $decoded["address"];
?>
Send request
Response from server: