Page cover

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.infoarrow-up-right 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.

chevron-rightParamshashtag

txid: string (required) - Transaction ID

chevron-rightResponsehashtag

Tx Status

Returns the transaction confirmation status.

Available fields: confirmed (boolean), block_height (optional) and block_hash (optional).

chevron-rightParamshashtag

txid: string (required) - Transaction ID

chevron-rightResponsehashtag

Tx Hex

Returns the hex encoded transaction.

chevron-rightParamshashtag

txid: string (required) - Transaction ID

chevron-rightResponsehashtag

Tx Raw

Returns the raw transaction as binary data.

chevron-rightParamshashtag

txid: string (required) - Transaction ID

verbose: string (optional, defaults to "false") - If "false" return a raw string, otherwise return a json object

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

txid: string (required) - Transaction ID

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

txid: string (required) - Transaction ID

chevron-rightResponsehashtag

Tx Outspends

Returns the spending status of all transaction outputs.

chevron-rightParamshashtag

txid: string (required) - Transaction ID

chevron-rightResponsehashtag

Tx Outspend

Returns the spending status of a specific transaction output.

chevron-rightParamshashtag

txid: string (required) - Transaction ID

vout: string (required) - The number of the transaction output

chevron-rightResponsehashtag

Addresses

Address Info

Returns details about an address.

chevron-rightParamshashtag

address: string (required) - Bitcoin address

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

address: string (required) - Bitcoin address

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

address: string (required) - Bitcoin address

last_seen_txid: string (optional) - Transaction ID from previous query

chevron-rightResponsehashtag

Addr Mempool Tx

Get unconfirmed transaction history for the specified address. Returns up to 50 transactions (no paging).

chevron-rightParamshashtag

address: string (required) - Bitcoin address

Addr UTXOs

Get the list of unspent transaction outputs associated with the address.

chevron-rightParamshashtag

address: string (required) - Bitcoin address

chevron-rightResponsehashtag

Scripthash

A script hasharrow-up-right 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).

chevron-rightParamshashtag

script_hash: string (required) - Script hash

chevron-rightResponsehashtag

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

chevron-rightParamshashtag

script_hash: string (required) - Script hash

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

script_hash: string (required) - Script hash

last_seen_txid: string (optional) - Transaction ID from previous query

chevron-rightResponsehashtag

Scripthash Mempool Tx

Get unconfirmed transaction history for the specified address/scripthash.

Returns up to 50 transactions (no paging).

chevron-rightParamshashtag

script_hash: string (required) - Script hash

chevron-rightResponsehashtag

Scripthash UTXOs

Get the list of unspent transaction outputs associated with the scripthash.

chevron-rightParamshashtag

script_hash: string (required) - Script hash

chevron-rightResponsehashtag

Blocks

Block Info

Returns information about a block.

The response from this endpoint can be cached indefinitely.

chevron-rightParamshashtag

block_hash: string (required) - Hash of the block

chevron-rightResponsehashtag

Block Header

Returns the hex-encoded block header.

The response from this endpoint can be cached indefinitely.

chevron-rightParamshashtag

block_hash: string (required) - Block hash

chevron-rightResponsehashtag

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).

chevron-rightParamshashtag

block_hash: string (required) - Block hash

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

block_hash: string (required) - Block hash

start_index: string (optional) - Start index (must be multiple of 25)

chevron-rightResponsehashtag

Tx Ids by Block Hash

Returns a list of all txids in the block.

The response from this endpoint can be cached indefinitely.

chevron-rightParamshashtag

block_hash: string (required) - Block hash

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

hash: string (required) - Block hash

index: string (optional) - Transaction index

chevron-rightResponsehashtag

Block Raw

Returns the raw block representation in binary.

The response from this endpoint can be cached indefinitely.

chevron-rightParamshashtag

block_hash: string (required) - Block hash

chevron-rightResponsehashtag

Block by Height

Returns the hash of the block currently at block_height.

chevron-rightParamshashtag

block_height: string (required) - Block height

chevron-rightResponsehashtag

Get Blocks

Returns the 10 newest blocks starting at the tip or at start_height if specified.

chevron-rightParamshashtag

start_height: string (required) - Block height

chevron-rightResponsehashtag

Block Tip Height

Returns the height of the last block.

chevron-rightParamshashtag

None

chevron-rightResponsehashtag

Block Tip Hash

Returns the hash of the last block.

chevron-rightParamshashtag

None

chevron-rightResponsehashtag

Mempool

Mempool Stats

Get mempool backlog statistics. Returns an object with:

  • count: the number of transactions in the mempool

  • vsize: the total size of mempool transactions in virtual bytes

  • total_fee: the total fee paid by mempool transactions in satoshis

  • fee_histogram: mempool fee-rate distribution histogram

    An array of (feerate, vsize) tuples, where each entry's vsize is the total vsize of transactions paying more than feerate but less than the previous entry's feerate (except for the first entry, which has no upper bound). This matches the format used by the Electrum RPC protocol for mempool.get_fee_histogram.

chevron-rightParamshashtag

None

chevron-rightResponsehashtag

In this example, there are transactions weighting a total of 102,131 vbytes that are paying more than 53 sat/vB, 110,990 vbytes of transactions paying between 38 and 53 sat/vB, 138,976 vbytes paying between 34 and 38, etc.

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.

chevron-rightParamshashtag

None

chevron-rightResponsehashtag

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

chevron-rightParamshashtag

None

chevron-rightResponsehashtag

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.

chevron-rightParamshashtag

None

chevron-rightResponsehashtag

Last updated