API Documentation
BTC.COM API V3
Your applications can access the data of Bitcoin network via the API provided by BTC.COM.
- Telegram: https://t.me/btccomchinese
- Twitter: https://twitter.com/btccom_official
- Discord: https://discord.com/invite/R8HzUvg2eR
- Mail: [email protected]
General
Some API calls can handle multiple parameters. For instance, if you request information about a couple of blocks, you can send one API call for all of them. Parameter delimiter is a comman(,).
So instead of doing there separate API calls:
GET /block/1
GET /block/2
GET /block/3
Response
All the response types are application/json
, as follows:
{
"data": ...,
"err_no": 0,
"err_msg": null
}
data
,API Response dataerror_no
Error Number- 0 OK
- 1 Resource Not Found
- 2 Parameter Error
error_msg
Error Message
Response Types
Block
Block {
height: int
version: int
mrkl_root: string
curr_max_timestamp: int
timestamp: int
bits: int
nonce: int
hash: string
prev_block_hash: string, null if not exists
next_block_hash: string, null if not exists
size: int
pool_difficulty: int
difficulty: int
tx_count: int
reward_block: int
reward_fees: int
created_at: int
confirmations: int
extras: {
relayed_by: string
}
}
Due to the timestamp
recorded in blocks is not increasing strictly with height, we added curr_max_timestamp
field for the max timestamp of blocks, which ensures that the timestamp is not less than the previous block timestamp when the blocks are generated. Some API will use the field to record the date, such as the API accessing block lists by date.
Transaction
Transaction {
block_height: int
block_time: int
created_at: int
fee: int
hash: string
inputs: [
{
"prev_addresses": Array<String>
"prev_position": int
"prev_tx_hash": string
"prev_value": int
"script_asm": string
"script_hex": string
"sequence": int
},
],
inputs_count: int
inputs_value: int
is_coinbase: boolean
lock_time: int
outputs: [
{
addresses: Array<String>
value: int
}
],
outputs_count: int
outputs_value: int
size: int
version: int
}
Since the size of some transactions is large, the API related to the transactions supports the rating output of transaction info, such as https://chain.api.btc.com/v3/block/latest/tx?verbose=2
.
The verbose
is optional and its 2 defaultly. The different output level has its own meaning:
Level 1: including transaction info
Level 2: including level 1, input, output and balance
Level 3: including level 2, input, output script and etc.
Address
{
address: string
received: int
sent: int
balance: int
tx_count: int
unconfirmed_tx_count: int
unconfirmed_received: int
unconfirmed_sent: int
unspent_tx_count: int
}
Unspent
{
tx_hash: string
tx_output_n: int
tx_output_n2: int
value: int
confirmations: int
}
API
Block
Block Info
GET /block/{xxx}
xxx
can be:
- Block height
- Block hash
- String
latest
Examples
Get the 3rd block
Get the latest block
Get the latest and 3rd Block
Block List
Get block list by date.
GET /block/date/{ymd}
Examples
Get block list on 12/15/2015
Block Transactions
Batch request is not supported now.
GET /block/{xxx}/tx
Parameters:
page
, optional, default to1
pagesize
,optional, default to50
, min1
, max50
Examples
Get transactions of Latest block
Get transaction of single block
Transaction
Transaction Info
GET /tx/{txhash}
Examples
Get Single Transaction
Unconfirmed Tranasction Hash
GET /tx/unconfirmed
Examples
https://chain.api.btc.com/v3/tx/unconfirmed
Unconfirmed Tranasctions Summary
GET /tx/unconfirmed/summary
Examples
https://chain.api.btc.com/v3/tx/unconfirmed/summary
Address
Address Info
GET /address/{address}
Examples
Get single address
https://chain.api.btc.com/v3/address/15urYnyeJe3gwbGJ74wcX89Tz7ZtsFDVew
Address Transactions
Batch request is not supported now.
GET /address/{address}/tx
Parameters:
page
, optional, default to1
pagesize
,optional, default to50
, min1
, max50
Examples
https://chain.api.btc.com/v3/address/15urYnyeJe3gwbGJ74wcX89Tz7ZtsFDVew/tx
Unspent
Batch request is not supported now.
GET /address/{address}/unspent
Examples
https://chain.api.btc.com/v3/address/15urYnyeJe3gwbGJ74wcX89Tz7ZtsFDVew/unspent