2.2. Blocks#
The Blocks class is available in all explorers.
2.2.1. Sync Usage#
from bloxplorer import bitcoin_explorer as explorer
result = explorer.blocks.get('000000000000000000010b6ed9d2333c0797ab02f244ad2adc8734fdf6cd03de')
print(result.data)
2.2.2. Async Usage#
from bloxplorer import async_bitcoin_explorer as async_explorer
result = await async_explorer.blocks.get('000000000000000000010b6ed9d2333c0797ab02f244ad2adc8734fdf6cd03de')
print(result.data)
2.2.3. Result#
Both usages will output the same result data. Example output:
"""
{
'id': '000000000000000000010b6ed9d2333c0797ab02f244ad2adc8734fdf6cd03de',
'height': 921775,
'version': 717307904,
'timestamp': 1762016765,
'tx_count': 2822,
'size': 1484850,
'weight': 3993429,
'merkle_root': 'a1f10dc62eb61cd5d15ebf6fa833b6176faebca5930a1dd41699fd064650a6d8',
'previousblockhash': '00000000000000000000610ab96dec47a277be98d3173857597e0d266249da7a',
'mediantime': 1762011777,
'nonce': 2992019156,
'bits': 385994235,
'difficulty': 155973032196071.94
}
"""
2.2.4. Available methods#
- class bloxplorer.blocks.SyncBlocks(base_url)#
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.