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)

Reply to this note

Please Login to reply.

Discussion

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.