WalletBit/API

From BitcoinWiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

WalletBit/API

Four APIs are currently available:

Send to Email or Bitcoin address[edit]

$fields = array(
  'merchant' => 'owner@example.com',
  'customer_email' => 'johnsmith@example.com',
  'address' => '',
  'amount' => 0.01000000,
  'details' => 'You got Bitcoins!'
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['customer_email'] . ':' . $fields['amount'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);
curl_close($ch);

if ($response == '1')
{

}

If 'customer_email' is not on WalletBit, it will try to send to the defined bitcoin address.


Send to Email or Mobile number (SMS)[edit]

$fields = array(
  'merchant' => 'owner@example.com', // Requires a valid WalletBit account with API key.
  'to' => '4550142790',	// Email or Mobile number
  'from' => '4591614856', // Email, Name or Phone number
  'details' => 'You got Bitcoins!' // Message to recipient
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['to'] . ':' . $fields['from'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api/sendto');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = json_decode(curl_exec($ch));
curl_close($ch);

if (is_object($response))
{
    // everythings good
    if ($response->status == 1)
    {
        // any bitcoin sent to this address will be forwarded
        print $response->address;
    }
    else
    {
        // print error message
        print $response->message;
    }
}

Send Bitcoin Methods[edit]

Parameters:
Merchant - WalletBit email
To * - The recipient's email address or mobile phone number (712 mobile networks in 212 countries)
From - The sender's name, phone number or email address
Details - Optional details to include. (22 characters message limit on phone messages)

  • Numbers MUST be in their international format, (no leading zeroes). The UK number 0870 711 111 will become 44870711111

Return:
Status - Indicating if the transaction was successful by a one or zero.
Message - Response from sendTo containing possible errors or similar.
Address - A Bitcoin address. Send bitcoins to it, and it will be forwarded immediately.

When bitcoin is sent to the generated bitcoin address, the system will send out IPN to the defined url in your account.

Our sendTo system covers 712 mobile networks in 212 countries — we can reach almost all mobile phones, however please test if we can reach your mobile or the mobile you want to send to, prior to utilize sending bitcoin via SMS. If the mobile is not covered, you can still enjoy sending instant to email addresses with WalletBit.


Generate new Bitcoin address[edit]

$fields = array(
  'merchant' => 'owner@example.com',
  'label' => 'TEST'
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['label'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api/getnewaddress');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);
curl_close($ch);

If successful $response will contain your new bitcoin address, otherwise empty.


Lookup deposit to Bitcoin address[edit]

$fields = array(
  'merchant' => 'owner@example.com',
  'address' => '1BPeF1tGHQj1tHoyZkFps1QKCbnqdx2yHE'
);
$fields['encrypted'] = strtoupper(hash('sha256', $fields['merchant'] . ':' . $fields['address'] . ':' . 'API Key'));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://walletbit.com/api/lookup/deposit');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$response = curl_exec($ch);
curl_close($ch);

If successful $response returns a json encoded array containing batch number, amount, fee, confirmations, txid, address and timestamp of deposit to the provided Bitcoin address, otherwise empty.

Source[edit]

http://bitcoin.it/

See Also on BitcoinWiki[edit]