
esplora (Block Explorer APIs)
SANDSHREW hosts a fully-qualified block explorer API within its JSON-RPC which expresses the full suite of functionality surfaced by esplora, the backend developed and used by blockchain.info for their block explorer API. For a developer, the APIs provided by esplora are often desirable, but running a fully-hosted esplora instance is resource-intensive and therefore costly. SANDSHREW provides esplora as part of the fully-hosted cluster to enable serious Bitcoin-powered application deployments without prohibitive dependencies.
Similar to the scheme used for the ord namespace in the SANDSHREW JSON-RPC, the esplora namespace maps a JSON-RPC payload to a REST call to the backend esplora service and proxies its API directly. This translation from JSON-RPC to REST occurs as follows:
For a JSON-RPC payload such as:
{
"jsonrpc": "2.0",
"id": 1,
"method": "esplora_address::txs",
"params": [
"bc1pqu8j3dlfwjkzt6tcx6w2dvf9j4wxku2n7mnp9eawegayu6k6x9xsgsff7n"
]
}The component of the JSON-RPC method following the esplora_namespace prefix is a colon-delimited list of components to the full REST path which is forwarded to the ord HTTP server. For any instance that splitting the JSON-RPC method by the colon character produces an empty string (i.e. there are repeated colons with no characters in between), these are taken to be placeholders for parameters to sequentially occupy, as the full REST path is constructed. Excess parameters within the JSON-RPC payload, for which there is no positional placeholder within the RPC method, are appended to the REST path as additional components.
Thus, the JSON-RPC method esplora_address::txs with parameters set to ["bc1pqu8j3dlfwjkzt6tcx6w2dvf9j4wxku2n7mnp9eawegayu6k6x9xsgsff7n"] maps to GET /address/bc1pqu8j3dlfwjkzt6tcx6w2dvf9j4wxku2n7mnp9eawegayu6k6x9xsgsff7n/txs on the esplora service.
The complete schema for the esplora HTTP server is available on the esplora repository, named for the project from which it is forked (electrs). The exact line of code where this section begins is linked below:
Transactions
Tx
esplora_tx returns detailed information about a specific Bitcoin transaction based on its transaction ID (txid). It provides comprehensive data about the transaction, including inputs, outputs, block information, and any associated inscriptions.
Tx Status
Returns the transaction confirmation status.
Available fields: confirmed (boolean), block_height (optional) and block_hash (optional).
Tx Hex
Returns the hex encoded transaction.
Tx Raw
Returns the raw transaction as binary data.
Tx Merkleblock Proof
Returns a merkle inclusion proof for the transaction using merkleblock format.
Note: This endpoint is not currently available for Liquid/Elements-based chains.
Tx Merkle-proof
Returns a merkle inclusion proof for the transaction with the following keys:
block_height
The height of the block the transaction was confirmed in.
merkle
A list of transaction hashes the current hash is paired with, recursively, in order to trace up to obtain merkle root of the block, deepest pairing first.
pos
The 0-based index of the position of the transaction in the ordered list of transactions in the block.
Tx Outspends
Returns the spending status of all transaction outputs.
Tx Outspend
Returns the spending status of a specific transaction output.
Addresses
Address Info
Returns details about an address.
Address Tx History
Get transaction history for the specified address. Returns up to 50 mempool transactions plus the first 25 confirmed transactions. You can request more confirmed transactions using last_seen_txid.
Address Confirmed Tx
Get confirmed transaction history for the specified address, sorted with newest first. Returns 25 transactions per page. More can be requested by specifying the last_seen_txid seen by the previous query.
Addr Mempool Tx
Get unconfirmed transaction history for the specified address. Returns up to 50 transactions (no paging).
Addr UTXOs
Get the list of unspent transaction outputs associated with the address.
Scripthash
A script hash is the hash of the binary bytes of the locking script (ScriptPubKey), expressed as a hexadecimal string. The hash function to use is currently sha256().
For example, the legacy Bitcoin address from the genesis block:
has P2PKH scriptpubkey:
with SHA256 hash, the scripthash:
which is sent to the server reversed as:
By subscribing to this hash you can find P2PK payments to the genesis block public key.
Scripthash Info
Get chain and mempool stats for a scripthash (script pub key).
Scripthash Tx History
Get transaction history for the specified address/scripthash, sorted with newest first.
Returns up to 50 mempool transactions plus the first 25 confirmed transactions. You can request more confirmed transactions using last_seen_txid.
beg
Scripthash Confirmed Tx
Get confirmed transaction history for the specified address/scripthash, sorted with newest first.
Returns 25 transactions per page. More can be requested by specifying the last txid seen by the previous query.
Scripthash Mempool Tx
Get unconfirmed transaction history for the specified address/scripthash.
Returns up to 50 transactions (no paging).
Scripthash UTXOs
Get the list of unspent transaction outputs associated with the scripthash.
Blocks
Block Info
Returns information about a block.
The response from this endpoint can be cached indefinitely.
Block Header
Returns the hex-encoded block header.
The response from this endpoint can be cached indefinitely.
Block Status
Returns the block status.
Available fields: in_best_chain (boolean, false for orphaned blocks), next_best (the hash of the next block, only available for blocks in the best chain).
Tx Data by Block Hash
Returns a list of transactions in the block (up to 25 transactions beginning at start_index).
The response from this endpoint can be cached indefinitely.
Tx Ids by Block Hash
Returns a list of all txids in the block.
The response from this endpoint can be cached indefinitely.
Tx Id by Block Index
Returns the transaction number at index <index> within the specified block.
The response from this endpoint can be cached indefinitely.
Block Raw
Returns the raw block representation in binary.
The response from this endpoint can be cached indefinitely.
Block by Height
Returns the hash of the block currently at block_height.
Get Blocks
Returns the 10 newest blocks starting at the tip or at start_height if specified.
Block Tip Height
Returns the height of the last block.
Block Tip Hash
Returns the hash of the last block.
Mempool
Mempool Stats
Get mempool backlog statistics. Returns an object with:
count: the number of transactions in the mempoolvsize: the total size of mempool transactions in virtual bytestotal_fee: the total fee paid by mempool transactions in satoshisfee_histogram: mempool fee-rate distribution histogramAn array of
(feerate, vsize)tuples, where each entry'svsizeis the total vsize of transactions paying more thanfeeratebut less than the previous entry'sfeerate(except for the first entry, which has no upper bound). This matches the format used by the Electrum RPC protocol formempool.get_fee_histogram.
Mempool Tx IDs
Get the full list of txids in the mempool as an array.
The order of the txids is arbitrary and does not match bitcoind's.
Mempool Recent Txs
Get a list of the last 10 transactions to enter the mempool.
Each transaction object contains simplified overview data, with the following fields: txid, fee, vsize and value
Fees
Fee Estimates
Get an object where the key is the confirmation target (in number of blocks) and the value is the estimated fee rate (in sat/vB).
The available confirmation targets are 1-25, 144, 504 and 1008 blocks.
Last updated