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
...
]
},