Oddbean new post about | logout
 There is no API call for the number of mempol blocks, but this can be estimated by dividing the sum of the vBytes in the mempool by 1,000,000

The number of unconfirmed transactions can be called directly. 

Here is a python example:

import json
import requests
import math

# Approximate number of blocks in mempool.space's mempool

total_blockVSize = sum(item['blockVSize'] for item in requests.get('https://mempool.space/api/v1/fees/mempool-blocks').json())

block_count_estimate = math.ceil(total_blockVSize/1000000)

print("Unconfirmed block count: ", block_count_estimate)

# Get transaction count 
transaction_count = requests.get("https://mempool.space/api/mempool").json()['count']

print("Transaction count:", transaction_count) 
 Thank you for this!! 
 Mempool blocks+transactions widget is in the App Store now. 

Block Screen v1.4.4 w/ the systemSmall + accessoryRectangular widget sizes for this widget. https://image.nostr.build/92cb5e0ea6ba146d090224a527b8ba43871942bc83ef4b246011fcf22592d7f6.jpg  
 Excellent app Matt! Thanks for sharing.