Gas API
Get gas prices, estimate transaction costs, and track historical gas data across all supported EVM chains.
Endpoints
Get Current Gas Prices
GET /v1/blockchain/{chain}/gas
Returns current gas prices for EVM chains.
Request
curl -H "X-API-Key: YOUR_KEY" \
https://api.axol.io/api/v1/blockchain/ethereum/gas
Response
{
"success": true,
"data": {
"chain": "ethereum",
"block_number": 19500000,
"timestamp": "2026-01-15T10:30:00Z",
"slow": 20,
"standard": 25,
"fast": 30,
"instant": 40,
"base_fee": 18,
"suggested_tip": {
"slow": 2,
"standard": 7,
"fast": 12,
"instant": 22
}
},
"metadata": {
"cached": true,
"cache_ttl": 3
}
}
Supported Chains
- ethereum
- polygon
- arbitrum
- optimism
- base
- gnosis
- avalanche
Get Gas History
GET /v1/blockchain/{chain}/gas/history
Returns historical gas data.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
hours | int | Hours of history (default 24, max 168) |
resolution | string | Data resolution (1m, 5m, 15m, 1h) |
Response
{
"success": true,
"data": {
"chain": "ethereum",
"history": [
{
"timestamp": "2026-01-15T09:00:00Z",
"avg_gas": 25,
"min_gas": 18,
"max_gas": 45,
"base_fee": 20
},
{
"timestamp": "2026-01-15T10:00:00Z",
"avg_gas": 28,
"min_gas": 20,
"max_gas": 50,
"base_fee": 22
}
]
}
}
Compare Gas Across Chains
GET /v1/gas/compare
Compare gas prices across multiple chains.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
chains | string | Comma-separated chain list |
Response
{
"success": true,
"data": {
"timestamp": "2026-01-15T10:30:00Z",
"prices": {
"ethereum": {"fast": 30, "usd_per_transfer": 2.50},
"polygon": {"fast": 100, "usd_per_transfer": 0.02},
"arbitrum": {"fast": 0.1, "usd_per_transfer": 0.15},
"optimism": {"fast": 0.001, "usd_per_transfer": 0.08},
"base": {"fast": 0.001, "usd_per_transfer": 0.05}
},
"cheapest": "base",
"eth_price_usd": 3000
}
}
Estimate Gas
POST /v1/gas/estimate
Estimate gas for a transaction.
Request
{
"chain": "ethereum",
"from": "0x123...",
"to": "0x456...",
"value": "1000000000000000000",
"data": "0x..."
}
Response
{
"success": true,
"data": {
"gas_limit": 21000,
"estimated_cost": {
"slow": {
"gas_gwei": 20,
"total_eth": "0.00042",
"total_usd": "1.26"
},
"fast": {
"gas_gwei": 30,
"total_eth": "0.00063",
"total_usd": "1.89"
}
}
}
}
Code Examples
Python - Gas Tracker
import requests
from dataclasses import dataclass
@dataclass
class GasPrice:
slow: float
standard: float
fast: float
instant: float
base_fee: float
class GasTracker:
def __init__(self, api_key: str):
self.api_key = api_key
self.base_url = "https://api.axol.io/api/v1"
def get_gas(self, chain: str) -> GasPrice:
response = requests.get(
f"{self.base_url}/blockchain/{chain}/gas",
headers={"X-API-Key": self.api_key}
)
data = response.json()["data"]
return GasPrice(
slow=data["slow"],
standard=data["standard"],
fast=data["fast"],
instant=data["instant"],
base_fee=data["base_fee"]
)
def find_cheapest_chain(self, chains: list[str]) -> tuple[str, float]:
response = requests.get(
f"{self.base_url}/gas/compare",
headers={"X-API-Key": self.api_key},
params={"chains": ",".join(chains)}
)
data = response.json()["data"]
return data["cheapest"], data["prices"][data["cheapest"]]["fast"]
# Usage
tracker = GasTracker(api_key="YOUR_KEY")
# Get Ethereum gas
eth_gas = tracker.get_gas("ethereum")
print(f"ETH Fast: {eth_gas.fast} gwei")
# Find cheapest L2
cheapest, price = tracker.find_cheapest_chain(
["arbitrum", "optimism", "base", "polygon"]
)
print(f"Cheapest: {cheapest} at {price} gwei")
TypeScript - Gas Alert
interface GasAlert {
chain: string;
threshold: number;
callback: (price: number) => void;
}
class GasMonitor {
private apiKey: string;
private baseUrl = 'https://api.axol.io/api/v1';
private alerts: GasAlert[] = [];
private intervalId?: NodeJS.Timeout;
constructor(apiKey: string) {
this.apiKey = apiKey;
}
addAlert(chain: string, threshold: number, callback: (price: number) => void) {
this.alerts.push({ chain, threshold, callback });
}
async checkGas(chain: string): Promise<number> {
const response = await fetch(
`${this.baseUrl}/blockchain/${chain}/gas`,
{ headers: { 'X-API-Key': this.apiKey } }
);
const data = await response.json();
return data.data.fast;
}
start(intervalMs = 10000) {
this.intervalId = setInterval(async () => {
for (const alert of this.alerts) {
const price = await this.checkGas(alert.chain);
if (price <= alert.threshold) {
alert.callback(price);
}
}
}, intervalMs);
}
stop() {
if (this.intervalId) {
clearInterval(this.intervalId);
}
}
}
// Usage
const monitor = new GasMonitor(process.env.AXOL_API_KEY!);
monitor.addAlert('ethereum', 25, (price) => {
console.log(`ETH gas is low: ${price} gwei - time to transact!`);
});
monitor.start();
Best Practices
1. Choose the Right Tier
| Use Case | Recommended Tier |
|---|---|
| Time-sensitive arbitrage | instant |
| Normal DeFi operations | fast |
| Regular transfers | standard |
| Non-urgent batch operations | slow |
2. Monitor Base Fee Trends
history = requests.get(
f"{BASE_URL}/blockchain/ethereum/gas/history",
params={"hours": 24, "resolution": "1h"}
)
# Find typical low-gas periods
for entry in history.json()["data"]["history"]:
if entry["avg_gas"] < 20:
print(f"Low gas at {entry['timestamp']}")
3. Use L2s for Cost Savings
Compare costs before choosing a chain:
comparison = tracker.find_cheapest_chain([
"ethereum", "arbitrum", "optimism", "base", "polygon"
])
if comparison["cheapest"] != "ethereum":
print(f"Save money by using {comparison['cheapest']}")
See Also
- Oracle API - MEV-focused gas oracle
- Unified Pattern - API structure
- Supported Chains - Chain list