Closed NateNate60 closed 2 years ago
I looked into these providers:
https://api.blockchair.com/stats
The desired information is in data["bitcoin"]["data"]["suggested_transaction_fee_per_byte_sat"]
. Here's a function that will return its recommended feerate, in sat/B:
def get_fee () -> int :
return requests.get(URL).json()['data']["bitcoin"]["data"]["suggested_transaction_fee_per_byte_sat"]
During testing, I hit the API limit, so I didn't investigate further.
https://blockstream.info/api/fee-estimates
Returns information in terms of in how many blocks you want the transaction to confirm. Returns float
by default so we must cast to int
def get_fee(fast: bool = True) -> int :
return int(requests.get(URL).json()['1' if fast else '6'])
https://api.blockchain.info/mempool/fees
def get_fee(fast:bool = True) -> int :
return requests.get(URL).json()['priority' if fast else 'regular']
@NateNate60 Thanks!
@bjarnemagnussen wdyt?
This pull request changes the fee provider from bitcoinfees.earn.com to mempool.space and fixes #152.
The current fee provider (bitcoinfees.earn.com) is often suggesting network fees that are an order of magnitude greater than providers such as Blockchair, Blockstream, Mempool.space, as well as Bitcoin Core. This is unnecessarily wasteful, and even the "slow" network fee is high enough to be a next-block confirmation fee, usually actually two or three times more than the prevailing next-block fee.
I selected Mempool.space because of its seemingly unlimited API limit. At least, I didn't run into its API limit during testing.