Fee Estimation

FeeEstimator fetches fee rates from the mempool.space REST API with a 30-second in-memory cache.

Usage


import asyncio
from bitpilot import FeeEstimator

estimator = FeeEstimator(network="mainnet")
fee = asyncio.run(estimator.estimate_fee())

print(f"Fast:   {fee.fast_sat_vb} sat/vB (~10 min)")
print(f"Medium: {fee.medium_sat_vb} sat/vB (~30 min)")
print(f"Slow:   {fee.slow_sat_vb} sat/vB (~60 min)")

FeeEstimate Model

FieldTypeDescription
fast_sat_vbfloatNext-block fee rate
medium_sat_vbfloat~3 block fee rate
slow_sat_vbfloat~6 block fee rate
estimated_minutesdict{"fast": 10, "medium": 30, "slow": 60}
fetched_atdatetimeUTC timestamp of the fetch

Target Block Helper


rate = fee.for_target_blocks(1)   # returns fast_sat_vb
rate = fee.for_target_blocks(3)   # returns medium_sat_vb
rate = fee.for_target_blocks(6)   # returns slow_sat_vb

API Endpoints

NetworkURL
mainnethttps://mempool.space/api/v1/fees/recommended
testnethttps://mempool.space/testnet/api/v1/fees/recommended

No API key required. Requests time out after 10 seconds.

Caching

Results are cached for 30 seconds. Subsequent calls within the TTL return the cached FeeEstimate without making an HTTP request.