Bitcoin
Bitcoin API is available on Web3 API platform (opens in a new tab).
Bitcoin API provides the means for communication with the Bitcoin’s public ledger.
In order for your Web3 application to interact with Bitcoin — either by reading blockchain data or sending transactions to the network — it must connect to a Bitcoin node. Developers interact with the blockchain using the methods provided by the API.
Bitcoin interaction interfaces supported:
- Bitcoin API native methods — JSON-RPC (opens in a new tab).
- Blockbook API methods — indexed data via REST.
Bitcoin native methods
Blockchain RPCs:
getbestblockhash
— returns the hash of the best (tip) block in the most-work fully-validated chain.getblock
— retrieves info about a specific block given its block hash.getblockchaininfo
— returns an object containing various state info regarding blockchain processing.getblockcount
— returns the height of the most-work fully-validated chain.getblockfilter
— retrieves a BIP 157 content filter for a particular block.getblockhash
— returns hash of block in best-block-chain at height provided.getblockheader
— retrieves information about a specific block header.getblockstats
— computes per block statistics for a given window.getchaintips
— returns information about all known tips in the block tree.getchaintxstats
— computes statistics about the total number and rate of transactions in the chain.getdifficulty
— returns the proof-of-work difficulty as a multiple of the minimum difficulty.getmempoolancestors
— if txid is in the mempool, returns all in-mempool ancestors.getmempooldescendants
— if txid is in the mempool, returns all in-mempool descendants.getmempoolentry
— returns mempool data for given transaction.getmempoolinfo
— returns details on the active state of the TX memory pool.getrawmempool
— returns all transaction ids in memory pool as a json array of string transaction ids.gettxout
— returns details about an unspent transaction output.gettxoutproof
— returns a hex-encoded proof that “txid” was included in a block.verifytxoutproof
— verifies that a proof points to a transaction in a block.
Raw transactions RPCs:
analyzepsbt
— analyzes and provides information about the current status of a PSBT and its inputs.combinepsbt
— combines multiple partially signed Bitcoin transactions into one transaction.combinerawtransaction
— combines multiple partially signed transactions into one transaction.converttopsbt
— converts a network serialized transaction to a PSBT.createpsbt
– creates a transaction in the Partially Signed Transaction format.createrawtransaction
— creates a transaction spending the given inputs and creating new outputs.decodepsbt
– returns a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.decoderawtransaction
— returns a JSON object representing the serialized, hex-encoded transaction.decodescript
— decodes a hex-encoded script.finalizepsbt
— finalizes the inputs of a PSBT.getrawtransaction
— returns the raw transaction data.joinpsbts
— joins multiple distinct PSBTs with different inputs and outputs into one PSBT.sendrawtransaction
— submits a raw transaction (serialized, hex-encoded) to local node and network.testmempoolaccept
— returns result of mempool acceptance tests.utxoupdatepsbt
— updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, or the mempool.
Util RPCs:
estimatesmartfee
— estimates the approximate fee.getindexinfo
— returns the status of one or all available indices currently running in the node.validateaddress
— returns information about the given bitcoin address.verifymessage
— verifies a signed message.
Wallet RPCs:
The wallet RPCs are only available if Bitcoin Core was built with wallet support, which is the default.
getaddressinfo
— returns information about the given Bitcoin address.
Blockchain RPCs
getbestblockhash
Returns the hash of the best (tip) block in the most-work fully-validated chain.
getbestblockhash
Parameters
id
(string; required): a request ID (example: test).jsonrpc
(string; required): a JSON RPC spec used (example: 2.0).method
(string; required): a method used for the request.params
(array; required): none.
Returns
The block hash, hex-encoded.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getbestblockhash",
"params": []
}'
Response example
{
"result": "00000000000000000001e4696901be3535c9f1cb3f3111caa57e809666021f46",
"error": null,
"id": "test"
}
getblock
Retrieves info about a specific block given its block hash.
If verbosity is 0, returns a string that is serialized, hex-encoded data for block ‘hash’.
If verbosity is 1, returns an Object with information about block ‘hash’.
If verbosity is 2, returns an Object with information about block ‘hash’ and information about each transaction.
getblock "blockhash" ( verbosity )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<blockhash>
(string; required): the block hash.<verbosity>
(numeric; optional; default=1): 0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data.
Returns
Verbosity=0:
A string that is serialized, hex-encoded data for the block hash.
Verbosity=1:
{ (json object)
"hash" : "hex", (string) the block hash (same as provided)
"confirmations" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain
"size" : n, (numeric) The block size
"strippedsize" : n, (numeric) The block size excluding witness data
"weight" : n, (numeric) The block weight as defined in BIP 141
"height" : n, (numeric) The block height or index
"version" : n, (numeric) The block version
"versionHex" : "hex", (string) The block version formatted in hexadecimal
"merkleroot" : "hex", (string) The merkle root
"tx" : [ (json array) The transaction ids
"hex", (string) The transaction id
...
],
"time" : xxx, (numeric) The block time expressed in UNIX epoch time
"mediantime" : xxx, (numeric) The median block time expressed in UNIX epoch time
"nonce" : n, (numeric) The nonce
"bits" : "hex", (string) The bits
"difficulty" : n, (numeric) The difficulty
"chainwork" : "hex", (string) Expected number of hashes required to produce the chain up to this block (in hex)
"nTx" : n, (numeric) The number of transactions in the block
"previousblockhash" : "hex", (string) The hash of the previous block
"nextblockhash" : "hex" (string) The hash of the next block
}
Verbosity=2:
{ (json object)
..., Same output as verbosity = 1
"tx" : [ (json array)
{ (json object)
... The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 "tx" result
},
...
]
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblock",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
}'
Response example
{
"result": {
"hash": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
"confirmations": 842553,
"height": 1000,
"version": 1,
"versionHex": "00000001",
"merkleroot": "fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33",
"time": 1232346882,
"mediantime": 1232344831,
"nonce": 2595206198,
"bits": "1d00ffff",
"difficulty": 1,
"chainwork": "000000000000000000000000000000000000000000000000000003e903e903e9",
"nTx": 1,
"previousblockhash": "0000000008e647742775a230787d66fdf92c46a48c896bfbc85cdc8acc67e87d",
"nextblockhash": "00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6",
"strippedsize": 216,
"size": 216,
"weight": 864,
"tx": [
"fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33"
]
},
"error": null,
"id": "test"
}
getblockchaininfo
Returns an object containing various state info regarding blockchain processing.
getblockchaininfo
Parameters
id
(string; required): a request ID (example: test).jsonrpc
(string; required): a JSON RPC spec used (example: 2.0).method
(string; required): a method used for the request.params
(array; required): none.
Returns
{ (json object)
"chain" : "str", (string) current network name (main, test, regtest)
"blocks" : n, (numeric) the height of the most-work fully-validated chain. The genesis block has height 0
"headers" : n, (numeric) the current number of headers we have validated
"bestblockhash" : "str", (string) the hash of the currently best block
"difficulty" : n, (numeric) the current difficulty
"mediantime" : n, (numeric) median time for the current best block
"verificationprogress" : n, (numeric) estimate of verification progress [0..1]
"initialblockdownload" : true|false, (boolean) (debug information) estimate of whether this node is in Initial Block Download mode
"chainwork" : "hex", (string) total amount of work in active chain, in hexadecimal
"size_on_disk" : n, (numeric) the estimated size of the block and undo files on disk
"pruned" : true|false, (boolean) if the blocks are subject to pruning
"pruneheight" : n, (numeric) lowest-height complete block stored (only present if pruning is enabled)
"automatic_pruning" : true|false, (boolean) whether automatic pruning is enabled (only present if pruning is enabled)
"prune_target_size" : n, (numeric) the target size used by pruning (only present if automatic pruning is enabled)
"softforks" : { (json object) status of softforks
"xxxx" : { (json object) name of the softfork
"type" : "str", (string) one of "buried", "bip9"
"bip9" : { (json object) status of bip9 softforks (only for "bip9" type)
"status" : "str", (string) one of "defined", "started", "locked_in", "active", "failed"
"bit" : n, (numeric) the bit (0-28) in the block version field used to signal this softfork (only for "started" status)
"start_time" : xxx, (numeric) the minimum median time past of a block at which the bit gains its meaning
"timeout" : xxx, (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in
"since" : n, (numeric) height of the first block to which the status applies
"statistics" : { (json object) numeric statistics about BIP9 signalling for a softfork (only for "started" status)
"period" : n, (numeric) the length in blocks of the BIP9 signalling period
"threshold" : n, (numeric) the number of blocks with the version bit set required to activate the feature
"elapsed" : n, (numeric) the number of blocks elapsed since the beginning of the current period
"count" : n, (numeric) the number of blocks with the version bit set in the current period
"possible" : true|false (boolean) returns false if there are not enough blocks left in this period to pass activation threshold
}
},
"height" : n, (numeric) height of the first block which the rules are or will be enforced (only for "buried" type, or "bip9" type with "active" status)
"active" : true|false (boolean) true if the rules are enforced for the mempool and the next block
},
...
},
"warnings" : "str" (string) any network and blockchain warnings
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblockchaininfo",
"params": []
}'
Response example
{
"result": {
"chain": "main",
"blocks": 843552,
"headers": 843552,
"bestblockhash": "00000000000000000000961750bb966af043f98ac0cc9a00c433ccc455204bac",
"difficulty": 83148355189239.77,
"time": 1715765116,
"mediantime": 1715761540,
"verificationprogress": 0.999989001722265,
"initialblockdownload": false,
"chainwork": "000000000000000000000000000000000000000079805bf222b2b5d07d76e90c",
"size_on_disk": 649426145409,
"pruned": false,
"warnings": ""
},
"error": null,
"id": "test"
}
getblockcount
Returns the height of the most-work fully-validated chain.
The genesis block has height 0.
getblockcount
Parameters
id
(string; required): a request ID (example: test).jsonrpc
(string; required): a JSON RPC spec used (example: 2.0).method
(string; required): a method used for the request.params
(array; required): none.
Returns
The current block count.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblockcount",
"params": []
}'
Response example
{
"result": 843552,
"error": null,
"id": "test"
}
getblockfilter
Retrieves a BIP 157 content filter for a particular block.
getblockfilter "blockhash" ( "filtertype" )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<blockhash>
(string; required): the hash of the block.<filtertype>
(string; optional; default=basic): the type name of the filter.
Returns
{ (json object)
"filter" : "hex", (string) the hex-encoded filter data
"header" : "hex" (string) the hex-encoded filter header
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblockfilter",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09", "basic"]
}'
Response example
{
"result": {
"filter": "0163cb10",
"header": "4a242283a406a7c089f671bb8df7671e5d5e9ba577cea1047d30a7f4919df193"
},
"error": null,
"id": "test"
}
getblockhash
Returns hash of block in best-block-chain at height provided.
getblockhash height
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<height>
(numeric; required): the height index.
Returns
The hash of the block.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblockhash",
"params": [1000]
}'
Response example
{
"result": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
"error": null,
"id": "test"
}
getblockheader
Retrieves information about a specific block header
If verbose is false, returns a string that is serialized, hex-encoded data for blockheader hash.
If verbose is true, returns an Object with information about blockheader hash.
getblockheader "blockhash" ( verbose )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<blockhash>
(string; required): the block hash.<verbose>
(boolean; optional; default=true):true
for a json object,false
for the hex-encoded data.
Returns
Verbose=true:
{ (json object)
"hash" : "hex", (string) the block hash (same as provided)
"confirmations" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain
"height" : n, (numeric) The block height or index
"version" : n, (numeric) The block version
"versionHex" : "hex", (string) The block version formatted in hexadecimal
"merkleroot" : "hex", (string) The merkle root
"time" : xxx, (numeric) The block time expressed in UNIX epoch time
"mediantime" : xxx, (numeric) The median block time expressed in UNIX epoch time
"nonce" : n, (numeric) The nonce
"bits" : "hex", (string) The bits
"difficulty" : n, (numeric) The difficulty
"chainwork" : "hex", (string) Expected number of hashes required to produce the current chain
"nTx" : n, (numeric) The number of transactions in the block
"previousblockhash" : "hex", (string) The hash of the previous block
"nextblockhash" : "hex" (string) The hash of the next block
}
Verbose=false:
A string that is serialized, hex-encoded data for block hash.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblockheader",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
}'
Response example
{
"result": {
"hash": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
"confirmations": 842554,
"height": 1000,
"version": 1,
"versionHex": "00000001",
"merkleroot": "fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33",
"time": 1232346882,
"mediantime": 1232344831,
"nonce": 2595206198,
"bits": "1d00ffff",
"difficulty": 1,
"chainwork": "000000000000000000000000000000000000000000000000000003e903e903e9",
"nTx": 1,
"previousblockhash": "0000000008e647742775a230787d66fdf92c46a48c896bfbc85cdc8acc67e87d",
"nextblockhash": "00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6"
},
"error": null,
"id": "test"
}
getblockstats
Computes per block statistics for a given window.
All amounts are in satoshis. It won’t work for some heights with pruning.
getblockstats hash_or_height ( stats )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<hash_or_height>
(string/numeric; required): the block hash or height of the target block. -
<stats>
(json array; optional; default=all values):[ "height", (string) Selected statistic "time", (string) Selected statistic ... ]
-
Returns
{ (json object)
"avgfee" : n, (numeric) Average fee in the block
"avgfeerate" : n, (numeric) Average feerate (in satoshis per virtual byte)
"avgtxsize" : n, (numeric) Average transaction size
"blockhash" : "hex", (string) The block hash (to check for potential reorgs)
"feerate_percentiles" : [ (json array) Feerates at the 10th, 25th, 50th, 75th, and 90th percentile weight unit (in satoshis per virtual byte)
n, (numeric) The 10th percentile feerate
n, (numeric) The 25th percentile feerate
n, (numeric) The 50th percentile feerate
n, (numeric) The 75th percentile feerate
n (numeric) The 90th percentile feerate
],
"height" : n, (numeric) The height of the block
"ins" : n, (numeric) The number of inputs (excluding coinbase)
"maxfee" : n, (numeric) Maximum fee in the block
"maxfeerate" : n, (numeric) Maximum feerate (in satoshis per virtual byte)
"maxtxsize" : n, (numeric) Maximum transaction size
"medianfee" : n, (numeric) Truncated median fee in the block
"mediantime" : n, (numeric) The block median time past
"mediantxsize" : n, (numeric) Truncated median transaction size
"minfee" : n, (numeric) Minimum fee in the block
"minfeerate" : n, (numeric) Minimum feerate (in satoshis per virtual byte)
"mintxsize" : n, (numeric) Minimum transaction size
"outs" : n, (numeric) The number of outputs
"subsidy" : n, (numeric) The block subsidy
"swtotal_size" : n, (numeric) Total size of all segwit transactions
"swtotal_weight" : n, (numeric) Total weight of all segwit transactions
"swtxs" : n, (numeric) The number of segwit transactions
"time" : n, (numeric) The block time
"total_out" : n, (numeric) Total amount in all outputs (excluding coinbase and thus reward [ie subsidy + totalfee])
"total_size" : n, (numeric) Total size of all non-coinbase transactions
"total_weight" : n, (numeric) Total weight of all non-coinbase transactions
"totalfee" : n, (numeric) The fee total
"txs" : n, (numeric) The number of transactions (including coinbase)
"utxo_increase" : n, (numeric) The increase/decrease in the number of unspent outputs
"utxo_size_inc" : n (numeric) The increase/decrease in size for the utxo index (not discounting op_return and similar)
}
Request example
Block hash param:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblockstats",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09", ["minfeerate","avgfeerate"]]
}'
Block height param:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getblockstats",
"params": [1000, ["minfeerate","avgfeerate"]]
}'
Response example
{
"result": {
"avgfeerate": 0,
"minfeerate": 0
},
"error": null,
"id": "test"
}
getchaintips
Returns information about all known tips in the block tree.
Return information about all known tips in the block tree, including the main chain as well as orphaned branches.
getchaintips
Parameters
id
(string; required): a request ID (example: test).jsonrpc
(string; required): a JSON RPC spec used (example: 2.0).method
(string; required): a method used for the request.params
(array; required): none.
Returns
[ (json array)
{ (json object)
"height" : n, (numeric) height of the chain tip
"hash" : "hex", (string) block hash of the tip
"branchlen" : n, (numeric) zero for main chain, otherwise length of branch connecting the tip to the main chain
"status" : "str" (string) status of the chain, "active" for the main chain
Possible values for status:
1. "invalid" This branch contains at least one invalid block
2. "headers-only" Not all blocks for this branch are available, but the headers are valid
3. "valid-headers" All blocks are available for this branch, but they were never fully validated
4. "valid-fork" This branch is not part of the active chain, but is fully validated
5. "active" This is the tip of the active main chain, which is certainly valid
},
...
]
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getchaintips",
"params": []
}'
Response example
{
"result": [
{
"height": 843553,
"hash": "00000000000000000001f0d113bbcef2c1f52882bf8044a7df5299d364216734",
"branchlen": 0,
"status": "active"
},
{
"height": 829613,
"hash": "0000000000000000000357088139cba6dc295875d7d3b2dd1fd764705727e451",
"branchlen": 1,
"status": "valid-fork"
}
],
"error": null,
"id": "test"
}
getchaintxstats
Computes statistics about the total number and rate of transactions in the chain.
getchaintxstats ( nblocks "blockhash" )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<nblocks>
(numeric; optional; default=one month): size of the window in number of blocks<blockhash>
(string; optional; default=chain tip): the hash of the block that ends the window.
Returns
{ (json object)
"time" : xxx, (numeric) The timestamp for the final block in the window, expressed in UNIX epoch time
"txcount" : n, (numeric) The total number of transactions in the chain up to that point
"window_final_block_hash" : "hex", (string) The hash of the final block in the window
"window_final_block_height" : n, (numeric) The height of the final block in the window.
"window_block_count" : n, (numeric) Size of the window in number of blocks
"window_tx_count" : n, (numeric) The number of transactions in the window. Only returned if "window_block_count" is > 0
"window_interval" : n, (numeric) The elapsed time in the window in seconds. Only returned if "window_block_count" is > 0
"txrate" : n (numeric) The average rate of transactions per second in the window. Only returned if "window_interval" is > 0
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getchaintxstats",
"params": [2016]
}'
Response example
{
"result": {
"time": 1715767659,
"txcount": 1005147385,
"window_final_block_hash": "00000000000000000001f0d113bbcef2c1f52882bf8044a7df5299d364216734",
"window_final_block_height": 843553,
"window_block_count": 2016,
"window_tx_count": 7940938,
"window_interval": 1269305,
"txrate": 6.256130717203509
},
"error": null,
"id": "test"
}
getdifficulty
Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
getdifficulty
Parameters
id
(string; required): a request ID (example: test).jsonrpc
(string; required): a JSON RPC spec used (example: 2.0).method
(string; required): a method used for the request.params
(array; required): none.
Returns
The proof-of-work difficulty as a multiple of the minimum difficulty.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getdifficulty",
"params": []
}'
Response example
{
"result": 83148355189239.77,
"error": null,
"id": "test"
}
getmempoolancestors
If txid is in the mempool, returns all in-mempool ancestors.
getmempoolancestors "txid" ( verbose )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<txid>
(string; required): the transaction id (must be in mempool).<verbose>
(boolean; optional; default=false):true
for a json object,false
for array of transaction ids.
Returns
Verbose=false:
[ (json array)
"hex", (string) The transaction id of an in-mempool ancestor transaction
...
]
Verbose=true:
{ (json object)
"transactionid" : { (json object)
"vsize" : n, (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
"weight" : n, (numeric) transaction weight as defined in BIP 141.
"fee" : n, (numeric) transaction fee in BTC (DEPRECATED)
"modifiedfee" : n, (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
"time" : xxx, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
"height" : n, (numeric) block height when transaction entered pool
"descendantcount" : n, (numeric) number of in-mempool descendant transactions (including this one)
"descendantsize" : n, (numeric) virtual transaction size of in-mempool descendants (including this one)
"descendantfees" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
"ancestorcount" : n, (numeric) number of in-mempool ancestor transactions (including this one)
"ancestorsize" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)
"ancestorfees" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
"wtxid" : "hex", (string) hash of serialized transaction, including witness data
"fees" : { (json object)
"base" : n, (numeric) transaction fee in BTC
"modified" : n, (numeric) transaction fee with fee deltas used for mining priority in BTC
"ancestor" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
"descendant" : n (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
},
"depends" : [ (json array) unconfirmed transactions used as inputs for this transaction
"hex", (string) parent transaction id
...
],
"spentby" : [ (json array) unconfirmed transactions spending outputs from this transaction
"hex", (string) child transaction id
...
],
"bip125-replaceable" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
"unbroadcast" : true|false (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
},
...
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getmempoolancestors",
"params": ["mytxid"]
}'
getmempooldescendants
If txid is in the mempool, returns all in-mempool descendants.
getmempooldescendants "txid" ( verbose )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<txid>
(string; required): the transaction id (must be in mempool).<verbose>
(boolean; optional; default=false):true
for a json object,false
for array of transaction ids.
Returns
Verbose=false:
[ (json array)
"hex", (string) The transaction id of an in-mempool descendant transaction
...
]
Verbose=true:
{ (json object)
"transactionid" : { (json object)
"vsize" : n, (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
"weight" : n, (numeric) transaction weight as defined in BIP 141.
"fee" : n, (numeric) transaction fee in BTC (DEPRECATED)
"modifiedfee" : n, (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
"time" : xxx, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
"height" : n, (numeric) block height when transaction entered pool
"descendantcount" : n, (numeric) number of in-mempool descendant transactions (including this one)
"descendantsize" : n, (numeric) virtual transaction size of in-mempool descendants (including this one)
"descendantfees" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
"ancestorcount" : n, (numeric) number of in-mempool ancestor transactions (including this one)
"ancestorsize" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)
"ancestorfees" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
"wtxid" : "hex", (string) hash of serialized transaction, including witness data
"fees" : { (json object)
"base" : n, (numeric) transaction fee in BTC
"modified" : n, (numeric) transaction fee with fee deltas used for mining priority in BTC
"ancestor" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
"descendant" : n (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
},
"depends" : [ (json array) unconfirmed transactions used as inputs for this transaction
"hex", (string) parent transaction id
...
],
"spentby" : [ (json array) unconfirmed transactions spending outputs from this transaction
"hex", (string) child transaction id
...
],
"bip125-replaceable" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
"unbroadcast" : true|false (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
},
...
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getmempooldescendants",
"params": ["mytxid"]
}'
getmempoolentry
Returns mempool data for given transaction.
getmempoolentry "txid"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<txid>
(string; required): the transaction id (must be in mempool).
Returns
{ (json object)
"vsize" : n, (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
"weight" : n, (numeric) transaction weight as defined in BIP 141.
"fee" : n, (numeric) transaction fee in BTC (DEPRECATED)
"modifiedfee" : n, (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
"time" : xxx, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
"height" : n, (numeric) block height when transaction entered pool
"descendantcount" : n, (numeric) number of in-mempool descendant transactions (including this one)
"descendantsize" : n, (numeric) virtual transaction size of in-mempool descendants (including this one)
"descendantfees" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
"ancestorcount" : n, (numeric) number of in-mempool ancestor transactions (including this one)
"ancestorsize" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)
"ancestorfees" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
"wtxid" : "hex", (string) hash of serialized transaction, including witness data
"fees" : { (json object)
"base" : n, (numeric) transaction fee in BTC
"modified" : n, (numeric) transaction fee with fee deltas used for mining priority in BTC
"ancestor" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
"descendant" : n (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
},
"depends" : [ (json array) unconfirmed transactions used as inputs for this transaction
"hex", (string) parent transaction id
...
],
"spentby" : [ (json array) unconfirmed transactions spending outputs from this transaction
"hex", (string) child transaction id
...
],
"bip125-replaceable" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
"unbroadcast" : true|false (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getmempoolentry",
"params": ["mytxid"]
}'
getmempoolinfo
Returns the details on the active state of the TX memory pool.
getmempoolinfo
Parameters
id
(string; required): a request ID (example: test).jsonrpc
(string; required): a JSON RPC spec used (example: 2.0).method
(string; required): a method used for the request.params
(array; required): none.
Returns
{ (json object)
"loaded" : true|false, (boolean) True if the mempool is fully loaded
"size" : n, (numeric) Current tx count
"bytes" : n, (numeric) Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted
"usage" : n, (numeric) Total memory usage for the mempool
"maxmempool" : n, (numeric) Maximum memory usage for the mempool
"mempoolminfee" : n, (numeric) Minimum fee rate in BTC/kB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee
"minrelaytxfee" : n, (numeric) Current minimum relay fee for transactions
"unbroadcastcount" : n (numeric) Current number of transactions that haven't passed initial broadcast yet
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getmempoolinfo",
"params": []
}'
Response example
{
"result": {
"loaded": true,
"size": 57725,
"bytes": 90167011,
"usage": 294308080,
"total_fee": 7.18859673,
"maxmempool": 300000000,
"mempoolminfee": 0.00004923,
"minrelaytxfee": 0.00001,
"incrementalrelayfee": 0.00001,
"unbroadcastcount": 0,
"fullrbf": false
},
"error": null,
"id": "test"
}
getrawmempool
Returns all transaction ids in memory pool as a json array of string transaction ids.
Hint: use getmempoolentry
to fetch a specific transaction from the mempool.
getrawmempool ( verbose mempool_sequence )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<verbose>
(boolean; optional; default=false):true
for a json object,false
for array of transaction ids.<mempool_sequence>
(boolean; optional; default=false): if verbose=false, returns a json object with transaction list and mempool sequence number attached.
Returns
Verbose=false:
[ (json array)
"hex", (string) The transaction id
...
]
Verbose=true:
{ (json object)
"transactionid" : { (json object)
"vsize" : n, (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
"weight" : n, (numeric) transaction weight as defined in BIP 141.
"fee" : n, (numeric) transaction fee in BTC (DEPRECATED)
"modifiedfee" : n, (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
"time" : xxx, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
"height" : n, (numeric) block height when transaction entered pool
"descendantcount" : n, (numeric) number of in-mempool descendant transactions (including this one)
"descendantsize" : n, (numeric) virtual transaction size of in-mempool descendants (including this one)
"descendantfees" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
"ancestorcount" : n, (numeric) number of in-mempool ancestor transactions (including this one)
"ancestorsize" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)
"ancestorfees" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
"wtxid" : "hex", (string) hash of serialized transaction, including witness data
"fees" : { (json object)
"base" : n, (numeric) transaction fee in BTC
"modified" : n, (numeric) transaction fee with fee deltas used for mining priority in BTC
"ancestor" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
"descendant" : n (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
},
"depends" : [ (json array) unconfirmed transactions used as inputs for this transaction
"hex", (string) parent transaction id
...
],
"spentby" : [ (json array) unconfirmed transactions spending outputs from this transaction
"hex", (string) child transaction id
...
],
"bip125-replaceable" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
"unbroadcast" : true|false (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
},
...
}
verbose=false and mempool_sequence=true:
{ (json object)
"txids" : [ (json array)
"hex", (string) The transaction id
...
],
"mempool_sequence" : n (numeric) The mempool sequence value.
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getrawmempool",
"params": []
}'
Response example
{
"result": [
"09448e71251330ff2fab39365284df31278eee4a5102556f674f32155d5eda5b",
"703feebeac6110ec3ab941e6c2e6ef655dc303f77209a142864828e4bba7bfc9",
"587af96d47e5ff6b9690ccba02fafb07473ed70a4528ec34ab5d7bcb1cef7c2e",
"6557e364a70420a1c0d06bad1eaff11cf23ccce3714aa2f384dcc854211f69cc",
"7e42415091463558478e17e62517faace89e14a88c430e0efb9b511739c6b31d",
"9eda12a34bbf507265c21e8d6c59dbfc1a779f238db7c06e8e8160147f74cbef",
"e44938eacb53f4e8a5e61a67cd3f840c02d26ff999349c523cf36761f711fcb4",
"e3494ca0f7fea1e598a1ec090f2f50df989e6c7b36ed1815a67f4a5c1b9e441b",
"7bf20128eb9904fdf4d5dd1a7fafe9d494c52304574a3fcd88c188a83a32086f",
"ebaedb496434bbd6b218e2d5ea1cb6d948a30cabb8f41576c4f15c5e4ad34f9d",
"75f614042e2bd67ac5ee19f425830333ae0381a706afa2b4d21c6f49745b6bff",
"85a183e9e19630e77b65abbf4e50305b32d683626099f65c385f034a2e72cb75"
],
"error": null,
"id": "test"
}
gettxout
Returns details about an unspent transaction output.
gettxout "txid" n ( include_mempool )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<txid>
(string; required): the transaction ID.<n>
(numeric; required): vout number.<include_mempool>
(boolean; optional; default=true): whether to include the mempool. Note that an unspent output that is spent in the mempool won’t appear.
Returns
{ (json object)
"bestblock" : "hex", (string) The hash of the block at the tip of the chain
"confirmations" : n, (numeric) The number of confirmations
"value" : n, (numeric) The transaction value in BTC
"scriptPubKey" : { (json object)
"asm" : "hex", (string)
"hex" : "hex", (string)
"reqSigs" : n, (numeric) Number of required signatures
"type" : "hex", (string) The type, eg pubkeyhash
"addresses" : [ (json array) array of bitcoin addresses
"str", (string) bitcoin address
...
]
},
"coinbase" : true|false (boolean) Coinbase or not
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "gettxout",
"params": ["txid", 1]
}'
gettxoutproof
Returns a hex-encoded proof that “txid” was included in a block.
NOTE: By default this function only works sometimes. This is when there is an unspent output in the utxo for this transaction. To make it always work, you need to maintain a transaction index, using the -txindex
command line option or specify the block in which the transaction is included manually (by blockhash).
gettxoutproof ["txid",...] ( "blockhash" )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<txid>
(array of strings: required): the txids to filter.[ "txid", (string) A transaction hash ... ]
-
<blockhash>
(string; optional): if specified, looks for txid in the block with this hash.
-
Returns
A string that is a serialized, hex-encoded data for the proof.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "gettxoutproof",
"params": [["c7f32887779200fec23a0f4ebe73bed003f9ab8a46c2b549320c3c5cb78c7dc9"], "000000000000000000034e30310c8bf30133e41ae3ae189f987e509901409bf7"]
Response example
{
"result": "008035222f854ca799cc749ca6d54a9ab85793b130a95348fe6e00000000000000000000badfdb8bab19d4ab1f08da2c98122c7d25586ba56b9c13cce8325eb42948fb8028a644669a62031723892528750d00000dc97d8cb75c3c0c3249b5c2468aabf903d0be73be4e0f3ac2fe0092778728f3c7096a1ace4290e6cfb9ab99245aee7fab74f6e6393ef47932d1b6cb494d60451780ecc5be308320b45fd9f07b6cffe1a6b7143ae9e2d134a4292dd937ff83d92b5a683483be79cabafd107330094c049ef166fad38a395b6bc4f58de82f0d5cbd479483b11d489ccb87e20cf97451419453495d1492e32bb9c0539c9a92885d7c2310ef802b85611f6340a7f99c36f04e769ab50bb00048791b16091870f817c503d46587bd48aa6bd895ea6ce9eb3fa06a86b432a40afbf27d879c09093ca03586284ac2b64b252b32be440a683beaf2f672efaf1cb36a429fa2a2cbe0800373a72857c1af218d71e4295ebeabdb80ca35b41f5d3a91c78a186fc76b01690d6f7a89a6912d4528a0072a5945f6a3f94b8fbc293964bdab3b9fb70ea0e7be6caa25f15f366a9473bbf55f69335b7dc642472efeb4feeaa0fafedf70c5a4f7dc370bddd972db84dd9fb5e82fced3cdef20bc98ae178fc8aedb8a2448652c6ce32cbe82d4859c7004d38db06d61b7b5014a89ad9160ec39adfb21b7a92d7f84525404ff1f0000",
"error": null,
"id": "test"
}
verifytxoutproof
Verifies that a proof points to a transaction in a block.
Verifies that a proof points to a transaction in a block, returning the transaction it commits to and throwing an RPC error if the block is not in our best chain.
verifytxoutproof "proof"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<proof>
(string; required): the hex-encoded proof generated bygettxoutproof
.
Returns
[ (json array)
"hex", (string) The txid(s) which the proof commits to, or empty array if the proof can not be validated.
...
]
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "verifytxoutproof",
"params": ["008035222f854ca799cc749ca6d54a9ab85793b130a95348fe6e00000000000000000000badfdb8bab19d4ab1f08da2c98122c7d25586ba56b9c13cce8325eb42948fb8028a644669a62031723892528750d00000dc97d8cb75c3c0c3249b5c2468aabf903d0be73be4e0f3ac2fe0092778728f3c7096a1ace4290e6cfb9ab99245aee7fab74f6e6393ef47932d1b6cb494d60451780ecc5be308320b45fd9f07b6cffe1a6b7143ae9e2d134a4292dd937ff83d92b5a683483be79cabafd107330094c049ef166fad38a395b6bc4f58de82f0d5cbd479483b11d489ccb87e20cf97451419453495d1492e32bb9c0539c9a92885d7c2310ef802b85611f6340a7f99c36f04e769ab50bb00048791b16091870f817c503d46587bd48aa6bd895ea6ce9eb3fa06a86b432a40afbf27d879c09093ca03586284ac2b64b252b32be440a683beaf2f672efaf1cb36a429fa2a2cbe0800373a72857c1af218d71e4295ebeabdb80ca35b41f5d3a91c78a186fc76b01690d6f7a89a6912d4528a0072a5945f6a3f94b8fbc293964bdab3b9fb70ea0e7be6caa25f15f366a9473bbf55f69335b7dc642472efeb4feeaa0fafedf70c5a4f7dc370bddd972db84dd9fb5e82fced3cdef20bc98ae178fc8aedb8a2448652c6ce32cbe82d4859c7004d38db06d61b7b5014a89ad9160ec39adfb21b7a92d7f84525404ff1f0000"]
}'
Response example
{
"result": [
"c7f32887779200fec23a0f4ebe73bed003f9ab8a46c2b549320c3c5cb78c7dc9"
],
"error": null,
"id": "test"
}
Raw transactions RPCs
analyzepsbt
Analyzes and provides information about the current status of a PSBT and its inputs.
analyzepsbt "psbt"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<psbt>
(string; required): a base64 string of a PSBT.
Returns
{ (json object)
"inputs" : [ (json array)
{ (json object)
"has_utxo" : true|false, (boolean) Whether a UTXO is provided
"is_final" : true|false, (boolean) Whether the input is finalized
"missing" : { (json object, optional) Things that are missing that are required to complete this input
"pubkeys" : [ (json array, optional)
"hex", (string) Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing
...
],
"signatures" : [ (json array, optional)
"hex", (string) Public key ID, hash160 of the public key, of a public key whose signature is missing
...
],
"redeemscript" : "hex", (string, optional) Hash160 of the redeemScript that is missing
"witnessscript" : "hex" (string, optional) SHA256 of the witnessScript that is missing
},
"next" : "str" (string, optional) Role of the next person that this input needs to go to
},
...
],
"estimated_vsize" : n, (numeric, optional) Estimated vsize of the final signed transaction
"estimated_feerate" : n, (numeric, optional) Estimated feerate of the final signed transaction in BTC/kB. Shown only if all UTXO slots in the PSBT have been filled
"fee" : n, (numeric, optional) The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled
"next" : "str", (string) Role of the next person that this psbt needs to go to
"error" : "str" (string, optional) Error message (if there is one)
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "analyzepsbt",
"params": ["cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA"]
}'
Response example
{
"result": {
"inputs": [
{
"has_utxo": false,
"is_final": false,
"next": "updater"
}
],
"next": "updater"
},
"error": null,
"id": "test"
}
combinepsbt
Combines multiple partially signed Bitcoin transactions into one transaction.
Implements the Combiner role.
combinepsbt ["psbt",...]
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<txs>
(array of strings; required): the base64 strings of partially signed transactions.[ "psbt", (string) A base64 string of a PSBT ... ]
-
Returns
The base64-encoded partially signed transaction.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "combinepsbt",
"params": ["mybase64_1", "mybase64_2", "mybase64_3"]
}'
combinerawtransaction
Combines multiple partially signed transactions into one transaction.
The combined transaction may be another partially signed transaction or a fully signed transaction.
combinerawtransaction ["hexstring",...]
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<txs>
(array of strings; required): the hex strings of partially signed transactions.[ "hexstring", (string) A hex-encoded raw transaction ... ]
-
Returns
The hex-encoded raw transaction with signatures.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "combinerawtransaction",
"params": ["mybase64_1", "mybase64_2", "mybase64_3"]
}'
converttopsbt
Converts a network serialized transaction to a PSBT.
This should be used only with createrawtransaction
and fundrawtransaction
. createpsbt
and walletcreatefundedpsbt
should be used for new applications.
converttopsbt "hexstring" ( permitsigdata iswitness )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<hexstring>
(string; required): the hex string of a raw transaction.<permitsigdata>
(boolean; optional; default=false): iftrue
, any signatures in the input will be discarded and conversion will continue. Iffalse
, RPC will fail if any signatures are present.<iswitness>
(boolean; optional; default=depends on heuristic tests): whether the transaction hex is a serialized witness transaction. Ifiswitness
is not present, heuristic tests will be used in decoding. If true, only witness deserialization will be tried. If false, only non-witness deserialization will be tried. This boolean should reflect whether the transaction has inputs (e.g. fully valid, or on-chain transactions), if known by the caller.
Returns
The resulting raw transaction (base64-encoded string).
Request example
Create a transaction:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "createrawtransaction",
"params": [[{"txid":"myid","vout":0}],[{"address":0.01}]]
}'
Convert the transaction to PSBT:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "converttopsbt",
"params": ["020000000132bfe475edd6142a2bd4b2fcd61fa7f4cf5bf45994ce4b6d5d2fefa4c7e7a9e10000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000"]
}'
Response example
{
"result": "cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA",
"error": null,
"id": "test"
}
createpsbt
Creates a transaction in the Partially Signed Transaction format.
Implements the Creator role.
createpsbt [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime replaceable )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<inputs>
(json array; required): the json objects.[ { (json object) "txid": "hex", (string, required) The transaction id "vout": n, (numeric, required) The output number "sequence": n, (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number }, ... ]
-
<outputs>
(json array; required): the outputs (key-value pairs), where none of the keys are duplicated. That is, each address can only appear once and there can only be one ‘data’ object. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also accepted as second parameter.[ { (json object) "address": amount, (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC }, { (json object) "data": "hex", (string, required) A key-value pair. The key must be "data", the value is hex-encoded data }, ... ]
-
<locktime>
(numeric; optional; default=0): raw locktime. Non-0 value also locktime-activates inputs. -
<replaceable>
(boolean; optional; default=false): marks this transaction as BIP125 replaceable. Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.
-
Returns
The resulting raw transaction (base64-encoded string).
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "createpsbt",
"params": [[{"txid":"e1a9e7c7a4ef2f5d6d4bce9459f45bcff4a71fd6fcb2d42b2a14d6ed75e4bf32","vout":0}],[{"data":"00010203"}]]
}'
Response example
{
"result": "cHNidP8BAEICAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AQAAAAAAAAAABmoEAAECAwAAAAAAAAA=",
"error": null,
"id": "test"
}
createrawtransaction
Creates a transaction spending the given inputs and creating new outputs.
Outputs can be addresses or data.
Returns hex-encoded raw transaction.
Note that the transaction’s inputs are not signed, and it is not stored in the wallet or transmitted to the network.
createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime replaceable )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<inputs>
(json array; required): the inputs.[ { (json object) "txid": "hex", (string, required) The transaction id "vout": n, (numeric, required) The output number "sequence": n, (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number }, ... ]
-
<outputs>
(json array; required): the outputs (key-value pairs), where none of the keys are duplicated. That is, each address can only appear once and there can only be one ‘data’ object. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also accepted as second parameter.[ { (json object) "address": amount, (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC }, { (json object) "data": "hex", (string, required) A key-value pair. The key must be "data", the value is hex-encoded data }, ... ]
-
<locktime>
(numeric; optional; default=0): raw locktime. Non-0 value also locktime-activates inputs. -
<replaceable>
(boolean; optional; default=false): marks this transaction as BIP125-replaceable. Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.
-
Returns
A hex string of the transaction.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "hww",
"method": "createrawtransaction",
"params": [[{"txid":"e1a9e7c7a4ef2f5d6d4bce9459f45bcff4a71fd6fcb2d42b2a14d6ed75e4bf32","vout":0}], [{"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}]]
}'
Response example
{
"result": "020000000132bfe475edd6142a2bd4b2fcd61fa7f4cf5bf45994ce4b6d5d2fefa4c7e7a9e10000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000",
"error": null,
"id": "hww"
}
decodepsbt
Returns a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.
decodepsbt "psbt"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<psbt>
(string; required): the PSBT base64 string.
Returns
{ (json object)
"tx" : { (json object) The decoded network-serialized unsigned transaction.
... The layout is the same as the output of decoderawtransaction.
},
"unknown" : { (json object) The unknown global fields
"key" : "hex", (string) (key-value pair) An unknown key-value pair
...
},
"inputs" : [ (json array)
{ (json object)
"non_witness_utxo" : { (json object, optional) Decoded network transaction for non-witness UTXOs
...
},
"witness_utxo" : { (json object, optional) Transaction output for witness UTXOs
"amount" : n, (numeric) The value in BTC
"scriptPubKey" : { (json object)
"asm" : "str", (string) The asm
"hex" : "hex", (string) The hex
"type" : "str", (string) The type, eg 'pubkeyhash'
"address" : "str" (string) Bitcoin address if there is one
}
},
"partial_signatures" : { (json object, optional)
"pubkey" : "str", (string) The public key and signature that corresponds to it.
...
},
"sighash" : "str", (string, optional) The sighash type to be used
"redeem_script" : { (json object, optional)
"asm" : "str", (string) The asm
"hex" : "hex", (string) The hex
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"witness_script" : { (json object, optional)
"asm" : "str", (string) The asm
"hex" : "hex", (string) The hex
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"bip32_derivs" : [ (json array, optional)
{ (json object, optional) The public key with the derivation path as the value.
"master_fingerprint" : "str", (string) The fingerprint of the master key
"path" : "str" (string) The path
},
...
],
"final_scriptsig" : { (json object, optional)
"asm" : "str", (string) The asm
"hex" : "str" (string) The hex
},
"final_scriptwitness" : [ (json array)
"hex", (string) hex-encoded witness data (if any)
...
],
"unknown" : { (json object) The unknown global fields
"key" : "hex", (string) (key-value pair) An unknown key-value pair
...
}
},
...
],
"outputs" : [ (json array)
{ (json object)
"redeem_script" : { (json object, optional)
"asm" : "str", (string) The asm
"hex" : "hex", (string) The hex
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"witness_script" : { (json object, optional)
"asm" : "str", (string) The asm
"hex" : "hex", (string) The hex
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"bip32_derivs" : [ (json array, optional)
{ (json object)
"pubkey" : "str", (string) The public key this path corresponds to
"master_fingerprint" : "str", (string) The fingerprint of the master key
"path" : "str" (string) The path
},
...
],
"unknown" : { (json object) The unknown global fields
"key" : "hex", (string) (key-value pair) An unknown key-value pair
...
}
},
...
],
"fee" : n (numeric, optional) The transaction fee paid if all UTXOs slots in the PSBT have been filled.
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "decodepsbt",
"params": ["cHNidP8BAEICAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AQAAAAAAAAAABmoEAAECAwAAAAAAAAA="]
}'
Response example
{
"result": {
"tx": {
"txid": "ad0f4833625ac33a57251e4c7d43fa29ed6f0b4b0276beed9977b6f84bfe58b4",
"hash": "ad0f4833625ac33a57251e4c7d43fa29ed6f0b4b0276beed9977b6f84bfe58b4",
"version": 2,
"size": 66,
"vsize": 66,
"weight": 264,
"locktime": 0,
"vin": [
{
"txid": "e1a9e7c7a4ef2f5d6d4bce9459f45bcff4a71fd6fcb2d42b2a14d6ed75e4bf32",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"sequence": 4294967293
}
],
"vout": [
{
"value": 0,
"n": 0,
"scriptPubKey": {
"asm": "OP_RETURN 50462976",
"desc": "raw(6a0400010203)#6scht25q",
"hex": "6a0400010203",
"type": "nulldata"
}
}
]
},
"global_xpubs": [],
"psbt_version": 0,
"proprietary": [],
"unknown": {},
"inputs": [
{}
],
"outputs": [
{}
]
},
"error": null,
"id": "test"
}
decoderawtransaction
Returns a JSON object representing the serialized, hex-encoded transaction.
decoderawtransaction "hexstring" ( iswitness )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<hexstring>
(string; required): the transaction hex string.<iswitness>
(boolean; optional; default=depends on heuristic tests): whether the transaction hex is a serialized witness transaction. Ifiswitness
is not present, heuristic tests will be used in decoding. If true, only witness deserialization will be tried. If false, only non-witness deserialization will be tried. This boolean should reflect whether the transaction has inputs (e.g. fully valid, or on-chain transactions), if known by the caller.
Returns
{ (json object)
"txid" : "hex", (string) The transaction id
"hash" : "hex", (string) The transaction hash (differs from txid for witness transactions)
"size" : n, (numeric) The transaction size
"vsize" : n, (numeric) The virtual transaction size (differs from size for witness transactions)
"weight" : n, (numeric) The transaction's weight (between vsize*4 - 3 and vsize*4)
"version" : n, (numeric) The version
"locktime" : xxx, (numeric) The lock time
"vin" : [ (json array)
{ (json object)
"txid" : "hex", (string) The transaction id
"vout" : n, (numeric) The output number
"scriptSig" : { (json object) The script
"asm" : "str", (string) asm
"hex" : "hex" (string) hex
},
"txinwitness" : [ (json array)
"hex", (string) hex-encoded witness data (if any)
...
],
"sequence" : n (numeric) The script sequence number
},
...
],
"vout" : [ (json array)
{ (json object)
"value" : n, (numeric) The value in BTC
"n" : n, (numeric) index
"scriptPubKey" : { (json object)
"asm" : "str", (string) the asm
"hex" : "hex", (string) the hex
"reqSigs" : n, (numeric) The required sigs
"type" : "str", (string) The type, eg 'pubkeyhash'
"addresses" : [ (json array)
"str", (string) bitcoin address
...
]
}
},
...
]
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "decoderawtransaction",
"params": ["02000000017e7c9f1b7eb7d7a48028a705a23f30ae9712a1b9c229aa57f948155f1d99f6b60000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000"]
}'
Response example
{
"result": {
"txid": "af71499460ee644f623f51d023dc837f3e2ae5dd6995ab872931fdb0cff2c2ee",
"hash": "af71499460ee644f623f51d023dc837f3e2ae5dd6995ab872931fdb0cff2c2ee",
"version": 2,
"size": 85,
"vsize": 85,
"weight": 340,
"locktime": 0,
"vin": [
{
"txid": "b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"sequence": 4294967293
}
],
"vout": [
{
"value": 0.01,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 62e907b15cbf27d5425399ebf6f0fb50ebb88f18 OP_EQUALVERIFY OP_CHECKSIG",
"desc": "addr(1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa)#632p52jr",
"hex": "76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac",
"address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"type": "pubkeyhash"
}
}
]
},
"error": null,
"id": "test"
}
decodescript
Decodes a hex-encoded script.
decodescript "hexstring"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<hexstring>
(string; required): the hex-encoded script.
Returns
{ (json object)
"asm" : "str", (string) Script public key
"type" : "str", (string) The output type (e.g. nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_scripthash, witness_v0_keyhash, witness_v1_taproot, witness_unknown)
"reqSigs" : n, (numeric) The required signatures
"addresses" : [ (json array)
"str", (string) bitcoin address
...
],
"p2sh" : "str", (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH)
"segwit" : { (json object) Result of a witness script public key wrapping this redeem script (not returned if the script is a P2SH or witness)
"asm" : "str", (string) String representation of the script public key
"hex" : "hex", (string) Hex string of the script public key
"type" : "str", (string) The type of the script public key (e.g. witness_v0_keyhash or witness_v0_scripthash)
"reqSigs" : n, (numeric) The required signatures (always 1)
"addresses" : [ (json array) (always length 1)
"str", (string) segwit address
...
],
"p2sh-segwit" : "str" (string) address of the P2SH script wrapping this witness redeem script
}
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "decodescript",
"params": ["76a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac"]
}'
Response example
{
"result": {
"asm": "OP_DUP OP_HASH160 89abcdefabbaabbaabbaabbaabbaabbaabbaabba OP_EQUALVERIFY OP_CHECKSIG",
"desc": "addr(1DYwPTpZuLjY2qApmJdHaSAuWRvEF5skCN)#kh26y3vv",
"address": "1DYwPTpZuLjY2qApmJdHaSAuWRvEF5skCN",
"type": "pubkeyhash",
"p2sh": "3F6i6kwkevjR7AsAd4te2YB2zZyASEm1HM",
"segwit": {
"asm": "0 89abcdefabbaabbaabbaabbaabbaabbaabbaabba",
"desc": "addr(bc1q3x4ummath24m42a64wa2hw4th24m42a6rul9r7)#fpmsztnh",
"hex": "001489abcdefabbaabbaabbaabbaabbaabbaabbaabba",
"address": "bc1q3x4ummath24m42a64wa2hw4th24m42a6rul9r7",
"type": "witness_v0_keyhash",
"p2sh-segwit": "37PDvpSnXXNRppuGZxa4CvqdfeNh9j6DtE"
}
},
"error": null,
"id": "test"
}
finalizepsbt
Finalizes the inputs of a PSBT.
Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a network serialized transaction which can be broadcast with sendrawtransaction
. Otherwise, a PSBT will be created which has the final_scriptSig
and final_scriptWitness
fields filled for inputs that are complete.
Implements the Finalizer and Extractor roles.
finalizepsbt "psbt" ( extract )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<psbt>
(string; required): a base64 string of a PSBT.<extract>
(boolean; optional; default=true):true
and the transaction is complete, extract and return the complete transaction in normal network serialization instead of the PSBT.
Returns
{ (json object)
"psbt" : "str", (string) The base64-encoded partially signed transaction if not extracted
"hex" : "hex", (string) The hex-encoded network transaction if extracted
"complete" : true|false (boolean) If the transaction has a complete set of signatures
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "finalizepsbt",
"params": ["cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA"]
}'
Response example
{
"result": {
"psbt": "cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA",
"complete": false
},
"error": null,
"id": "test"
}
getrawtransaction
Returns the raw transaction data.
getrawtransaction "txid" ( verbose "blockhash" )
By default, this function only works for mempool transactions. When called with a blockhash argument, getrawtransaction
will return the transaction if the specified block is available and the transaction is found in that block. When called without a blockhash argument, getrawtransaction
will return the transaction if it is in the mempool, or if -txindex
is enabled and the transaction is in a block in the blockchain.
Hint: Use gettransaction
for wallet transactions.
If verbose is true
, returns an Object with information about txid
.
If verbose is false
or omitted, returns a string that is serialized, hex-encoded data for txid
.
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<txid>
(string; required): the transaction ID.<verbose>
(boolean; optional; default=false): iffalse
, return a string, otherwise return a json object.<blockhash>
(string; optional): the block in which to look for the transaction.
Returns
Verbose=false:
The serialized, hex-encoded data for txid
.
Verbose=true:
{ (json object)
"in_active_chain" : true|false, (boolean) Whether specified block is in the active chain or not (only present with explicit "blockhash" argument)
"hex" : "hex", (string) The serialized, hex-encoded data for 'txid'
"txid" : "hex", (string) The transaction id (same as provided)
"hash" : "hex", (string) The transaction hash (differs from txid for witness transactions)
"size" : n, (numeric) The serialized transaction size
"vsize" : n, (numeric) The virtual transaction size (differs from size for witness transactions)
"weight" : n, (numeric) The transaction's weight (between vsize*4-3 and vsize*4)
"version" : n, (numeric) The version
"locktime" : xxx, (numeric) The lock time
"vin" : [ (json array)
{ (json object)
"txid" : "hex", (string) The transaction id
"vout" : n, (numeric) The output number
"scriptSig" : { (json object) The script
"asm" : "str", (string) asm
"hex" : "hex" (string) hex
},
"sequence" : n, (numeric) The script sequence number
"txinwitness" : [ (json array)
"hex", (string) hex-encoded witness data (if any)
...
]
},
...
],
"vout" : [ (json array)
{ (json object)
"value" : n, (numeric) The value in BTC
"n" : n, (numeric) index
"scriptPubKey" : { (json object)
"asm" : "str", (string) the asm
"hex" : "str", (string) the hex
"reqSigs" : n, (numeric) The required sigs
"type" : "str", (string) The type, eg 'pubkeyhash'
"addresses" : [ (json array)
"str", (string) bitcoin address
...
]
}
},
...
],
"blockhash" : "hex", (string) the block hash
"confirmations" : n, (numeric) The confirmations
"blocktime" : xxx, (numeric) The block time expressed in UNIX epoch time
"time" : n (numeric) Same as "blocktime"
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getrawtransaction",
"params": ["c7f32887779200fec23a0f4ebe73bed003f9ab8a46c2b549320c3c5cb78c7dc9", false, "000000000000000000034e30310c8bf30133e41ae3ae189f987e509901409bf7"]
}'
Response example
{
"result": "010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff560327df0c194d696e656420627920416e74506f6f6c20d1001e027fbb47f4fabe6d6de0c279796c6962fedcf285c9d73b2db2bdbf613053c23bde86fbfd601dcb857f10000000000000000000a0a91100000000000000ffffffff05220200000000000017a91442402a28dd61f2718a4b27ae72a4791d5bbdade787e380d0130000000017a9145249bdf2c131d43995cff42e8feee293f79297a8870000000000000000266a24aa21a9edbec170280a56f035b0341dbbddd94bb6e7980831c83800833367122d7aa839dc00000000000000002f6a2d434f524501a37cf4faa0758b26dca666f3e36d42fa15cc01064e3ecda72cb7961caa4b541b1e322bcfe0b5a03000000000000000002b6a2952534b424c4f434b3a4a651ea38b372994e3ba5f22984412606c1f031ea133168998896e280060d9d20120000000000000000000000000000000000000000000000000000000000000000000000000",
"error": null,
"id": "test"
}
joinpsbts
Joins multiple distinct PSBTs with different inputs and outputs into one PSBT.
Joins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs. No input in any of the PSBTs can be in more than one of the PSBTs.
joinpsbts ["psbt",...]
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<txs>
(array of strings; required): the base64 strings of partially signed transactions.[ "psbt", (string, required) A base64 string of a PSBT ... ]
-
Returns
The base64-encoded partially signed transaction.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "joinpsbts",
"params": ["my-spbt1", "my-spbt2", "my-spbt3"]
}'
sendrawtransaction
Submits a raw transaction (serialized, hex-encoded) to local node and network.
Note that the transaction will be sent unconditionally to all peers, so using this for manual rebroadcast may degrade privacy by leaking the transaction’s origin, as nodes will normally not rebroadcast non-wallet transactions already in their mempool.
Also see createrawtransaction
and signrawtransactionwithkey
calls.
sendrawtransaction "hexstring" ( maxfeerate )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<hexstring>
(string; required): the hex string of the raw transaction.<maxfeerate>
(numeric/string; optional; default=0.10): rejects transactions whose fee rate is higher than the specified value, expressed in BTC/kB. Set to 0 to accept any fee rate.
Returns
The transaction hash in hex.
Request example
Create a transaction:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "createrawtransaction",
"params": [[{"txid":"b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e","vout":0}], {"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}]
}'
Sign the transaction, and get back the hex:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "signrawtransactionwithwallet",
"params": ["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e0000000000ffffffff0100f2052a010000001976a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac00000000"]
}'
Send the transaction (signed hex):
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "sendrawtransaction",
"params": ["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e010000006a47304402203b8e51e8ee7a9f23f7c7ea3a73a9b7d9fda7914f7f7d433c9a9e6efad0706e9f022073c405f2beed367d9
testmempoolaccept
Returns result of mempool acceptance tests.
Returns result of mempool acceptance tests indicating if raw transaction (serialized, hex-encoded) would be accepted by mempool.
This checks if the transaction violates the consensus or policy rules.
See sendrawtransaction
call.
testmempoolaccept ["rawtx",...] ( maxfeerate )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<rawtxs>
(array of strings; required): an array of hex strings of raw transactions.[ "rawtx", (string) ... ]
-
<maxfeerate>
(numeric/string; optional; default=0.10): rejects transactions whose fee rate is higher than the specified value, expressed in BTC/kB.
-
Returns
[ (json array) The result of the mempool acceptance test for each raw transaction in the input array.
Length is exactly one for now.
{ (json object)
"txid" : "hex", (string) The transaction hash in hex
"allowed" : true|false, (boolean) If the mempool allows this tx to be inserted
"vsize" : n, (numeric) Virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted (only present when 'allowed' is true)
"fees" : { (json object) Transaction fees (only present if 'allowed' is true)
"base" : n (numeric) transaction fee in BTC
},
"reject-reason" : "str" (string) Rejection string (only present when 'allowed' is false)
},
...
]
Request example
Create a transaction:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "createrawtransaction",
"params": [[{"txid":"b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e","vout":0}], {"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}]
}'
Sign the transaction, and get back the hex:
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "signrawtransactionwithwallet",
"params": ["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e0000000000ffffffff0100f2052a010000001976a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac00000000"]
}'
Test acceptance of the transaction (signed hex):
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "testmempoolaccept",
"params": [["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e010000006a47304402203b8e51e8ee7a9f23f7c7ea3a73a9b7d9fda7914f7f7d433c9a9e6efad0706e9f022073c405f2beed367d9f7ee5e8e6a4e5e5c595cf1fa2b3b5dc74db9b2a36d4e7ec012102f3b5c0e7322d3e72d40c7f6b3fd8b1ab3141574a63eefa9a098c4b0be1dbb5e4ffffffff0100f2052a010000001976a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac00000000"]]
}'
Reponse example
{
"result": [
{
"txid": "077e6ae456a9d84b4bc85aa782121e8b725031178595326d4df078927a66e998",
"wtxid": "077e6ae456a9d84b4bc85aa782121e8b725031178595326d4df078927a66e998",
"allowed": false,
"reject-reason": "missing-inputs"
}
],
"error": null,
"id": "test"
}
utxoupdatepsbt
Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, or the mempool.
utxoupdatepsbt "psbt" ( ["",{"desc":"str","range":n or [n,n]},...] )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):-
<psbt>
(string; required): a base64 string of a PSBT. -
<descriptors>
(array; optional): an array of either strings or objects.[ "", (string) An output descriptor { (json object) An object with an output descriptor and extra information "desc": "str", (string, required) An output descriptor "range": n or [n,n], (numeric or array, optional, default=1000) Up to what index HD chains should be explored (either end or [begin,end]) }, ... ]
-
Returns
The base64-encoded partially signed transaction with inputs updated.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "utxoupdatepsbt",
"params": ["cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA"]
}'
Response example
{
"result": "cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA",
"error": null,
"id": "test"
}
Util RPCs
estimatesmartfee
Estimates the approximate fee.
Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks if possible and return the number of blocks for which the estimate is valid. Uses virtual transaction size as defined in BIP 141 (witness data is discounted).
estimatesmartfee conf_target ( "estimate_mode" )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<conf_target>
(numeric; required): confirmation target in blocks (1 - 1008).<estimate_mode>
(string; optional; default=CONSERVATIVE): the fee estimate mode. Whether to return a more conservative estimate which also satisfies a longer history. A conservative estimate potentially returns a higher feerate and is more likely to be sufficient for the desired target, but is not as responsive to short term drops in the prevailing fee market. Must be one of: “UNSET” “ECONOMICAL” “CONSERVATIVE”.
Returns
{ (json object)
"feerate" : n, (numeric, optional) estimate fee rate in BTC/kB (only present if no errors were encountered)
"errors" : [ (json array, optional) Errors encountered during processing (if there are any)
"str", (string) error
...
],
"blocks" : n (numeric) block number where estimate was found
The request target will be clamped between 2 and the highest target
fee estimation is able to return based on how long it has been running.
An error is returned if not enough transactions and blocks
have been observed to make an estimate for any number of blocks.
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "estimatesmartfee",
"params": [6]
}'
Response example
{
"result": {
"feerate": 0.00012296,
"blocks": 6
},
"error": null,
"id": "test"
}
getindexinfo
Returns the status of one or all available indices currently running in the node.
getindexinfo ( "index_name" )
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<txindex>
(string; optional): filters results for an index with a specific name.
Returns
{ (json object)
"name" : { (json object) The name of the index
"synced" : true|false, (boolean) Whether the index is synced or not
"best_block_height" : n (numeric) The block height to which the index is synced
}
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getindexinfo",
"params": ["txindex"]
}'
validateaddress
Returns information about the given bitcoin address.
validateaddress "address"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<address>
(string; required): the Bitcoin address to validate.
Returns
{ (json object)
"isvalid" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.
"address" : "str", (string) The bitcoin address validated
"scriptPubKey" : "hex", (string) The hex-encoded scriptPubKey generated by the address
"isscript" : true|false, (boolean) If the key is a script
"iswitness" : true|false, (boolean) If the address is a witness address
"witness_version" : n, (numeric, optional) The version number of the witness program
"witness_program" : "hex" (string, optional) The hex value of the witness program
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "validateaddress",
"params": ["bc1qw4e2dl3pfw6nzxrzpghrtnpx7y8kyj7vg09qlh"]
}'
Response example
{
"result": {
"isvalid": false,
"error_locations": [
35,
36
],
"error": "Invalid Bech32 checksum"
},
"error": null,
"id": "test"
}
verifymessage
Verifies a signed message.
verifymessage "address" "signature" "message"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<address>
(string; required): the Bitcoin address to use for the signature.<signature>
(string; required): the signature provided by the signer in base 64 encoding (seesignmessage
).<message>
(string; required): the message that was signed.
Returns
If the signature is verified or not.
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "verifymessage",
"params": ["1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX", "signature", "my message"]
}'
Wallet RPCs
The wallet RPCs are only available if Bitcoin Core was built with wallet support, which is the default.
getaddressinfo
Returns information about the given Bitcoin address.
Some information will only be present if the address is in the active wallet.
getaddressinfo "address"
Parameters
-
id
(string; required): a request ID (example: test). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(array; required):<address>
(string; required): the Bitcoin address for which to get information.
Returns
{ (json object)
"address" : "str", (string) The bitcoin address validated.
"scriptPubKey" : "hex", (string) The hex-encoded scriptPubKey generated by the address.
"ismine" : true|false, (boolean) If the address is yours.
"iswatchonly" : true|false, (boolean) If the address is watchonly.
"solvable" : true|false, (boolean) If we know how to spend coins sent to this address, ignoring the possible lack of private keys.
"desc" : "str", (string, optional) A descriptor for spending coins sent to this address (only when solvable).
"isscript" : true|false, (boolean) If the key is a script.
"ischange" : true|false, (boolean) If the address was used for change output.
"iswitness" : true|false, (boolean) If the address is a witness address.
"witness_version" : n, (numeric, optional) The version number of the witness program.
"witness_program" : "hex", (string, optional) The hex value of the witness program.
"script" : "str", (string, optional) The output script type. Only if isscript is true and the redeemscript is known. Possible
types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,
witness_v0_scripthash, witness_unknown.
"hex" : "hex", (string, optional) The redeemscript for the p2sh address.
"pubkeys" : [ (json array, optional) Array of pubkeys associated with the known redeemscript (only if script is multisig).
"str", (string)
...
],
"sigsrequired" : n, (numeric, optional) The number of signatures required to spend multisig output (only if script is multisig).
"pubkey" : "hex", (string, optional) The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH).
"embedded" : { (json object, optional) Information about the address embedded in P2SH or P2WSH, if relevant and known.
... Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)
and relation to the wallet (ismine, iswatchonly).
},
"iscompressed" : true|false, (boolean, optional) If the pubkey is compressed.
"timestamp" : xxx, (numeric, optional) The creation time of the key, if available, expressed in UNIX epoch time.
"hdkeypath" : "str", (string, optional) The HD keypath, if the key is HD and available.
"hdseedid" : "hex", (string, optional) The Hash160 of the HD seed.
"hdmasterfingerprint" : "hex", (string, optional) The fingerprint of the master key.
"labels" : [ (json array) Array of labels associated with the address. Currently limited to one label but returned as an array to keep the API stable if multiple labels are enabled in the future.
"str", (string) Label name (defaults to "").
...
]
}
Request example
curl -X POST https://rpc.ankr.com/btc \
-d '{
"id": "test",
"method": "getaddressinfo",
"params": ["bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl"]
}'
Blockbook API methods
Blockbook is an open-source blockchain indexer and API backend developed by the cryptocurrency wallet company Trezor. It is designed to be a high-performance and scalable solution for accessing blockchain data.
Blockbook provides interaction with the indexed blockchain data via the following API interfaces:
- Blockbook API v.2 REST — current methods.
- Blockbook API v.1 REST — legacy methods.
Common principles used in Blockbook API V2:
- all crypto amounts are transferred as strings, in the lowest denomination (satoshis, wei, ...), without decimal point
- empty fields are omitted. Empty field is a string of value null or "", a number of value 0, an object of value null or an array without elements.
Blockbook API v.2 REST
The following methods are supported:
- Get block hash — retrieve the hash of a specific block by its height.
- Get transaction — retrieves detailed information about a specific transaction by its ID.
- Get transaction specific — retrieves detailed and specific information about a particular transaction.
- Get address — retrieves info about a specific cryptocurrency address.
- Get xpub — retrieves info about an extended public key (xpub) or descriptor.
- Get utxo — retrieves unspent transaction outputs (UTXOs) for a specific address.
- Get block — retrieves detailed information about a specific block by its height or hash.
- Send transaction — broadcasts a raw transaction to the blockchain network.
- Tickers list — retrieves a list of all available tickers.
- Tickers — retrieves detailed information about specific tickers.
- Balance history — retrieves the balance history for a specific xpub or address over a specified time range.
Get block hash
GET /api/v2/block-index/<block-height>
Retrieves the hash of the block specified by the block number.
Parameters
block-height
(string; path; required): the height (block number) of the block for which you want to retrieve the hash.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/block-index/854043
Response example
{
"blockHash": "000000000000000000020c91b9e0ded91c1b69c00fa0c0611c636425b52f7f98"
}
Note: Blockbook always follows the main chain of the backend it is attached to. See notes on Get Block below
Get transaction
GET /api/v2/tx/<txid>
Retrieves detailed information about a specific transaction on the blockchain. It does not return coin specific fields.
Parameters
txid
(string; path; required): the transaction ID of the transaction you want to retrieve information about.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/tx/950817076007421e23552156277f343fd579cbacc1e92aa14657baff647d2fc9
Response example
{
"txid": "950817076007421e23552156277f343fd579cbacc1e92aa14657baff647d2fc9",
"version": 1,
"vin": [
{
"sequence": 4294967295,
"n": 0,
"isAddress": false,
"coinbase": "03700a0d194d696e656420627920416e74506f6f6c2048008a0022d76023fabe6d6d457f44903a18fde9ef74fe2f8fcec7bdc2bfea8f0cdca4a7e8d93713dec1ca491000000000000000ea4000001802000000000000"
}
],
"vout": [
{
"value": "546",
"n": 0,
"hex": "a91442402a28dd61f2718a4b27ae72a4791d5bbdade787",
"addresses": [
"37jKPSmbEGwgfacCr2nayn1wTaqMAbA94Z"
],
"isAddress": true
},
{
"value": "319767249",
"n": 1,
"hex": "a9145249bdf2c131d43995cff42e8feee293f79297a887",
"addresses": [
"39C7fxSzEACPjM78Z7xdPxhf7mKxJwvfMJ"
],
"isAddress": true
},
{
"value": "0",
"n": 2,
"hex": "6a24aa21a9ed6daa62fdbed57bd0fa6aa10c9522a4a6f602ab0206310d432541ed7dc33a26d0",
"addresses": [
"OP_RETURN aa21a9ed6daa62fdbed57bd0fa6aa10c9522a4a6f602ab0206310d432541ed7dc33a26d0"
],
"isAddress": false
},
{
"value": "0",
"n": 3,
"hex": "6a2d434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a030",
"addresses": [
"OP_RETURN 434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a030"
],
"isAddress": false
},
{
"value": "0",
"n": 4,
"hex": "6a2952534b424c4f434b3a68162ad9bace1bb20c1d2121e9634bc1be6c6dbe32c32684e291622200642fad",
"addresses": [
"OP_RETURN 52534b424c4f434b3a68162ad9bace1bb20c1d2121e9634bc1be6c6dbe32c32684e291622200642fad"
],
"isAddress": false
}
],
"blockHash": "000000000000000000008fe0320eb7034ecababe30a838308b5df4fab8c7a176",
"blockHeight": 854640,
"confirmations": 16,
"blockTime": 1722330680,
"size": 392,
"vsize": 365,
"value": "319767795",
"valueIn": "0",
"fees": "0",
"hex": "010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5603700a0d194d696e656420627920416e74506f6f6c2048008a0022d76023fabe6d6d457f44903a18fde9ef74fe2f8fcec7bdc2bfea8f0cdca4a7e8d93713dec1ca491000000000000000ea4000001802000000000000ffffffff05220200000000000017a91442402a28dd61f2718a4b27ae72a4791d5bbdade787d1420f130000000017a9145249bdf2c131d43995cff42e8feee293f79297a8870000000000000000266a24aa21a9ed6daa62fdbed57bd0fa6aa10c9522a4a6f602ab0206310d432541ed7dc33a26d000000000000000002f6a2d434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a03000000000000000002b6a2952534b424c4f434b3a68162ad9bace1bb20c1d2121e9634bc1be6c6dbe32c32684e291622200642fad0120000000000000000000000000000000000000000000000000000000000000000000000000"
}
Response (unconfirmed tx)
(blockHeight: -1, confirmations: 0, mining estimates confirmationETABlocks and confirmationETASeconds):
{
"txid": "cd8ec77174e426070d0a50779232bba7312b712e2c6843d82d963d7076c61366",
"version": 2,
"vin": [
{
"txid": "47687cc4abb58d815168686465a38113a0608b2568a6d6480129d197e653f6dc",
"sequence": 4294967295,
"n": 0,
"addresses": ["bc1qka0gpenex558g8gpxmpx247mwhw695k6a7yhs4"],
"isAddress": true,
"value": "1983687"
}
],
"vout": [
{
"value": "3106",
"n": 0,
"hex": "0020d7da4868055fde790a8581637ab81c216e17a3f8a099283da6c4a27419ffa539",
"addresses": [
"bc1q6ldys6q9tl08jz59s93h4wquy9hp0glc5zvjs0dxcj38gx0l55uspu8x86"
],
"isAddress": true
},
{
"value": "1979101",
"n": 1,
"hex": "0014381be30ca46ddf378ef69ebc4a601bd6ff30b754",
"addresses": ["bc1q8qd7xr9ydh0n0rhkn67y5cqm6mlnpd65dcyeeg"],
"isAddress": true
}
],
"blockHeight": -1,
"confirmations": 0,
"confirmationETABlocks": 3,
"confirmationETASeconds": 2055,
"blockTime": 1675270935,
"size": 234,
"vsize": 153,
"value": "1982207",
"valueIn": "1983687",
"fees": "1480",
"hex": "020000000001...b18f00000000"
}
A note about the blockTime
field:
- For already mined transactions (
confirmations > 0
), the fieldblockTime
contains time of the block. - For transactions in mempool (
confirmations == 0
), the field contains time when the running instance of Blockbook was first time notified about the transaction. This time may be different in different instances of Blockbook.
Get transaction specific
GET /api/v2/tx-specific/<txid>
Returns transaction data in the exact format as returned by backend, including all coin specific fields.
Parameters
txid
(string; path; required): the unique identifier of the transaction you want to retrieve information about.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/tx-specific/950817076007421e23552156277f343fd579cbacc1e92aa14657baff647d2fc9
Response example
{
"txid": "950817076007421e23552156277f343fd579cbacc1e92aa14657baff647d2fc9",
"hash": "9dedf821ffda5a9e235e455c699983b5c76ce6ab962454317a78aeb84b59519f",
"version": 1,
"size": 392,
"vsize": 365,
"weight": 1460,
"locktime": 0,
"vin": [
{
"coinbase": "03700a0d194d696e656420627920416e74506f6f6c2048008a0022d76023fabe6d6d457f44903a18fde9ef74fe2f8fcec7bdc2bfea8f0cdca4a7e8d93713dec1ca491000000000000000ea4000001802000000000000",
"txinwitness": [
"0000000000000000000000000000000000000000000000000000000000000000"
],
"sequence": 4294967295
}
],
"vout": [
{
"value": 0.00000546,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 42402a28dd61f2718a4b27ae72a4791d5bbdade7 OP_EQUAL",
"desc": "addr(37jKPSmbEGwgfacCr2nayn1wTaqMAbA94Z)#avhxp88d",
"hex": "a91442402a28dd61f2718a4b27ae72a4791d5bbdade787",
"address": "37jKPSmbEGwgfacCr2nayn1wTaqMAbA94Z",
"type": "scripthash"
}
},
{
"value": 3.19767249,
"n": 1,
"scriptPubKey": {
"asm": "OP_HASH160 5249bdf2c131d43995cff42e8feee293f79297a8 OP_EQUAL",
"desc": "addr(39C7fxSzEACPjM78Z7xdPxhf7mKxJwvfMJ)#vjljy0jc",
"hex": "a9145249bdf2c131d43995cff42e8feee293f79297a887",
"address": "39C7fxSzEACPjM78Z7xdPxhf7mKxJwvfMJ",
"type": "scripthash"
}
},
{
"value": 0.00000000,
"n": 2,
"scriptPubKey": {
"asm": "OP_RETURN aa21a9ed6daa62fdbed57bd0fa6aa10c9522a4a6f602ab0206310d432541ed7dc33a26d0",
"desc": "raw(6a24aa21a9ed6daa62fdbed57bd0fa6aa10c9522a4a6f602ab0206310d432541ed7dc33a26d0)#e7gqcaj2",
"hex": "6a24aa21a9ed6daa62fdbed57bd0fa6aa10c9522a4a6f602ab0206310d432541ed7dc33a26d0",
"type": "nulldata"
}
},
{
"value": 0.00000000,
"n": 3,
"scriptPubKey": {
"asm": "OP_RETURN 434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a030",
"desc": "raw(6a2d434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a030)#jcuzcwf4",
"hex": "6a2d434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a030",
"type": "nulldata"
}
},
{
"value": 0.00000000,
"n": 4,
"scriptPubKey": {
"asm": "OP_RETURN 52534b424c4f434b3a68162ad9bace1bb20c1d2121e9634bc1be6c6dbe32c32684e291622200642fad",
"desc": "raw(6a2952534b424c4f434b3a68162ad9bace1bb20c1d2121e9634bc1be6c6dbe32c32684e291622200642fad)#c8yvmutu",
"hex": "6a2952534b424c4f434b3a68162ad9bace1bb20c1d2121e9634bc1be6c6dbe32c32684e291622200642fad",
"type": "nulldata"
}
}
],
"hex": "010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5603700a0d194d696e656420627920416e74506f6f6c2048008a0022d76023fabe6d6d457f44903a18fde9ef74fe2f8fcec7bdc2bfea8f0cdca4a7e8d93713dec1ca491000000000000000ea4000001802000000000000ffffffff05220200000000000017a91442402a28dd61f2718a4b27ae72a4791d5bbdade787d1420f130000000017a9145249bdf2c131d43995cff42e8feee293f79297a8870000000000000000266a24aa21a9ed6daa62fdbed57bd0fa6aa10c9522a4a6f602ab0206310d432541ed7dc33a26d000000000000000002f6a2d434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a03000000000000000002b6a2952534b424c4f434b3a68162ad9bace1bb20c1d2121e9634bc1be6c6dbe32c32684e291622200642fad0120000000000000000000000000000000000000000000000000000000000000000000000000",
"blockhash": "000000000000000000008fe0320eb7034ecababe30a838308b5df4fab8c7a176",
"confirmations": 16,
"time": 1722330680,
"blocktime": 1722330680
}
Get address
GET /api/v2/address/<address>
Returns balances and transactions of an address. The returned transactions are sorted by block height, the newest blocks first.
Parameters
address
(path; string; required): the cryptocurrency address you want to retrieve information about.page
(query; integer; optional): specifies page of returned transactions, starting from 1. If out of range, Blockbook returns the closest possible page.pageSize
(query; integer; optional): number of transactions returned by call (default and maximum 1000)from
(query; integer; optional): a starting block height of transactions to return.to
(query; integer; optional): an ending block height of transactions to return.details
(query; string; optional; default=txids
): specifies level of details returned by request; supported values are the following:basic
: return only address balances, without any transactions.tokens
:basic
+ tokens belonging to the address (applicable only to some coins).tokenBalances
:basic
+ tokens with balances + belonging to the address (applicable only to some coins).txids
:tokenBalances
+ list oftxids
, subject tofrom
,to
filter and pagination.txslight
:tokenBalances
+ list of transaction with limited details (only data from index), subject tofrom
,to
filter and pagination.txs
:tokenBalances
+ list of transaction with details, subject tofrom
,to
filter and pagination.
contract
(query; string; optional): return only transactions which affect specified contract (applicable only to coins which support contracts).secondary
(query; string; optional): specifies secondary (fiat) currency in which the token and total balances are returned in addition to crypto values.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/address/bc1qqy0q2hxw2hwyw4qqdjjewyxx5sq966tstjyvh2y96zrz674dztjqe6qld0?details=txids
Response example
{
"page": 1,
"totalPages": 1,
"itemsOnPage": 1000,
"address": "bc1qqy0q2hxw2hwyw4qqdjjewyxx5sq966tstjyvh2y96zrz674dztjqe6qld0",
"balance": "140659800",
"totalReceived": "140659800",
"totalSent": "0",
"unconfirmedBalance": "0",
"unconfirmedTxs": 0,
"txs": 1,
"txids": [
"711004b7192e86b8c26e2567526a292e01045071a05b5fa40beed8edeb780829"
]
}
Get xpub
GET /api/v2/xpub/<xpub>
Returns balances and transactions of an xpub
or output descriptor, applicable only for Bitcoin-type coins.
Blockbook supports BIP44, BIP49, BIP84 and BIP86 (Taproot) derivation schemes, using either xpubs or output descriptors (see https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md (opens in a new tab))
-
Xpubs
Blockbook expects xpub at level 3 derivation path, i.e. m/purpose'/coin_type'/account'/. Blockbook completes the change/address_index part of the path when deriving addresses. The BIP version is determined by the prefix of the xpub. The prefixes for each coin are defined by fields
xpub_magic
,xpub_magic_segwit_p2sh
,xpub_magic_segwit_native
in the trezor-common (opens in a new tab) library. If the prefix is not recognized, Blockbook defaults to BIP44 derivation scheme.
-
Output descriptors
Output descriptors are in the form
<type>([<path>]<xpub>[/<change>/*])[#checksum]
, for examplepkh([5c9e228d/44'/0'/0']xpub6BgBgses...Mj92pReUsQ/<0;1>/*)#abcd
Parameters
type
andxpub
are mandatory, the rest is optionalBlockbook supports a limited set of
type
s:- BIP44:
pkh(xpub)
- BIP49:
sh(wpkh(xpub))
- BIP84:
wpkh(xpub)
- BIP86 (Taproot single key):
tr(xpub)
Parameter
change
can be a single number or a list of change indexes, specified either in the format<index1;index2;...>
or{index1,index2,...}
. If the parameterchange
is not specified, Blockbook defaults to<0;1>
. - BIP44:
The returned transactions are sorted by block height, the newest blocks first.
Parameters
xpub|descriptor
(path; string; required): the extended public key (xpub) or descriptor you want to retrieve information about.page
(query; integer; optional): specifies returned transactions' page number, starting from 1. If out of range, Blockbook returns the closest possible page.pageSize
(query; integer; optional): the number of transactions returned by call (default and maximum 1000).from
(query; integer; optional): the starting block height to retrieve transactions from.to
(query; integer; optional): the ending block height to retrieve transactions up to.details
(query; string; optional): The level of detail in the response. Possible values are:basic
: only xpub balances, without any derived addresses and transactions.tokens
: basic + tokens (addresses) derived from the xpub, subject to tokens parametertokenBalances
: basic + tokens (addresses) derived from the xpub with balances, subject to tokens parametertxids
: tokenBalances + list of txids, subject tofrom
,to
filter and pagingtxs
: tokenBalances + list of transaction with details, subject tofrom
,to
filter and paging
tokens
(query; string; optional): specifies the tokens (xpub addresses) returned by the request (default nonzero); supported values are the following:nonzero
: return only addresses with nonzero balance.used
: return addresses with at least one transaction.derived
: return all derived addresses.
secondary
(query; string; optional): specifies secondary (fiat) currency in which the balances are returned in addition to crypto values
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/xpub/xpub6AHA9hZDN11k2ijHMeS5QqHx2KP9aMBRhTDqANMnwVtdyw2TDYRmF8PjpvwUFcL1Et8Hj59S3gTSMcUQ5gAqTz3Wd8EsMTmF3DChhqPQBnU
Response example
{
"page": 1,
"totalPages": 1,
"itemsOnPage": 1000,
"address": "xpub6AHA9hZDN11k2ijHMeS5QqHx2KP9aMBRhTDqANMnwVtdyw2TDYRmF8PjpvwUFcL1Et8Hj59S3gTSMcUQ5gAqTz3Wd8EsMTmF3DChhqPQBnU",
"balance": "0",
"totalReceived": "490131736",
"totalSent": "490131736",
"unconfirmedBalance": "0",
"unconfirmedTxs": 0,
"txs": 68,
"addrTxCount": 80,
"txids": [
"32ae8b107808fa52e811d0b0ac988959a5225af520ab1ba8b6461e1ae01c6549",
"4c3fb15f12550280922896879120f2f629e56341df59112b0463d19bced143d9",
"32b8d9c755d17da87d7ebbaa0589fe888f8547a7c4307b62991247d5dd4ef6f6",
"a69c554c12a0f991cc5b8072e30782381e5748c97ab851dafcbc984928a60894",
"2276913ab7b623feeda669d953ebd715984d87200bc01d1cb4fe8c1797e6f6ef",
"19540748a8f3dc41a6b4a76fd1567987c375ff028ff280fe0a06f4d77da1744d",
"0b24d267cb6c8122f2cff5a12090b78dd96102752b7ce9d274f1207805794635",
"bca1b4fa2e0e962523f299588b2aa5f06065f6fc8a46180e0e0992297a9bad22",
"8f8e412a4e0b0e140b28ae3ea01bad13b9a03383b04ead14e287f9103ecb64aa",
"3b9170ee0267d138334af4ca3accce780d6b99f0b339263dbfe1abbe2e0d9b98",
"22c0d06fe20252d22123d31bad257376c038b365e2206518ea3e085e6c1f893c",
"45bba65dd50120dbaba555471321074d631c492d7a6f6a48384b313f0e32ed3f",
"a958148603cbc8f4b98624c5807a6e6ac86f573191ee108d1795835561f98e2d",
"5f2cbbe257f7c38c62f0c5058e97451bc52b218596bb1fcadad1b7feddd8ac37"
],
"usedTokens": 33
}
Note: usedTokens always returns total number of used addresses of xpub.
Get utxo
GET /api/v2/utxo/<address>
Returns array of unspent transaction outputs of address or xpub, applicable only for Bitcoin-type coins. By default, the list contains both confirmed and unconfirmed transactions. The query parameter confirmed=true
disables return of unconfirmed transactions. The returned utxos are sorted by block height, the newest blocks first. For xpubs or output descriptors, the response also contains address and derivation path of the utxo.
Unconfirmed utxos do not have field height
, the field confirmations
has value 0
and may contain field lockTime
, if not zero.
Coinbase utxos have field coinbase set to true, however due to performance reasons only up to minimum coinbase confirmations limit (100). After this limit, utxos are not detected as coinbase.
Parameters
address
|xpub
|descriptor
(string; path; required): this parameter can be either a regular cryptocurrency address, an extended public key (xpub), or a descriptor. It is required to specify one of these to identify the source for which UTXOs are to be retrieved:address
: a standard cryptocurrency address (e.g., Bitcoin address).xpub
: an extended public key that can derive multiple addresses.descriptor
: a more flexible way to specify addresses using output descriptors.
confirmed
(boolean; query; optional): filters the UTXOs based on their confirmation status; If set totrue
, only confirmed UTXOs will be returned.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/utxo/bc1qxhmdufsvnuaaaer4ynz88fspdsxq2h9e9cetdj?confirmed=true
Response example
[
{
"txid": "c80f70c48aff883b060aed28544aec0fbdeb3db913a214d37194cee6337b0437",
"vout": 1,
"value": "319691557",
"height": 854658,
"confirmations": 3,
"coinbase": true
},
{
"txid": "d6957ef0d3a8a13b369f4996f3a80182acc26445508f22ac50a4cea468663f06",
"vout": 1,
"value": "317092804",
"height": 854649,
"confirmations": 12,
"coinbase": true
},
{
"txid": "9b11befa61b7e7bc7440fcb68213c6ecf2c19f50bfac4fc5a4bbe37dad138d0d",
"vout": 1,
"value": "319367244",
"height": 854646,
"confirmations": 15,
"coinbase": true
}
]
Get block
GET /api/v2/block/<block>
Returns information about block with transactions. Subject to pagination.
Parameters
block-height
|block-hash
(path; required): specify the block height or the block hash to retrieve info for:block-height
(integer): the height (number) of the block in the blockchain.block-hash
(string): unique hash of the block.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/block/854631
Response example
{
"page": 1,
"totalPages": 4,
"itemsOnPage": 1000,
"hash": "00000000000000000000b6770ffd8f9c1697e3d7f63ffe129c4f3a8f5eea0437",
"previousBlockHash": "00000000000000000002b9e2f4f115c54505978fc8691053af32e51127b5b335",
"nextBlockHash": "00000000000000000000225a7447063290267bf4ba2013b4bd53b1bc94c568d9",
"height": 854631,
"confirmations": 30,
"size": 1615140,
"time": 1722328595,
"version": 735567872,
"merkleRoot": "56b0dc81de0f00d81eb5ea566563deb15acb7b39ff79b46d14e34584d0431f1b",
"nonce": "287725700",
"bits": "17036e3a",
"difficulty": "82047728459932.75",
"txCount": 3988,
"txs": [
{
"txid": "9ebf046099d38fc97d9fbdb864fdbb1205871b2294bc6fd6eb187e13b42d41f7",
"vin": [
{
"n": 0,
"isAddress": false,
"value": "0"
}
],
"vout": [
{
"value": "546",
"n": 0,
"addresses": [
"37jKPSmbEGwgfacCr2nayn1wTaqMAbA94Z"
],
"isAddress": true
},
{
"value": "320584648",
"n": 1,
"addresses": [
"39C7fxSzEACPjM78Z7xdPxhf7mKxJwvfMJ"
],
"isAddress": true
},
{
"value": "0",
"n": 2,
"addresses": [
"OP_RETURN aa21a9edb28074e5f34e138fd659c82217610fbe81159aff0fee8bdb15f619828811f4f8"
],
"isAddress": false
},
{
"value": "0",
"n": 3,
"addresses": [
"OP_RETURN 434f5245012953559db5cc88ab20b1960faa9793803d0703374e3ecda72cb7961caa4b541b1e322bcfe0b5a030"
],
"isAddress": false
},
{
"value": "0",
"n": 4,
"addresses": [
"OP_RETURN 52534b424c4f434b3aef4c3fbaf3d2e916c4159306ca07eb8d7ba33359c32684e291621c2700642f6a"
],
"isAddress": false
}
],
"blockHash": "00000000000000000000b6770ffd8f9c1697e3d7f63ffe129c4f3a8f5eea0437",
"blockHeight": 854631,
"confirmations": 30,
"blockTime": 1722328595,
"vsize": 365,
"value": "320585194",
"valueIn": "0",
"fees": "0"
}
]
}
Note: Blockbook always follows the main chain of the backend it is attached to. If there is a rollback-reorg in the backend, Blockbook will also do rollback. When you ask for block by height, you will always get the main chain block. If you ask for block by hash, you may get the block from another fork, but it is not guaranteed (backend may not keep it)
Send transaction
GET /api/v2/sendtx/<hex-tx-data>
POST /api/v2/sendtx/
Broadcasts new transaction to the blockchain.
Parameters (GET request)
hex-tx-data
(path; string; required): the raw transaction data in hexadecimal format that you want to broadcast to the network.
Parameters (POST request)
hex-tx-data
(body; string; required): the raw transaction data in hexadecimal format that you want to broadcast to the network.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/sendtx/{hex-tx-data}
Response example
{
"result": "7c3be24063f268aaa1ed81b64776798f56088757641a34fb156c4f51ed2e9d25"
}
Response example (error)
{
"error": {
"message": "error message"
}
}
Tickers list
GET /api/v2/tickers-list/
Returns a list of available currency rate tickers (secondary currencies) for the specified date, along with an actual data timestamp.
Parameters
timestamp
(query; integer; optional): the Unix timestamp for which to retrieve the tickers for.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/tickers-list/?timestamp=1625648394
Response example
{
"ts": 1722346261,
"available_currencies": [
"aed",
"ars",
"aud",
"bdt",
"bhd",
"bmd",
"brl",
"btc",
"cad"
]
}
Tickers
GET /api/v2/tickers/
Returns currency rate for the specified currency and date. If the currency is not available for that specific timestamp, the next closest rate will be returned. All responses contain an actual rate timestamp.
Parameters
currency
(query; string; optional): specifies a currency of returned rate ("usd", "eur", "eth"...). If not specified, all available currencies will be returned.timestamp
(query; integer; optional): a Unix timestamp that specifies a date to return currency rates for. If not specified, the last available rate will be returned.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/tickers/?currency=usd×tamp=1625648394
Response example
{
"ts": 1722346380,
"rates": {
"usd": 66601
}
}
Response example (no params)
{
"ts": 1722346500,
"rates": {
"aed": 244626,
"ars": 62038176,
"aud": 101909,
"bdt": 7828348,
"bhd": 25103,
"bmd": 66601,
"brl": 376127,
"btc": 1
}
}
Response example (error)
Rate unavailable, incorrect currency, etc.
{
"ts":7980386400,
"rates": {
"usd": -1
}
}
Balance history
GET /api/v2/balancehistory/<address>
Returns a balance history for the specified xpub or address.
Parameters
xpub|address
(path; string; required): the extended public key (XPUB) or the cryptocurrency address to retrieve the balance history for.from
(query; integer; optional): specifies a start date as a Unix timestamp.to
(query; integer; optional): specifies an end date as a Unix timestamp.fiatcurrency
(query; string; optional): if specified, the response will contain secondary (fiat) rate at the time of transaction. If not, all available currencies will be returned.groupBy
(query; integer; optional): an interval in seconds, to group results by. Default is 3600 seconds.
Request example
curl -X GET https://rpc.ankr.com/http/btc_blockbook/api/v2/balancehistory/39C7fxSzEACPjM78Z7xdPxhf7mKxJwvfMJ
Response example
[
{
"time": 1711350000,
"txs": 1,
"received": "100000",
"sent": "0",
"sentToSelf": "0",
"rates": {
"aed": 245674,
"ars": 62306730,
"aud": 102337
...
}
},
{
"time": 1711436400,
"txs": 1,
"received": "5000000000",
"sent": "0",
"sentToSelf": "0",
"rates": {
"aed": 245674,
"ars": 62306730,
"aud": 102337
...
}
}
]
Response example (?fiatcurrency=usd
)
[
{
"time": 1711350000,
"txs": 1,
"received": "100000",
"sent": "0",
"sentToSelf": "0",
"rates": {
"usd": 66563
}
},
{
"time": 1711436400,
"txs": 1,
"received": "5000000000",
"sent": "0",
"sentToSelf": "0",
"rates": {
"usd": 66563
}
}
]
Response example (?fiatcurrency=usd&groupBy=172800
):
[
{
"time": 1711238400,
"txs": 1,
"received": "100000",
"sent": "0",
"sentToSelf": "0",
"rates": {
"usd": 66563
}
},
{
"time": 1711411200,
"txs": 33,
"received": "30061271674",
"sent": "5000000000",
"sentToSelf": "4998996282",
"rates": {
"usd": 66563
}
}
]
The value of sentToSelf
is the amount sent from the same address to the same address or within addresses of xpub.
Blockbook API v.1 REST
GET /api/v1/block-index/<block height>
GET /api/v1/tx/<txid>
GET /api/v1/address/<address>
GET /api/v1/utxo/<address>
GET /api/v1/block/<block height | block hash>
GET /api/v1/estimatefee/<number of blocks>
GET /api/v1/sendtx/<hex tx data>
POST /api/v1/sendtx/ (hex tx data in request body)