{
  "openapi": "3.1.1",
  "info": {
    "title": "Gas Fee Intelligence Explorer API",
    "version": "1.0.0",
    "summary": "Live gas on 7 EVM chains: base fee, tips, trend and the USD cost of transfers and swaps.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://gasfeeintelligenceexplorer.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Live gas on 7 EVM chains: base fee, tips, trend and the USD cost of transfers and swaps.",
        "description": "Pulls eth_feeHistory (last 100 blocks, 10th/50th/90th percentile tips) and eth_gasPrice from Ethereum, Base, Arbitrum, OP Mainnet, Polygon, Avalanche and BNB Chain, prices the native tokens via DefiLlama and shows what a native transfer, ERC-20 transfer and swap cost on each chain — ranked cheapest first, with OP Stack L1 data fees as an upper bound.\n\nMethodology:\n- eth_feeHistory(blockCount, \"latest\", [10, 50, 90]) per chain: base fee per block (the last entry is the next block's base fee) and the 10th/50th/90th percentile priority fee of each block; the tool takes the median of each percentile across blocks.\n- Price tiers = next base fee + median p10 (slow) / p50 (standard) / p90 (fast) tip. Chains without a base fee use eth_gasPrice. Trend compares the average base fee of the newest fifth of blocks with the oldest fifth (±15 %).\n- Operation costs use typical gas amounts — native transfer 21,000 (exact), ERC-20 transfer ≈ 65,000, DEX swap ≈ 150,000 (estimates; real usage varies by contract and state) — times the standard tier.\n- USD: native token prices from the DefiLlama coins API (coingecko:ethereum, polygon-ecosystem-token, avalanche-2, binancecoin).\n- L2 data fees: on Base and OP Mainnet the OP Stack GasPriceOracle (0x4200…000F) getL1FeeUpperBound(size) is added as an upper bound using approximate transaction sizes (50 / 120 / 350 bytes unsigned). Arbitrum's L1 component is not included (it is folded into gas used at execution time and needs a per-transaction estimate).",
        "tags": [
          "web3"
        ],
        "x-mcp-tool": "gas_fee_intelligence_explorer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GasFeeIntelligenceExplorerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Ethereum vs Base vs Polygon from pasted data (offline)",
                  "value": {
                    "mode": "pasted",
                    "pasted": "{\"prices\":{\"ETH\":2400,\"POL\":0.25,\"BNB\":600},\"chains\":{\"ethereum\":{\"gasPrice\":\"0x77359400\",\"feeHistory\":{\"oldestBlock\":\"0x1406f40\",\"baseFeePerGas\":[\"0x6fc23ac00\",\"0x77359400\",\"0x6fc23ac00\",\"0x684ee1800\",\"0x6fc23ac00\",\"0x74a3df240\"],\"gasUsedRatio\":[0.62,0.41,0.38,0.55,0.6],\"reward\":[[\"0x3b9aca0\",\"0x5f5e100\",\"0x77359400\"],[\"0x2faf080\",\"0x5f5e100\",\"0x3b9aca00\"],[\"0x0\",\"0x3b9aca0\",\"0x77359400\"],[\"0x2faf080\",\"0x5f5e100\",\"0x3b9aca00\"],[\"0x3b9aca0\",\"0x77359400\",\"0xb2d05e00\"]]}},\"base\":{\"gasPrice\":\"0x1312d00\",\"feeHistory\":{\"oldestBlock\":\"0x16e3600\",\"baseFeePerGas\":[\"0xf4240\",\"0xf4240\",\"0x10c8e0\",\"0xf4240\",\"0xe4e1c\",\"0xf4240\"],\"gasUsedRatio\":[0.31,0.29,0.35,0.3,0.28],\"reward\":[[\"0x0\",\"0xf4240\",\"0x989680\"],[\"0x0\",\"0xf4240\",\"0x989680\"],[\"0x0\",\"0xf4240\",\"0x1312d00\"],[\"0x0\",\"0xf4240\",\"0x989680\"],[\"0x0\",\"0x7a120\",\"0x989680\"]]},\"l1FeeUpperBoundWei\":{\"eth-transfer\":\"0x9184e72a00\",\"erc20-transfer\":\"0xdf8475800\",\"swap\":\"0x2540be400\"}},\"polygon\":{\"gasPrice\":\"0x6fc23ac000\",\"feeHistory\":{\"oldestBlock\":\"0x4c4b400\",\"baseFeePerGas\":[\"0x5d21dba000\",\"0x5d21dba000\",\"0x5d21dba000\",\"0x5d21dba000\",\"0x5d21dba000\",\"0x5d21dba000\"],\"gasUsedRatio\":[0.5,0.48,0.52,0.51,0.5],\"reward\":[[\"0x6fc23ac00\",\"0x6fc23ac00\",\"0x1176592e00\"],[\"0x6fc23ac00\",\"0x6fc23ac00\",\"0x1176592e00\"],[\"0x6fc23ac00\",\"0x6fc23ac00\",\"0x1176592e00\"],[\"0x6fc23ac00\",\"0x6fc23ac00\",\"0x1176592e00\"],[\"0x6fc23ac00\",\"0x6fc23ac00\",\"0x1176592e00\"]]}}}}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GasFeeIntelligenceExplorerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "GasFeeIntelligenceExplorerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Data source",
            "type": "string",
            "enum": [
              "live",
              "pasted"
            ],
            "default": "live"
          },
          "chains": {
            "title": "Chains",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "ethereum",
                "base",
                "arbitrum",
                "optimism",
                "polygon",
                "avalanche",
                "bsc"
              ]
            },
            "default": [
              "ethereum",
              "base",
              "arbitrum",
              "optimism",
              "polygon",
              "avalanche",
              "bsc"
            ]
          },
          "blocks": {
            "title": "Blocks of fee history",
            "type": "integer",
            "minimum": 10,
            "maximum": 100,
            "default": 100
          },
          "pasted": {
            "title": "Pasted JSON",
            "description": "{\"prices\":{\"ETH\":2400},\"chains\":{\"ethereum\":{\"feeHistory\":{…eth_feeHistory result…},\"gasPrice\":\"0x…\",\"l1FeeUpperBoundWei\":{\"erc20-transfer\":\"0x…\"}}}}",
            "type": "string",
            "maxLength": 1000000
          }
        },
        "required": []
      },
      "GasFeeIntelligenceExplorerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "mode",
              "chains",
              "ranking",
              "operations"
            ],
            "properties": {
              "mode": {
                "type": "string"
              },
              "chains": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "chain",
                    "name",
                    "native",
                    "priceUsd",
                    "oldestBlock",
                    "newestBlock",
                    "blocks",
                    "baseFeeGwei",
                    "priorityGwei",
                    "gasPriceGwei",
                    "avgGasUsedRatio",
                    "trend",
                    "tiersGwei",
                    "operations",
                    "l1DataFee",
                    "error"
                  ],
                  "properties": {
                    "chain": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "native": {
                      "type": "string"
                    },
                    "priceUsd": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "oldestBlock": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "newestBlock": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "blocks": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "baseFeeGwei": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "additionalProperties": false,
                      "required": [
                        "next",
                        "min",
                        "avg",
                        "max"
                      ],
                      "properties": {
                        "next": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "avg": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        }
                      }
                    },
                    "priorityGwei": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "additionalProperties": false,
                      "required": [
                        "p10",
                        "p50",
                        "p90"
                      ],
                      "properties": {
                        "p10": {
                          "type": "number"
                        },
                        "p50": {
                          "type": "number"
                        },
                        "p90": {
                          "type": "number"
                        }
                      }
                    },
                    "gasPriceGwei": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "avgGasUsedRatio": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "trend": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tiersGwei": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "additionalProperties": false,
                      "required": [
                        "slow",
                        "standard",
                        "fast"
                      ],
                      "properties": {
                        "slow": {
                          "type": "number"
                        },
                        "standard": {
                          "type": "number"
                        },
                        "fast": {
                          "type": "number"
                        }
                      }
                    },
                    "operations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "operation",
                          "gas",
                          "executionNative",
                          "l1DataFeeNative",
                          "totalNative",
                          "totalUsd"
                        ],
                        "properties": {
                          "operation": {
                            "type": "string"
                          },
                          "gas": {
                            "type": "integer"
                          },
                          "executionNative": {
                            "type": "number"
                          },
                          "l1DataFeeNative": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "totalNative": {
                            "type": "number"
                          },
                          "totalUsd": {
                            "type": [
                              "number",
                              "null"
                            ]
                          }
                        }
                      }
                    },
                    "l1DataFee": {
                      "type": "string",
                      "enum": [
                        "included-upper-bound",
                        "not-included",
                        "not-applicable"
                      ]
                    },
                    "error": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "ranking": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "rank",
                    "chain",
                    "erc20TransferUsd",
                    "erc20TransferNative"
                  ],
                  "properties": {
                    "rank": {
                      "type": "integer"
                    },
                    "chain": {
                      "type": "string"
                    },
                    "erc20TransferUsd": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "erc20TransferNative": {
                      "type": "number"
                    }
                  }
                }
              },
              "operations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "label",
                    "gas"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "gas": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}