Skip to main content

Bitcoin Deep Dive: Mempool & Blockchain Data

Learn how to access comprehensive Bitcoin network data including mempool statistics, fee recommendations, address lookups, and Lightning Network metrics.

Overview

The Web3 Identity API provides two Bitcoin data sources:

  • Blockchain.info - Network statistics, supply data, and market metrics
  • Mempool.space - Real-time mempool data, fee estimates, and transaction details

All endpoints are prefixed with /api/bitcoin/.

Prerequisites

npm install @atv-eth/x402-sdk
# or use curl/fetch directly

Quick Start

Get Current Bitcoin Stats

// All Bitcoin data in one call
const response = await fetch('https://api.web3identity.com/api/bitcoin/all');
const data = await response.json();

console.log(`BTC Price: $${data.price.usd}`);
console.log(`Block Height: ${data.network.blockHeight}`);
console.log(`Total Supply: ${data.supply.totalBtc} BTC (${data.supply.percentMined}% mined)`);
curl https://api.web3identity.com/api/bitcoin/all

Response:

{
"price": {
"usd": 97500.42,
"eur": 89234.18,
"gbp": 77123.56
},
"network": {
"blockHeight": 882451,
"difficulty": 110452135211283.5,
"hashrate": 823456789.12,
"hashrateUnit": "GH/s"
},
"supply": {
"totalBtc": 19623456.25,
"maxSupply": 21000000,
"percentMined": "93.4450"
},
"market": {
"marketCap": 1913436789012.34,
"tradeVolume24h": 45678901234.56
},
"source": "blockchain.info",
"timestamp": "2026-02-09T08:30:00.000Z"
}

Network Statistics

Block Information

// Current block height
const blockcount = await fetch('https://api.web3identity.com/api/bitcoin/blockcount');
// { "blockHeight": 882451, "source": "blockchain.info", "timestamp": "..." }

// Latest block hash
const latesthash = await fetch('https://api.web3identity.com/api/bitcoin/latesthash');
// { "latestHash": "00000000000000000002f5e3...", "source": "blockchain.info", "timestamp": "..." }

// Network difficulty
const difficulty = await fetch('https://api.web3identity.com/api/bitcoin/difficulty');
// { "difficulty": 110452135211283.5, "source": "blockchain.info", "timestamp": "..." }

// Network hashrate
const hashrate = await fetch('https://api.web3identity.com/api/bitcoin/hashrate');
// { "hashrate": 823456789.12, "unit": "GH/s", "source": "blockchain.info", "timestamp": "..." }

Supply Metrics

// Total circulating supply
const totalbc = await fetch('https://api.web3identity.com/api/bitcoin/totalbc');
const supply = await totalbc.json();
console.log(`${supply.percentMined}% of max supply mined`);

// Block reward
const bcperblock = await fetch('https://api.web3identity.com/api/bitcoin/bcperblock');
// { "btcPerBlock": 3.125, "satoshisPerBlock": 312500000, ... }

Price & Market Data

// Multi-currency ticker
const ticker = await fetch('https://api.web3identity.com/api/bitcoin/ticker');
// Returns USD, EUR, GBP, JPY, CNY prices

// 24-hour weighted price
const price24h = await fetch('https://api.web3identity.com/api/bitcoin/24hrprice');
// { "price24h": 97234.56, "currency": "USD", ... }

// Market cap
const marketcap = await fetch('https://api.web3identity.com/api/bitcoin/marketcap');
// { "marketCap": 1913436789012.34, "currency": "USD", ... }

// 24-hour transaction count
const txcount = await fetch('https://api.web3identity.com/api/bitcoin/24hrtransactioncount');
// { "transactionCount24h": 456789, ... }

Mempool Data (mempool.space)

Real-Time Mempool Stats

// Mempool overview
const mempool = await fetch('https://api.web3identity.com/api/bitcoin/mempool');
const data = await mempool.json();

console.log(`Pending TXs: ${data.count}`);
console.log(`Total Size: ${(data.vsize / 1000000).toFixed(2)} MB`);
console.log(`Total Fees: ${data.totalFee} sats`);

Response:

{
"count": 45678,
"vsize": 123456789,
"totalFee": 567890123,
"feeHistogram": [[1, 12345], [2, 23456], ...],
"source": "mempool.space",
"timestamp": "2026-02-09T08:30:00.000Z"
}

Recent Mempool Transactions

const recent = await fetch('https://api.web3identity.com/api/bitcoin/mempool/recent');
const data = await recent.json();

data.transactions.forEach(tx => {
console.log(`TX: ${tx.txid.slice(0, 16)}... Fee: ${tx.fee} sats`);
});

Fee Estimation

This is crucial for wallet applications:

const fees = await fetch('https://api.web3identity.com/api/bitcoin/fees/recommended');
const data = await fees.json();

console.log('Fee Recommendations (sat/vB):');
console.log(` ⚡ Fastest (next block): ${data.fastestFee}`);
console.log(` 🚀 Half hour: ${data.halfHourFee}`);
console.log(` ⏰ Hour: ${data.hourFee}`);
console.log(` 💰 Economy: ${data.economyFee}`);
console.log(` 📉 Minimum: ${data.minimumFee}`);

Response:

{
"fastestFee": 45,
"halfHourFee": 38,
"hourFee": 25,
"economyFee": 12,
"minimumFee": 5,
"unit": "sat/vB",
"source": "mempool.space",
"timestamp": "2026-02-09T08:30:00.000Z"
}

Fee Distribution by Block

const blocks = await fetch('https://api.web3identity.com/api/bitcoin/fees/mempool-blocks');
const data = await blocks.json();

// Shows projected blocks with fee ranges
data.blocks.forEach((block, i) => {
console.log(`Block +${i}: ${block.nTx} txs, median fee: ${block.medianFee} sat/vB`);
});

Address Lookups

Address Balance & Stats

const address = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'; // Satoshi's address
const info = await fetch(`https://api.web3identity.com/api/bitcoin/address/${address}`);
const data = await info.json();

console.log(`Balance: ${data.balance} sats`);
console.log(`Total Received: ${data.chain_stats.funded_txo_sum} sats`);
console.log(`Total Spent: ${data.chain_stats.spent_txo_sum} sats`);
console.log(`TX Count: ${data.chain_stats.tx_count}`);

Address Transaction History

const txs = await fetch(`https://api.web3identity.com/api/bitcoin/address/${address}/txs`);
const data = await txs.json();

data.transactions.forEach(tx => {
const status = tx.status.confirmed ? `Block ${tx.status.block_height}` : 'Unconfirmed';
console.log(`${tx.txid.slice(0, 16)}... [${status}] Fee: ${tx.fee}`);
});

Address UTXOs

const utxos = await fetch(`https://api.web3identity.com/api/bitcoin/address/${address}/utxo`);
const data = await utxos.json();

console.log(`${data.count} UTXOs, Total: ${data.totalValue} sats`);
data.utxos.forEach(utxo => {
console.log(` ${utxo.txid.slice(0, 16)}:${utxo.vout} = ${utxo.value} sats`);
});

Transaction Lookups

Transaction Details

const txid = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b';
const tx = await fetch(`https://api.web3identity.com/api/bitcoin/tx/${txid}`);
const data = await tx.json();

console.log(`TX: ${data.txid}`);
console.log(`Size: ${data.size} bytes, Weight: ${data.weight}`);
console.log(`Fee: ${data.fee} sats`);
console.log(`Inputs: ${data.vin}, Outputs: ${data.vout}`);
console.log(`Total Output: ${data.totalOutput} sats`);

Transaction Status

const status = await fetch(`https://api.web3identity.com/api/bitcoin/tx/${txid}/status`);
const data = await status.json();

if (data.confirmed) {
console.log(`✅ Confirmed in block ${data.block_height}`);
console.log(`Block hash: ${data.block_hash}`);
console.log(`Block time: ${new Date(data.block_time * 1000).toISOString()}`);
} else {
console.log('⏳ Unconfirmed (in mempool)');
}

Block Data

Block by Hash

const blockHash = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f';
const block = await fetch(`https://api.web3identity.com/api/bitcoin/block/${blockHash}`);
const data = await block.json();

console.log(`Block #${data.height}: ${data.id.slice(0, 16)}...`);
console.log(`Timestamp: ${new Date(data.timestamp * 1000).toISOString()}`);
console.log(`Transactions: ${data.tx_count}`);
console.log(`Size: ${(data.size / 1000).toFixed(2)} KB`);
console.log(`Difficulty: ${data.difficulty}`);

Block by Height

const block = await fetch('https://api.web3identity.com/api/bitcoin/block-height/0');
// Genesis block!

Recent Blocks

const blocks = await fetch('https://api.web3identity.com/api/bitcoin/blocks');
const data = await blocks.json();

console.log('Recent Blocks:');
data.blocks.forEach(block => {
console.log(`#${block.height}: ${block.tx_count} txs, ${new Date(block.timestamp * 1000).toLocaleString()}`);
});

Mining Data

Mining Pools

// Get pool distribution (default: 1 week)
const pools = await fetch('https://api.web3identity.com/api/bitcoin/mining/pools');
// Or specify period: 24h, 3d, 1w, 1m, 3m, 6m, 1y, all
const poolsWeek = await fetch('https://api.web3identity.com/api/bitcoin/mining/pools?period=1w');

const data = await pools.json();
console.log(`${data.blockCount} blocks in ${data.period}:`);
data.pools.forEach(pool => {
console.log(` ${pool.name}: ${pool.blockCount} blocks (${(pool.share * 100).toFixed(1)}%)`);
});

Network Hashrate

const hashrate = await fetch('https://api.web3identity.com/api/bitcoin/mining/hashrate?period=1m');
const data = await hashrate.json();

console.log(`Current Hashrate: ${data.currentHashrate}`);
console.log(`Current Difficulty: ${data.currentDifficulty}`);
// Also includes historical data points in data.hashrates

Lightning Network

const lightning = await fetch('https://api.web3identity.com/api/bitcoin/lightning/statistics');
const data = await lightning.json();

console.log('⚡ Lightning Network Stats:');
console.log(` Channels: ${data.channels.toLocaleString()}`);
console.log(` Nodes: ${data.nodes.toLocaleString()}`);
console.log(` Total Capacity: ${(data.totalCapacity / 100000000).toFixed(2)} BTC`);
console.log(` Avg Capacity: ${data.avgCapacity} sats`);
console.log(` Avg Fee Rate: ${data.avgFeeRate} ppm`);

Building a Fee Monitor Dashboard

Here's a complete example combining multiple endpoints:

async function getBitcoinDashboard() {
const [all, fees, mempool, blocks] = await Promise.all([
fetch('https://api.web3identity.com/api/bitcoin/all').then(r => r.json()),
fetch('https://api.web3identity.com/api/bitcoin/fees/recommended').then(r => r.json()),
fetch('https://api.web3identity.com/api/bitcoin/mempool').then(r => r.json()),
fetch('https://api.web3identity.com/api/bitcoin/blocks').then(r => r.json())
]);

return {
price: all.price.usd,
blockHeight: all.network.blockHeight,
supply: {
current: all.supply.totalBtc,
percentMined: all.supply.percentMined
},
fees: {
fast: fees.fastestFee,
medium: fees.halfHourFee,
slow: fees.economyFee
},
mempool: {
pendingTxs: mempool.count,
sizeMB: (mempool.vsize / 1000000).toFixed(2)
},
recentBlocks: blocks.blocks.slice(0, 5).map(b => ({
height: b.height,
txCount: b.tx_count,
time: new Date(b.timestamp * 1000).toISOString()
}))
};
}

// Usage
const dashboard = await getBitcoinDashboard();
console.log(JSON.stringify(dashboard, null, 2));

Endpoint Reference

EndpointDescriptionSource
/api/bitcoin/allAll stats in one callblockchain.info
/api/bitcoin/tickerMulti-currency pricesblockchain.info
/api/bitcoin/statsNetwork statisticsblockchain.info
/api/bitcoin/difficultyCurrent difficultyblockchain.info
/api/bitcoin/blockcountBlock heightblockchain.info
/api/bitcoin/hashrateNetwork hashrateblockchain.info
/api/bitcoin/totalbcTotal supplyblockchain.info
/api/bitcoin/bcperblockBlock rewardblockchain.info
/api/bitcoin/marketcapMarket capitalizationblockchain.info
/api/bitcoin/mempoolMempool statsmempool.space
/api/bitcoin/mempool/recentRecent mempool txsmempool.space
/api/bitcoin/fees/recommendedFee recommendationsmempool.space
/api/bitcoin/fees/mempool-blocksFee distributionmempool.space
/api/bitcoin/address/:addressAddress infomempool.space
/api/bitcoin/address/:address/txsAddress transactionsmempool.space
/api/bitcoin/address/:address/utxoAddress UTXOsmempool.space
/api/bitcoin/tx/:txidTransaction detailsmempool.space
/api/bitcoin/tx/:txid/statusTransaction statusmempool.space
/api/bitcoin/block/:hashBlock by hashmempool.space
/api/bitcoin/block-height/:heightBlock by heightmempool.space
/api/bitcoin/blocksRecent blocksmempool.space
/api/bitcoin/mining/poolsMining pool statsmempool.space
/api/bitcoin/mining/hashrateHashrate historymempool.space
/api/bitcoin/lightning/statisticsLightning statsmempool.space

Rate Limits & Pricing

  • Free tier: 100 calls/day
  • Paid: $0.005 - $0.02 per call depending on endpoint
  • Cache: 15-30 second cache on most endpoints

Next Steps