Author

Topic: Getting fee ranges for unconfirmed transactions, a la mempool.space (Read 172 times)

legendary
Activity: 2352
Merit: 6089
bitcoindata.science
Does anyone know how of a mempool.space alternative, or a Python script, to calculate the fee ranges in the next few blocks (highlighted in red in this screenshot)?


A simple python script using requests library and mempool.space data:

Code:
import requests

r = requests.get('https://mempool.space/api/v1/fees/recommended')

r.status_code
# 200

r.json()
# {'fastestFee': 17, 'halfHourFee': 10, 'hourFee': 1, 'minimumFee': 1}

r.json()['fastestFee']
#17

fastestFee next block
halfHourFee 3 blocks
hourFee 6 blocks


Edit: There's mempool.observer as well as jochen-hoenicke.de/queue but they are both visual representation.
I also made one visual representation , few years ago.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
-snip-
I think those are the floating fee estimation which would be okay if OP is trying to estimate the fees for their transactions. I think OP is trying to get the range of fees, mempool.space also offers an API call for that: https://mempool.space/api/v1/fees/mempool-blocks(https://mempool.space/docs/api/rest#get-mempool-blocks-fees). The extremes of each block denotes the range of fees included in that estimated block.
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
I needed something like this for my LED Bitcoin Dashboard [weekend project] and opted to simply use mempool.space's API for it. While I do have a full node on the same network, it was easier and faster to just use an online REST API than building something more custom - after all, it was a weekend project. Wink

The API endpoint I use to get the recommended fee:
Code:
https://mempool.space/api/v1/fees/recommended

Here you have their full API documentation:
https://mempool.space/docs/api/rest

Endpoint for recommended fees:
Endpoint
GET /api/v1/fees/recommended

Description
Returns our currently suggested fees for new transactions.

Code Example
Code:
curl -sSL "https://mempool.space/api/v1/fees/recommended"
Response
Code:
{
  fastestFee: 1,
  halfHourFee: 1,
  hourFee: 1,
  minimumFee: 1
}
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
You can parse the mempool yourself if you require such data. The range of fees are not fee estimations but rather the range of fees in each segment. If I remember correctly, and from the looks of it they use the range of transaction fee rates within each segment of the mempool. I don't think they account for the growth rate of the mempool with respect to time so take the accuracy of it with a grain of salt (if you're estimating the fees of course).

Anyways, I'm not aware of any current implementations that does things like this. As mentioned, estimatesmartfee is the way to go. If you cannot work with that, then something that could work would be to dump the mempool (getrawmempool), organize the transactions in descending order. Then segment the transactions according to the size, get the boundaries of each segment and you're done.  This shouldn't be too difficult to do, might have some time to do it in the coming weeks but no guarantees.

Edit: There's mempool.observer as well as jochen-hoenicke.de/queue but they are both visual representation.
legendary
Activity: 3668
Merit: 6382
Looking for campaign manager? Contact icopress!
If you have your own mempool, maybe consecutive calls of estimatesmartfee with increasing (or decreasing) parameter would do.
Or you can find web based mempools that allow API calls like https://mempool.space/api/v1/fees/mempool-blocks and parse/interpret the results, just make sure you're within the allowed amount of API calls for the platform(s).
full member
Activity: 209
Merit: 148
Does anyone know how of a mempool.space alternative, or a Python script, to calculate the fee ranges in the next few blocks (highlighted in red in this screenshot)?

Jump to: