Get the base fee percentile
Returns the base fee percentile (50th percentile) of the specified blockchain network.
For example, if the API returns a value of 20
GWEI, it means that 50% of the historical base fees are less than or equal to
20
GWEI.
This can be useful for users or applications to estimate the optimal gas price for transactions based on historical data.
GET https://gas.api.infura.io/networks/${chainId}/baseFeePercentile
Parameters
Path:
chainId
: string - ID of the chain to query.
Returns
baseFeePercentile
: string - The base fee in Gwei at the 50th percentile, meaning that 50% of the base fees are
less than or equal to the provided amount.
Example
Request
Include your API key and optional API key secret to use the API.
You can call the API with only an API key, and include it as a path parameter
instead of using the cURL authentication option (-u
).
- cURL
- JavaScript
curl -X 'GET' \
-u <API-KEY>:<API-KEY-SECRET> \
'https://gas.api.infura.io/networks/1/baseFeePercentile'
const axios = require("axios");
const apiKey = '<API-KEY>'; // replace with your API key
const apiKeySecret = '<API-KEY-SECRET>'; // replace with your API key secret
const Auth = Buffer.from(
apiKey + ":" + apiKeySecret,
).toString("base64");
// The chain ID of the supported network
const chainId = 1;
(async () => {
try {
const { data } = await axios.get(
`https://gas.api.infura.io/networks/${chainId}/baseFeePercentile`,
{
headers: {
Authorization: `Basic ${Auth}`,
},
},
);
console.log("Base fee history:", data);
} catch (error) {
console.log("Server responded with:", error);
}
})();
Response
{
"baseFeePercentile": "23.227829059"
}