2.2. Blocks¶
The Blocks class is available in all explorers.
2.2.1. Usage¶
from bloxplorer import bitcoin_testnet_explorer as explorer
result = explorer.blocks.get('00000000000001bcfbd6242711752c6d8eb15701eb19e410a39a45fa363926e9')
print(result.data)
"""
{
'id': '00000000000001bcfbd6242711752c6d8eb15701eb19e410a39a45fa363926e9',
'height': 1572304,
'version': 536870912,
'timestamp': 1564789315,
'tx_count': 71,
'size': 22381,
'weight': 71122,
'merkle_root': '55cdb5be1689027c81c9bf8731c05f955be49eece5639d99ad95ccbf9374cada',
'previousblockhash': '00000000000001decd01ced9b0b98f15ffb600f6abd27e0634809a90268b3765',
'nonce': 2812464956,
'bits': 436412916
}
"""
- class bloxplorer.blocks.Blocks(*args, **kwargs)¶
Wrapper class around the Esplora Blocks endpoint.
Blockstream Esplora Blocks API Docs
- get(hash, **kwargs)¶
Returns information about a block. The response from this endpoint can be cached indefinitely.
- Parameters:
hash – String representing the block hash.
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.
- get_blocks(start_height=None, **kwargs)¶
Returns the 10 newest blocks starting at the tip or at start_height if specified.
- Parameters:
start_height – (Optional) Integer representing the block height.
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.
- get_height(height, **kwargs)¶
Returns the hash of the block currently at height.
- Parameters:
height – Integer representing the block height.
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.
- get_last_hash(**kwargs)¶
Returns the hash of the last block.
- Parameters:
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.
- get_last_height(**kwargs)¶
Returns the height of the last block.
- Parameters:
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.
- get_status(hash, **kwargs)¶
Returns information about the block status. The response from this endpoint can be cached indefinitely.
- Parameters:
hash – String representing the block hash.
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.
- get_txids(hash, index=None, **kwargs)¶
Returns a list of all txids in the block. If index is present, return the transaction at index index within the specified block. The response from this endpoint can be cached indefinitely.
- Parameters:
hash – String representing the block hash.
index – (Optional) Integer representing the index within a block.
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.
- get_txs(hash, start_index=None, **kwargs)¶
Returns a list of transactions in the block (up to 25 transactions beginning at start_index). Transactions returned here do not have the status field, since all the transactions share the same block and confirmation status. The response from this endpoint can be cached indefinitely.
- Parameters:
hash – String representing the block hash.
start_index – (Optional) Integer representing the transaction start index.
**kwargs – (Optional) Arguments that Requests takes.
- Returns:
- class:
Response object.