API BlockchainBlockchain Wallet
close
USD
USD
AUD
CAD
CHF
CLP
CNY
DKK
EUR
GBP
HKD
INR
ISK
JPY
KRW
NZD
PLN
RUB
SEK
SGD
THB
TWD

Blockchain Wallet API

Simple API for Blockchain Wallet users to send and receive bitcoin payments.

The Blockchain Wallet API provides a simple interface Merchants can use to programmatically interact with their wallet.

Installation

To use this API, you will need to run small local service which be responsible for managing your Blockchain Wallet. Your application interacts with this service locally via HTTP API calls. Click here for complete setup instructions on GitHub.

Create Wallet API

Create blockchain wallets programmatically

The create_wallet method can be used to create a new blockchain.info bitcoin wallet.
URL:http://localhost:3000/api/v2/create
Method:POST or GET
  • $password - The password for the new wallet. Must be at least 10 characters in length.
  • $api_code - An API code with create wallets permission.
  • $priv - A private key to add to the wallet (Wallet import format preferred). (Optional)
  • $label - A label to set for the first address in the wallet. Alphanumeric only. (Optional)
  • $email - An email to associate with the new wallet i.e. the email address of the user you are creating this wallet on behalf of. (Optional)
Please create an API code here including permissions to "Create Wallets".
Response:200 OK, application/json
{
  "guid": "4b8cd8e9-9480-44cc-b7f2-527e98ee3287",
  "address": "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS",
  "label": "Main address"
}

Making Outgoing Payments

Send bitcoin from your wallet to another bitcoin address. All transactions include a 0.0001 BTC miners fee.
All bitcoin values are in Satoshi i.e. divide by 100000000 to get the amount in BTC. The Base URL for all requests: https://blockchain.info/merchant/$guid/. $guid should be replaced with your Blockchain Wallet identifier (found on the login page).
http://localhost:3000/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount&from=$from&fee=$fee
  • $main_password - Your Main Blockchain Wallet password
  • $second_password - Your second Blockchain Wallet password if double encryption is enabled.
  • $to - Recipient Bitcoin Address.
  • $amount - Amount to send in satoshi.
  • $from - Send from a specific Bitcoin Address (Optional)
  • $fee - Transaction fee value in satoshi (Must be greater than default fee) (Optional)
Response:200 OK, application/json
{
  "message": "Response Message",
  "tx_hash": "Transaction Hash",
  "notice": "Additional Message"
}
{
  "message": "Sent 0.1 BTC to 1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq",
  "tx_hash": "f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c",
  "notice": "Some funds are pending confirmation and cannot be spent yet (Value 0.001 BTC)"
}

Send Many Transactions

Send a transaction to multiple recipients in the same transaction.
http://localhost:3000/merchant/$guid/sendmany?password=$main_password&second_password=$second_password&recipients=$recipients&fee=$fee
  • $main_password - Your Main Blockchain Wallet password
  • $second_password - Your second Blockchain Wallet password if double encryption is enabled.
  • $recipients - Is a JSON Object using Bitcoin Addresses as keys and the amounts to send as values (See below).
  • $from - Send from a specific Bitcoin Address (Optional)
  • $fee - Transaction fee value in satoshi (Must be greater than default fee) (Optional)
Response:200 OK, application/json
{
  "1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh": 100000000,
  "12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT": 1500000000,
  "1dice6YgEVBf88erBFra9BHf6ZMoyvG88": 200000000
}
The above example would send 1 BTC to 1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh, 15 BTC to 12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT and 2 BTC to 1dice6YgEVBf88erBFra9BHf6ZMoyvG88 in the same transaction.
Response:200 OK, application/json
{
  "message": "Response Message",
  "tx_hash": "Transaction Hash"
}
{
  "message": "Sent To Multiple Recipients",
  "tx_hash": "f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c"
}

PHP Example

<?

$guid="GUID_HERE";
$firstpassword="PASSWORD_HERE";
$secondpassword="PASSWORD_HERE";
$amounta = "10000000";
$amountb = "400000";
$addressa = "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq";
$addressb = "1ExD2je6UNxL5oSu6iPUhn9Ta7UrN8bjBy";
$recipients = urlencode('{
"'.$addressa.'": '.$amounta.',
"'.$addressb.'": '.$amountb.'
}');

$json_url = "http://localhost:3000/merchant/$guid/sendmany?password=$firstpassword&second_password=$secondpassword&recipients=$recipients";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$message = $json_feed->message;
$txid = $json_feed->tx_hash;
?>

Fetching the wallet balance

Fetch the balance of a wallet. This should be used as an estimate only and will include unconfirmed transactions and possibly double spends.
http://localhost:3000/merchant/$guid/balance?password=$main_password
Response:200 OK, application/json
{
  "balance": "Wallet Balance in Satoshi"
}
{
  "balance": 1000
}

Listing Addresses

List all active addresses in a wallet. Also includes a 0 confirmation balance which should be used as an estimate only and will include unconfirmed transactions and possibly double spends.
http://localhost:3000/merchant/$guid/list?password=$main_password
Response:200 OK, application/json
{
  "addresses": [
    {
      "balance": 1400938800,
      "address": "1Q1AtvCyKhtveGm3187mgNRh5YcukUWjQC",
      "label": "SMS Deposits",
      "total_received": 5954572400
    },
    {
      "balance": 79434360,
      "address": "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq",
      "label": "My Wallet",
      "total_received": 453300048335
    },
    {
      "balance": 0,
      "address": "17p49XUC2fw4Fn53WjZqYAm4APKqhNPEkY",
      "total_received": 0
    }
  ]
}

Getting the balance of an address

Retrieve the balance of a bitcoin address. Querying the balance of an address by label is depreciated.
http://localhost:3000/merchant/$guid/address_balance?password=$main_password&address=$address
  • $main_password - Your Main Blockchain wallet password
  • $address - The bitcoin address to lookup
Response:200 OK, application/json
{
  "balance": "Balance in Satoshi",
  "address": "Bitcoin Address",
  "total_received": "Total Satoshi Received"
}
{
  "balance": 50000000,
  "address": "19r7jAbPDtfTKQ9VJpvDzFFxCjUJFKesVZ",
  "total_received": 100000000
}

Generating a new address

http://localhost:3000/merchant/$guid/new_address?password=$main_password&second_password=$second_password&label=$label
  • $main_password - Your Main Blockchain wallet password
  • $second_password - Your second Blockchain Wallet password if double encryption is enabled.
  • $label - An optional label to attach to this address. It is recommended this is a human readable string e.g. "Order No : 1234". You May use this as a reference to check balance of an order (documented later)
Response:200 OK, application/json
{
  "address": "The Bitcoin Address Generated",
  "label": "The Address Label"
}
{
  "address": "18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy",
  "label": "Order No : 1234"
}

Address Management

Archiving an address

To improve wallet performance addresses which have not been used recently should be moved to an archived state. They will still be held in the wallet but will no longer be included in the "list" or "list-transactions" calls.
For example if an invoice is generated for a user once that invoice is paid the address should be archived.
Or if a unique bitcoin address is generated for each user, users who have not logged in recently (~30 days) their addresses should be archived.
http://localhost:3000/merchant/$guid/archive_address?password=$main_password&second_password=$second_password&address=$address
Response:200 OK, application/json
{
  "archived": "18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy"
}

Unarchive an address

Unarchive an address. Will also restore consolidated addresses (see below).
http://localhost:3000/merchant/$guid/unarchive_address?password=$main_password&second_password=$second_password&address=$address
  • $main_password - Your Main Blockchain wallet password
  • $label - The bitcoin address to unarchive
Response:200 OK, application/json
{
  "active": "18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy"
}

Lo has pensado, ahora es el momento.

Crea una billetera. Regístrese para el intercambio. Compra Bitcoin en minutos.