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)
Published at
2023-09-30 13:55:34Event JSON
{
"id": "3605e3fa416ccaf52cdadb6e368609f7bfe3a8112364643638fdc6375cc714d6",
"pubkey": "3b6a3d3bb3358836a64d1c80292b96e7698ec35a2e5ca451defa6bd3af3eeb84",
"created_at": 1696082134,
"kind": 1,
"tags": [
[
"e",
"c87896e6304dc54b88a7d0141f7921b2965d8a0ffe69bdd24b5710fb3d86dbc9",
"",
"reply"
],
[
"p",
"1e7229ab0b18d1e8eb8097b6ce97f0e398fb0e9d84aac659c698ddfbb0c929d7"
]
],
"content": "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\n\nThe number of unconfirmed transactions can be called directly. \n\nHere is a python example:\n\nimport json\nimport requests\nimport math\n\n# Approximate number of blocks in mempool.space's mempool\n\ntotal_blockVSize = sum(item['blockVSize'] for item in requests.get('https://mempool.space/api/v1/fees/mempool-blocks').json())\n\nblock_count_estimate = math.ceil(total_blockVSize/1000000)\n\nprint(\"Unconfirmed block count: \", block_count_estimate)\n\n# Get transaction count \ntransaction_count = requests.get(\"https://mempool.space/api/mempool\").json()['count']\n\nprint(\"Transaction count:\", transaction_count)",
"sig": "dfd44a1498af4295c47baf600159abdeab4096085230c69dced56517381b71e2c48db8f1a3b40305e859b848becf1d6b6f743123fc92451dfe2cbfe13aae72e2"
}