Our Basic Multi-Signature addresses by default require two signatures for all withdrawals: yours, and Block.io's. This method provides exponentially higher security for your Wallets and applications than single-signature addresses. This way, you spend coins yourself, without trusting Block.io with your credentials. For private keys for your wallets, visit the Settings page on your dashboard.
If you require a more elaborate configuration to customize your applications' security, inquire about our Distributed Trust framework by going here. This framework allows up to 5 signatures per address. The use cases are endless!
First, you will need your API Keys, which we provide for Bitcoin, Dogecoin, Litecoin, and their Testnets. These API Keys are located in your Wallet. You are required to use an API Key when you interact with Block.io. It tells Block.io which network (e.g., Bitcoin) you wish to perform actions on.
You can download and install the official NodeJS library like so:
$ npm install block_io
If you're using a NodeJS version earlier than 10.0 but later than 5.10.0, please use:
$ npm install block_io@2.0.3
If you're using a NodeJS version earlier than 5.10.0, please use:
$ npm install block_io@1.0.9-5
Easy enough. Before using the library in your code, initialize it like so (block_io@3.0.0 and later):
> const BlockIo = require('block_io');
> const block_io = new BlockIo('YOUR API KEY');
Now you're good to go. Here's an example call:
> block_io.get_new_address({ label: 'shibe1' })
.then(data => console.log(JSON.stringify(data))
.catch(error => console.log("Error:", error.message));
Returns a newly generated address, and its unique(!) label generated by Block.io. You can optionally specify a custom label.
You can also optionally specify the type of address you wish to generate.
Available address types for Bitcoin, and Litecoin are P2SH (default), and WITNESS_V0. Dogecoin is limited to P2SH addresses at this time.
Note that use of Witness v0 addresses will save you significant amounts of network fees, but these addresses are very new, and users' wallets may not recognize them at this time.
block_io.get_new_address();
block_io.get_new_address({ label: 'LABEL' });
block_io.get_new_address({ address_type: 'ADDRESS TYPE' });
Returns the balance of your entire Bitcoin, Litecoin, or Dogecoin account (i.e., the sum of balances of all addresses/users within it) as numbers to 8 decimal points, as strings.
block_io.get_balance();
Returns the (unarchived) addresses, their labels, user ids, and balances on your account. Upto 2500 addresses per page. Page parameter is optional.
block_io.get_my_addresses({ page: PAGE_NUMBER });
Returns the balance of the specified addresses, or labels. Upto 2500 addresses/labels can be specified per request.
Can be used to query balances for external (non-account) addresses. If an external address' balance is returned, its user_id and label fields will be null.
block_io.get_address_balance({ address: 'ADDRESS' });
block_io.get_address_balance({ label: 'LABEL' });
block_io.get_address_balance({ user_id: USER_ID });
Returns the address specified by a label.
block_io.get_address_by_label({ label: 'LABEL' });
Block.io eases your burden of storing information regarding users' addresses, labels, and user IDs. Below, we provide various methods that allow you to make fine-grained withdrawals from your account(s). You can withdraw from any addresses, from specific addresses, from specific user ids, and from specific labels, and you can send the specified amounts to up to 2500 destination addresses, users, or labels in a single API call.
Minimum Amounts You can withdraw at least 2 DOGE, 0.00002 BTC, or 0.0002 LTC.
Block.io Fees Block.io does not charge fees (except on the Viking Plan). You always pay your own network fees, however, which are in addition to the withdrawal amounts specified.
Network Fees The speed with which miners confirm your transaction depends on the network fees you pay, and the network fees you pay depend on the size of your transaction (in bytes). Larger transactions incur higher network fees. You can specify the priority for your transactions using an additional parameter priority={low,medium,high,custom} to adjust the network fee you wish to pay. Block.io will adjust appropriate network fees for priority={low,medium,high} automatically by monitoring the state of the relevant network. You can specify custom network fees using the parameters priority=custom and custom_network_fee=CUSTOM_NETWORK_FEE.
Transaction Batching You can send coins to upto 2500 destination addresses in a single transaction. We recommend using a single transaction to send coins to multiple recipients, wherever possible. This allows you to incur lower network fees overall, improves confirmation times for your transactions, as well as the health of the relevant network and its blockchain.
Ensuring Uniqueness of Withdrawals Client-side human or machine error can lead to multiple executions of the same withdrawal request. If such an error occurs, you will lose money. To ensure the uniqueness of withdrawal requests, you can specify a nonce=value parameter with your withdrawal requests, where value is an alpha-numeric string between 1 and 64 characters long. Withdrawal requests that provide duplicate nonces less than 1 hour apart will be rejected. This is an optional but recommended security measure.
Missing "reference_id" Errors Executing transactions simultaneously may result in two or more transactions that attempt to spend the same coins (inputs). Since an input can only be spent once, you will see a "missing reference_id" error. To avoid this pitfall, your code must make sure all withdrawal requests are performed in a mutually exclusive manner, meaning a transaction must be created and signed before another transaction is attempted.
Withdraws amount of coins from any addresses in your account to up to 2500 destination addresses.
block_io.withdraw({ amounts: 'AMOUNT1,AMOUNT2,...', to_addresses: 'ADDRESS1,ADDRESS2,...' });
Withdraws amount of coins from any addresses in your account to up to 2500 destination addresses. Use custom network fee.
block_io.withdraw({ amounts: 'AMOUNT1,AMOUNT2,...', to_addresses: 'ADDRESS1,ADDRESS2,...', priority: 'custom', custom_network_fee: 'CUSTOM_NETWORK_FEE' });
Withdraws AMOUNT coins from upto 2500 addresses at a time, and deposits it to up to 2500 destination addresses.
block_io.withdraw_from_addresses({ amounts: 'AMOUNT1,AMOUNT2,...', from_addresses: 'ADDRESS1,ADDRESS2,...', to_addresses: 'ADDRESS1,ADDRESS2,...' });
Withdraws AMOUNT coins from upto 2500 labels at a time, and deposits it to upto 2500 destination addresses, or labels.
block_io.withdraw_from_labels({ amounts: 'AMOUNT1,AMOUNT2,...', from_labels: 'LABEL1,LABEL2,...', to_addresses: 'ADDRESS1,ADDRESS2,...' });
block_io.withdraw_from_labels({ amounts: 'AMOUNT1,AMOUNT2,...', from_labels: 'LABEL1,LABEL2,...', to_labels: 'LABEL1,LABEL2,...' });
The amounts=AMOUNT1,AMOUNT2,... and to_addresses=ADDRESS1,ADDRESS2,... parameters specify that destination ADDRESS1 will receive AMOUNT1, ADDRESS2 will receive AMOUNT2, etc. The source addresses (from_addresses=...) will need at least SUM(AMOUNT1,AMOUNT2...)+Network Fees in balances for this withdrawal to succeed.
Estimates the Network Fee you will need to pay when you make a withdrawal request. The Network Fee is required by the Bitcoin/Dogecoin/etc. networks, not Block.io.
When you change withdrawal parameters, the estimated network fees or lower/upper bounds for custom network fee may change as well.
Please use the same parameters as you would with any withdrawal API call; only one example is given below.
block_io.get_network_fee_estimate({ amounts: 'AMOUNT1,AMOUNT2,...', to_addresses: 'ADDRESS1,ADDRESS2,...' });
Archiving of addresses help you control account bloat due to a large number of addresses.
When an address is archived, it is:
Address archival can greatly enhance the operational security of your applications by allowing you to move coins to new addresses without clogging your API call responses.
As of 07/04/2020, addresses that receive coins (other than from your own account's addresses) will be unarchived automatically.
Archives upto 100 addresses in a single API call. Addresses can be specified by their labels.
block_io.archive_addresses({ address: 'ADDRESS' });
block_io.archive_addresses({ label: 'LABEL' });
block_io.archive_addresses({ user_id: USER_ID });
Unarchives upto 100 addresses in a single API call. Addresses can be specified by their labels.
block_io.unarchive_addresses({ address: 'ADDRESS' });
block_io.unarchive_addresses({ label: 'LABEL' });
block_io.unarchive_addresses({ user_id: USER_ID });
Returns your archived addresses, their labels, and user ids on your account. Upto 2500 addresses per page. Page parameter is optional.
block_io.get_my_archived_addresses({ page: PAGE_NUMBER });
Returns the prices from the largest exchanges for Bitcoin, Dogecoin, or Litecoin, specified by the API Key. Specifying the base currency is optional.
block_io.get_current_price();
block_io.get_current_price({ price_base: 'BASE CURRENCY' });
Returns various data for the last 25 transactions spent or received. You can optionally specify a before_tx parameter to get earlier transactions.
You can use this method to query for addresses that are not on your account.
Each result provides a confidence rating that shows the network's belief in the transaction's viability. This is useful if you need to validate transactions quickly (for e.g., in retail store settings) without waiting for confirmations. We recommend waiting for confidence ratings to reach 0.90-0.99 for unconfirmed transactions if you need to validate it. For unconfirmed transactions, you are also provided with the number of nodes (propagated_by_nodes) on the Network that approve of the given unconfirmed transaction (out of 150 sampled nodes).
If a double spend is detected for an unconfirmed transaction, its confidence rating falls to 0.0.
block_io.get_transactions({ type: 'sent' });
block_io.get_transactions({ type: 'received' });
block_io.get_transactions({ type: 'sent', before_tx: 'TXID' });
block_io.get_transactions({ type: 'received', before_tx: 'TXID' });
block_io.get_transactions({ type: 'received', addresses: 'ADDRESS1,ADDRESS2,...' });
block_io.get_transactions({ type: 'received', user_ids: 'USERID1,USERID2,...' });
block_io.get_transactions({ type: 'received', labels: 'LABEL1,LABEL2,...' });
block_io.get_transactions({ type: 'sent', before_tx: 'TXID', addresses: 'ADDRESS1,ADDRESS2,...' });
block_io.get_transactions({ type: 'received', before_tx: 'TXID', addresses: 'ADDRESS1,ADDRESS2,...' });
...
Returns the raw data, including transaction hex, for a given transaction ID.
block_io.get_raw_transaction({ txid: 'TXID' });
Returns whether a single specified address is valid for the network, or not.
block_io.is_valid_address({ address: 'ADDRESS' });
Returns basic information about your account, such as its current Plan, number of addresses created, number of daily API requests used, etc. API Key agnostic.
block_io.get_account_info();