Why Nostr? What is Njump?
2023-09-30 13:55:34
in reply to

mempool on Nostr: There is no API call for the number of mempol blocks, but this can be estimated by ...

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)
Author Public Key
npub18d4r6wanxkyrdfjdrjqzj2ukua5cas669ew2g5w7lf4a8te7awzqey6lt3