Oddbean new post about | logout
 Basically I’m looking for the number of blocks in the mempool, secondary metric would be number of transactions. 

In this case, it would include the data from the left most block in the pic and all other blocks to the right that have yet to be mined.

I’ll look at the API docs in a bit. Also @wiz might be able to tell us how to get this info easily https://image.nostr.build/b131a2c85acaebfdd420d42c6a45c2f1c5648fd7c33d9d12562be51e65a4fa08.png  
 Or @mempool 
 Haven’t found the right API call for it yet but I’ll keep my eyes out and for sure create a widget with it when I find it 
 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.