Recommended Bitcoin transaction fees from mempool.space in satoshis per byte, which rise when the network is busy.
No keys needed.
mempool.space
Use in Studio adds this version to your Data Feeds and opens a Strategy chat with it. It runs on your own Runner when you test it or deploy a Strategy that reads it, in Paper and Live, not in Backtests. Your copy is yours to edit, and later changes to this example don't change it.
# /// turbine-edge-source
# { "contract": 1, "name": "btc_network_fees", "mode": "hosted", "refresh": "1m", "max_age": "5m",
# "fields": {
# "fastest_fee": { "type": "number" },
# "half_hour_fee": { "type": "number" },
# "hour_fee": { "type": "number" },
# "economy_fee": { "type": "number" },
# "minimum_fee": { "type": "number" }
# } }
# ///
# Recommended Bitcoin transaction fees from mempool.space, in satoshis per
# virtual byte: what it costs to be confirmed in the next block, within half
# an hour, within an hour, or eventually. High fees mean a busy network. No
# key needed.
import json
import urllib.request
URL = "https://mempool.space/api/v1/fees/recommended"
def fetch():
req = urllib.request.Request(URL, headers={"User-Agent": "Turbine Data Feed", "Accept": "application/json"})
with urllib.request.urlopen(req, timeout=8) as resp:
fees = json.load(resp)
return {
"fastest_fee": float(fees["fastestFee"]),
"half_hour_fee": float(fees["halfHourFee"]),
"hour_fee": float(fees["hourFee"]),
"economy_fee": float(fees["economyFee"]),
"minimum_fee": float(fees["minimumFee"]),
}