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

Params

txid: string (required) - Transaction ID

Response

Tx Status

Returns the transaction confirmation status.

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

Params

txid: string (required) - Transaction ID

Response

Tx Hex

Returns the hex encoded transaction.

Params

txid: string (required) - Transaction ID

Response

Tx Raw

Returns the raw transaction as binary data.

Params

txid: string (required) - Transaction ID

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

Response

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.

Params

txid: string (required) - Transaction ID

Response

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.

Params

txid: string (required) - Transaction ID

Response

Tx Outspends

Returns the spending status of all transaction outputs.

Params

txid: string (required) - Transaction ID

Response

Tx Outspend

Returns the spending status of a specific transaction output.

Params

txid: string (required) - Transaction ID

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

Response

Addresses

Address Info

Returns details about an address.

Params

address: string (required) - Bitcoin address

Response

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.

Params

address: string (required) - Bitcoin address

Response

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.

Params

address: string (required) - Bitcoin address

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

Response

Addr Mempool Tx

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

Params

address: string (required) - Bitcoin address

Addr UTXOs

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

Params

address: string (required) - Bitcoin address

Response

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

Params

script_hash: string (required) - Script hash

Response

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

Params

script_hash: string (required) - Script hash

Response

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.

Params

script_hash: string (required) - Script hash

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

Response

Scripthash Mempool Tx

Get unconfirmed transaction history for the specified address/scripthash.

Returns up to 50 transactions (no paging).

Params

script_hash: string (required) - Script hash

Response

Scripthash UTXOs

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

Params

script_hash: string (required) - Script hash

Response

Blocks

Block Info

Returns information about a block.

The response from this endpoint can be cached indefinitely.

Params

block_hash: string (required) - Hash of the block

Response

Block Header

Returns the hex-encoded block header.

The response from this endpoint can be cached indefinitely.

Params

block_hash: string (required) - Block hash

Response

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

Params

block_hash: string (required) - Block hash

Response

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.

Params

block_hash: string (required) - Block hash

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

Response

Tx Ids by Block Hash

Returns a list of all txids in the block.

The response from this endpoint can be cached indefinitely.

Params

block_hash: string (required) - Block hash

Response

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.

Params

hash: string (required) - Block hash

index: string (optional) - Transaction index

Response

Block Raw

Returns the raw block representation in binary.

The response from this endpoint can be cached indefinitely.

Params

block_hash: string (required) - Block hash

Response

Block by Height

Returns the hash of the block currently at block_height.

Params

block_height: string (required) - Block height

Response

Get Blocks

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

Params

start_height: string (required) - Block height

Response

Block Tip Height

Returns the height of the last block.

Params

None

Response

Block Tip Hash

Returns the hash of the last block.

Params

None

Response

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.

Params

None

Response

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.

Params

None

Response

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

Params

None

Response

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.

Params

None

Response

Last updated