estimatesmartfee - Bitcoin

This method estimates the approximate fee rate per kilobyte needed for a transaction to begin confirmation within a given number of blocks.

Parameters

ParameterTypeRequiredDescription
conf_targetnumberYesConfirmation target in blocks (1 to 1008)
estimate_modestringNoFee estimate mode: "unset", "economical", or "conservative" (default: "conservative")

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "estimatesmartfee",
    "params": [6, "economical"],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'estimatesmartfee',
    params: [6, "economical"],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'estimatesmartfee',
        'params': [6, "economical"],
        'id': 'getblock.io'
    }
)

print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "estimatesmartfee",
            "params": [6, "economical"],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "feerate": 0.00012345,
        "blocks": 6
    }
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultobjectFee estimate object

Result Object

FieldTypeDescription
feeratenumberEstimated fee rate in BTC/kB (1 kB = 1000 bytes)
blocksnumberThe block number the estimate is for
errorsarrayErrors encountered during estimation, if any

Use Cases

  • Dynamic Fees: Compute a fee rate for a target confirmation time
  • Fee Selection UX: Offer users fast, medium, and slow options
  • RBF Strategies: Set fees for replaceable transactions
  • Cost Optimization: Minimize fees for a desired confirmation window

Error Handling

Error CodeMessageDescription
403ForbiddenMissing or invalid ACCESS-TOKEN
-1Insufficient dataNot enough data to produce an estimate
-8Invalid parameterThe confirmation target is out of range
-32602Invalid paramsA parameter is missing or has the wrong type