TriportRPC

eth_feeHistory

POSThttps://api.triport.io/v1/ethereum

Returns a window of historical base fees, gas-usage ratios, and priority-fee percentiles, used to estimate EIP-1559 fees.

Ethereumeth_read_rpcfree 10 RPS · basic 20 RPS · pro 100 RPS · business 250 RPS

eth_feeHistory returns fee-market data for a contiguous range of blocks ending at newestBlock. For each block in the window it reports the base fee per gas, the gas-used ratio, and — when you pass rewardPercentiles — the effective priority fee (tip) at each requested percentile. The response also includes the projected base fee for the block immediately after the window, so the baseFeePerGas array always has one more entry than the number of blocks requested.

Use it to build EIP-1559 fee estimates: read recent base fees to anticipate the next block's base fee, and read tip percentiles to pick a maxPriorityFeePerGas that matches how aggressively you want a transaction included. A common pattern is to request the last few blocks at the [10, 50, 90] percentiles and choose a tip from the median or upper band depending on urgency.

All numeric values are returned as 0x-prefixed hexadecimal strings (wei), including the entries inside the reward arrays. The gasUsedRatio field is the exception — it is a JSON number between 0 and 1.

Parameters

Positional params array, in order:

blockCountstring | numberrequired
Number of blocks in the requested window, 11024. Accepts a hex-encoded string (e.g. "0x5") or an integer.
newestBlockstringrequired
Highest block of the window: a 0x-prefixed block number or a tag ("latest", "pending", "earliest", "safe", "finalized").
rewardPercentilesnumber[]optional
Monotonically increasing list of percentiles (0100) at which to sample effective priority fees per block. Omit to skip the reward array.

Response

Response fields

FieldTypeDescription
jsonrpcstringJSON-RPC version, always "2.0".
idnumberEchoes the request id.
resultobjectThe fee-history window.
result.oldestBlockstringBlock number of the lowest (oldest) block in the window, as a 0x-prefixed hex string.
result.baseFeePerGasstring[]Base fee per gas (wei, hex) for each block in the window plus the projected base fee for the next block. Length = blockCount + 1.
result.gasUsedRationumber[]Ratio of gas used to gas limit (01) for each block in the window. Length = blockCount.
result.rewardstring[][]Per-block array of effective priority fees (wei, hex), one entry per requested percentile. Length = blockCount. Omitted when rewardPercentiles is not supplied.

Errors

CodeMeaningWhen it happens
-32001trial_expiredThe account's trial period has ended.
-32003rate_limitedThe per-tier RPS limit was exceeded. Back off and retry.
-32602invalid_paramsblockCount is outside 11024, rewardPercentiles is not increasing or out of range, or newestBlock is malformed.

See errors.md for the full error envelope and handling guidance.

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/v1/ethereum", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "eth_feeHistory",
    params: ["0x4", "latest", [10, 50, 90]],
  }),
});


const { result } = await res.json();


// Suggest a tip from the median (50th percentile) of the most recent block.
const recentReward = result.reward.at(-1);
const medianTip = parseInt(recentReward[1], 16);
const nextBaseFee = parseInt(result.baseFeePerGas.at(-1), 16);
console.log({ nextBaseFee, medianTip });

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });


interface FeeHistory {
  oldestBlock: string;
  baseFeePerGas: string[];
  gasUsedRatio: number[];
  reward?: string[][];
}


const history = await client.ethereum.request<FeeHistory>("eth_feeHistory", [
  "0x4",
  "latest",
  [10, 50, 90],
]);


const nextBaseFee = parseInt(history.baseFeePerGas.at(-1)!, 16);
console.log("projected base fee (wei):", nextBaseFee);

Python (triport-sdk)

import os
from triport import Triport


client = Triport(api_key=os.environ["TRIPORT_API_KEY"])


history = client.ethereum.request(
    "eth_feeHistory",
    ["0x4", "latest", [10, 50, 90]],
)


next_base_fee = int(history["baseFeePerGas"][-1], 16)
median_tip = int(history["reward"][-1][1], 16)
print("projected base fee (wei):", next_base_fee)
print("median tip (wei):", median_tip)

Notes

  • baseFeePerGas is always one element longer than blockCount — the last entry is the predicted base fee for the block after newestBlock, which is what you feed into a maxFeePerGas estimate.
  • gasUsedRatio values near 1.0 indicate full blocks and an upward-trending base fee; values well below 0.5 indicate the base fee is likely to fall.
  • Omitting rewardPercentiles returns a lighter response without the reward array — useful when you only need base-fee trends.
  • All wei amounts (base fees and rewards) are hex strings; convert with base 16 before arithmetic. gasUsedRatio is already a decimal number.
  • eth_feeHistory is available on the free tier (eth_read_rpc category). Rate limiting is RPS-per-tier with burst; there is no daily quota. A -32003 rate_limited error means you should back off and retry shortly.
  • For a single spot price instead of a window, see eth_gasPrice. To learn the current chain head before requesting a historical window, see eth_blockNumber.