{
 "openapi": "3.1.0",
 "info": {
  "title": "Konfirm API",
  "version": "1.0.0-beta",
  "description": "Read-only Bitcoin and Ethereum fee estimates and transaction diagnostics. No key during the beta; send a descriptive User-Agent (Cloudflare blocks some library defaults, error 1010). Per-IP limits: fees 120/min, tx lookups 20/min, diagnose 60/min. Fee estimates are experimental and carry no confirmation probability. CORS: open (*) on fees, fees/history, status, health, openapi.json and /rpc; tx and diagnose routes only for allowlisted origins (KONFIRM_TX_CORS_ORIGINS). EVM chains: eth (chain id 1), polygon (137), base (8453), avalanche (43114); a tip at the node's floor is used on Polygon, Base and Avalanche while their blocks have room."
 },
 "servers": [
  {
   "url": "https://konfirm.kha.do"
  }
 ],
 "paths": {
  "/api/v1/btc/fees": {
   "get": {
    "summary": "Bitcoin fee rates (sat/vB) for 1, 2, 3 and 6 blocks, with baselines",
    "parameters": [
     {
      "name": "targets",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "example": "1,3"
      },
      "description": "Comma list of 1, 2, 3, 6 (default all)."
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/BtcFees"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (ETag)"
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/eth/fees": {
   "get": {
    "summary": "Ethereum base fee and slow / standard / fast tip and max fee (gwei)",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/EthFees"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (ETag)"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/btc/fees/history": {
   "get": {
    "summary": "Model fee rates over the last hours (chart data)",
    "responses": {
     "200": {
      "description": "OK"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/eth/fees/history": {
   "get": {
    "summary": "ETH model tips over the last hours (chart data)",
    "responses": {
     "200": {
      "description": "OK"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/btc/tx/{txid}": {
   "get": {
    "summary": "State and diagnosis of a Bitcoin transaction",
    "parameters": [
     {
      "name": "txid",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[0-9a-fA-F]{64}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/eth/tx/{hash}": {
   "get": {
    "summary": "State and diagnosis of an Ethereum transaction",
    "parameters": [
     {
      "name": "hash",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^0x[0-9a-fA-F]{64}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/status": {
   "get": {
    "summary": "Freshness and health of every data source",
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/api/v1/health": {
   "get": {
    "summary": "Liveness",
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/rpc/btc": {
   "post": {
    "summary": "Bitcoin Core compatible JSON-RPC (fee methods only)",
    "description": "Methods: estimatesmartfee conf_target [estimate_mode] -> {feerate (BTC/kvB), blocks}; getblockcount; getbestblockhash. Without a tier, conf_target maps to the largest Konfirm target <= it (1, 2, 3, 6). estimate_mode is accepted and ignored. Stale data returns {errors, blocks: 0}. JSON-RPC 1.0 and 2.0, batches up to 20; HTTP 200 for every parsed request.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "estimatesmartfee",
        "params": [
         3
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/rpc/btc/{tier}": {
   "post": {
    "summary": "Bitcoin Core compatible JSON-RPC with a fixed tier (fast 1, standard 3, slow 6 blocks; overrides conf_target)",
    "parameters": [
     {
      "name": "tier",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "fast",
        "standard",
        "slow"
       ]
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "method": "estimatesmartfee",
        "params": [
         6
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "404": {
      "description": "Unknown tier"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/rpc/eth": {
   "post": {
    "summary": "Ethereum JSON-RPC (fee methods only, standard tier)",
    "description": "Methods: eth_gasPrice (next base fee + tip, wei hex), eth_maxPriorityFeePerGas, eth_blockNumber, eth_chainId, net_version. Other methods return -32601; nothing is proxied or broadcast. Stale data returns -32000. Also ?tier=fast|standard|slow.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_maxPriorityFeePerGas"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/rpc/eth/{tier}": {
   "post": {
    "summary": "Ethereum JSON-RPC with a fixed tier",
    "parameters": [
     {
      "name": "tier",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "fast",
        "standard",
        "slow"
       ]
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_gasPrice"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "404": {
      "description": "Unknown tier"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/btc/diagnose": {
   "post": {
    "summary": "Diagnose Bitcoin transaction data the caller fetched itself (used by the web page; no upstream calls)",
    "description": "Body: the raw provider responses for the transaction, as the web page sends them. Prefer GET /api/v1/btc/tx/{id} from scripts.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Invalid body"
     },
     "429": {
      "description": "Rate limited"
     }
    }
   }
  },
  "/api/v1/eth/diagnose": {
   "post": {
    "summary": "Diagnose Ethereum transaction data the caller fetched itself (used by the web page; no upstream calls)",
    "description": "Body: the raw provider responses for the transaction, as the web page sends them. Prefer GET /api/v1/eth/tx/{id} from scripts.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Invalid body"
     },
     "429": {
      "description": "Rate limited"
     }
    }
   }
  },
  "/api/v1/polygon/fees": {
   "get": {
    "summary": "Polygon PoS base fee and slow / standard / fast tip and max fee (gwei) Amounts in POL.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/EthFees"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (ETag)"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/polygon/fees/history": {
   "get": {
    "summary": "Polygon PoS model tips over the last hours (chart data)",
    "responses": {
     "200": {
      "description": "OK"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/polygon/tx/{hash}": {
   "get": {
    "summary": "State and diagnosis of an Polygon PoS transaction",
    "parameters": [
     {
      "name": "hash",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^0x[0-9a-fA-F]{64}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/polygon/diagnose": {
   "post": {
    "summary": "Diagnose Polygon PoS transaction data the caller fetched itself (used by the web page; no upstream calls)",
    "description": "Body: the raw provider responses for the transaction, as the web page sends them. Prefer GET /api/v1/eth/tx/{id} from scripts.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Invalid body"
     },
     "429": {
      "description": "Rate limited"
     }
    }
   }
  },
  "/rpc/polygon": {
   "post": {
    "summary": "Polygon PoS JSON-RPC (fee methods only, standard tier)",
    "description": "Methods: eth_gasPrice (next base fee + tip, wei hex), eth_maxPriorityFeePerGas, eth_blockNumber, eth_chainId, net_version. Other methods return -32601; nothing is proxied or broadcast. Stale data returns -32000. Also ?tier=fast|standard|slow.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_maxPriorityFeePerGas"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/rpc/polygon/{tier}": {
   "post": {
    "summary": "Polygon PoS JSON-RPC with a fixed tier",
    "parameters": [
     {
      "name": "tier",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "fast",
        "standard",
        "slow"
       ]
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_gasPrice"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "404": {
      "description": "Unknown tier"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/base/fees": {
   "get": {
    "summary": "Base base fee and slow / standard / fast tip and max fee (gwei). Adds l1_data_fee: the OP-stack L1 data fee per example transaction (upper bound, ETH).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/EthFees"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (ETag)"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/base/fees/history": {
   "get": {
    "summary": "Base model tips over the last hours (chart data)",
    "responses": {
     "200": {
      "description": "OK"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/base/tx/{hash}": {
   "get": {
    "summary": "State and diagnosis of an Base transaction",
    "parameters": [
     {
      "name": "hash",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^0x[0-9a-fA-F]{64}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/base/diagnose": {
   "post": {
    "summary": "Diagnose Base transaction data the caller fetched itself (used by the web page; no upstream calls)",
    "description": "Body: the raw provider responses for the transaction, as the web page sends them. Prefer GET /api/v1/eth/tx/{id} from scripts.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Invalid body"
     },
     "429": {
      "description": "Rate limited"
     }
    }
   }
  },
  "/rpc/base": {
   "post": {
    "summary": "Base JSON-RPC (fee methods only, standard tier)",
    "description": "Methods: eth_gasPrice (next base fee + tip, wei hex), eth_maxPriorityFeePerGas, eth_blockNumber, eth_chainId, net_version. Other methods return -32601; nothing is proxied or broadcast. Stale data returns -32000. Also ?tier=fast|standard|slow.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_maxPriorityFeePerGas"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/rpc/base/{tier}": {
   "post": {
    "summary": "Base JSON-RPC with a fixed tier",
    "parameters": [
     {
      "name": "tier",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "fast",
        "standard",
        "slow"
       ]
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_gasPrice"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "404": {
      "description": "Unknown tier"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/esplora/fee-estimates": {
   "get": {
    "summary": "Esplora-compatible fee estimates: {\"<target>\": sat/vB} for targets 1-25, 144, 504, 1008 (each uses Konfirm's largest target <= it: 1, 2, 3, 6)",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": {
          "type": "number"
         }
        }
       }
      }
     },
     "503": {
      "description": "No fresh data"
     }
    }
   }
  },
  "/api/v1/avalanche/fees": {
   "get": {
    "summary": "Avalanche C-Chain base fee and slow / standard / fast tip and max fee (gwei)",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/EthFees"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (ETag)"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/avalanche/fees/history": {
   "get": {
    "summary": "ETH model tips over the last hours (chart data)",
    "responses": {
     "200": {
      "description": "OK"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/avalanche/tx/{hash}": {
   "get": {
    "summary": "State and diagnosis of an Avalanche C-Chain transaction",
    "parameters": [
     {
      "name": "hash",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^0x[0-9a-fA-F]{64}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/avalanche/diagnose": {
   "post": {
    "summary": "Diagnose Avalanche C-Chain transaction data the caller fetched itself (used by the web page; no upstream calls)",
    "description": "Body: the raw provider responses for the transaction, as the web page sends them. Prefer GET /api/v1/eth/tx/{id} from scripts.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TxResult"
        }
       }
      }
     },
     "400": {
      "description": "Invalid body"
     },
     "429": {
      "description": "Rate limited"
     }
    }
   }
  },
  "/rpc/avalanche": {
   "post": {
    "summary": "Avalanche C-Chain JSON-RPC (fee methods only, standard tier)",
    "description": "Methods: eth_gasPrice (next base fee + tip, wei hex), eth_maxPriorityFeePerGas, eth_blockNumber, eth_chainId, net_version. Other methods return -32601; nothing is proxied or broadcast. Stale data returns -32000. Also ?tier=fast|standard|slow.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_maxPriorityFeePerGas"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/rpc/avalanche/{tier}": {
   "post": {
    "summary": "Avalanche C-Chain JSON-RPC with a fixed tier",
    "parameters": [
     {
      "name": "tier",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "fast",
        "standard",
        "slow"
       ]
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/RpcRequest"
         },
         {
          "type": "array",
          "maxItems": 20,
          "items": {
           "$ref": "#/components/schemas/RpcRequest"
          }
         }
        ]
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_gasPrice"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RpcResponse"
        }
       }
      }
     },
     "404": {
      "description": "Unknown tier"
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       },
       "retryable": {
        "type": "boolean"
       }
      }
     },
     "request_id": {
      "type": "string"
     }
    }
   },
   "BtcFees": {
    "type": "object",
    "properties": {
     "chain": {
      "type": "string"
     },
     "network": {
      "type": "string"
     },
     "unit": {
      "const": "sat/vB"
     },
     "as_of": {
      "type": "string",
      "format": "date-time"
     },
     "provider": {
      "type": "string"
     },
     "tip_height": {
      "type": "integer"
     },
     "tip_hash": {
      "type": "string"
     },
     "stale": {
      "type": "boolean"
     },
     "model": {
      "type": "object",
      "properties": {
       "id": {
        "type": "string"
       },
       "version": {
        "type": "string"
       }
      }
     },
     "mempool": {
      "type": [
       "object",
       "null"
      ],
      "properties": {
       "vsize": {
        "type": "integer"
       },
       "count": {
        "type": "integer"
       }
      }
     },
     "recommendations": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "target_blocks": {
         "type": "integer"
        },
        "fee_rate": {
         "type": "number"
        },
        "probability": {
         "type": [
          "number",
          "null"
         ]
        },
        "quality": {
         "type": "string"
        }
       }
      }
     },
     "baselines": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "name": {
         "type": "string"
        },
        "target_blocks": {
         "type": "integer"
        },
        "fee_rate": {
         "type": "number"
        },
        "method": {
         "type": "string"
        }
       }
      }
     },
     "disclaimer": {
      "type": "string"
     },
     "congestion": {
      "$ref": "#/components/schemas/Congestion"
     }
    }
   },
   "EthFees": {
    "type": "object",
    "properties": {
     "chain": {
      "type": "string"
     },
     "network": {
      "type": "string"
     },
     "unit": {
      "const": "gwei"
     },
     "as_of": {
      "type": "string",
      "format": "date-time"
     },
     "provider": {
      "type": "string"
     },
     "block_number": {
      "type": "integer"
     },
     "base_fee_per_gas": {
      "type": "number"
     },
     "next_base_fee_per_gas": {
      "type": "number"
     },
     "stale": {
      "type": "boolean"
     },
     "recommendations": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "urgency": {
         "enum": [
          "slow",
          "standard",
          "fast"
         ]
        },
        "target_blocks": {
         "type": "integer"
        },
        "max_priority_fee_per_gas": {
         "type": "number"
        },
        "max_fee_per_gas": {
         "type": "number"
        },
        "probability": {
         "type": [
          "number",
          "null"
         ]
        }
       }
      }
     },
     "disclaimer": {
      "type": "string"
     },
     "congestion": {
      "$ref": "#/components/schemas/Congestion"
     }
    }
   },
   "TxResult": {
    "type": "object",
    "properties": {
     "chain": {
      "type": "string"
     },
     "txid": {
      "type": "string"
     },
     "hash": {
      "type": "string"
     },
     "state": {
      "enum": [
       "pending",
       "confirmed",
       "confirmed_success",
       "confirmed_reverted",
       "not_found",
       "replaced_or_conflicted",
       "unknown"
      ]
     },
     "observed_at": {
      "type": "string"
     },
     "stale": {
      "type": "boolean"
     },
     "provider": {
      "type": "string"
     },
     "transaction": {
      "type": [
       "object",
       "null"
      ]
     },
     "fee_context": {
      "type": [
       "object",
       "null"
      ]
     },
     "estimate": {
      "type": "object"
     },
     "replacement_txid": {
      "type": "string"
     },
     "diagnosis": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string"
       },
       "severity": {
        "enum": [
         "info",
         "warning",
         "critical"
        ]
       },
       "certainty": {
        "enum": [
         "observed",
         "estimated",
         "insufficient_data"
        ]
       },
       "summary": {
        "type": "string"
       },
       "evidence": {
        "type": "array",
        "items": {
         "type": "object"
        }
       },
       "recommended_actions": {
        "type": "array",
        "items": {
         "type": "string"
        }
       },
       "guidance": {
        "type": "array",
        "items": {
         "type": "object"
        }
       },
       "limitations": {
        "type": "array",
        "items": {
         "type": "string"
        }
       }
      }
     }
    }
   },
   "RpcRequest": {
    "type": "object",
    "required": [
     "method"
    ],
    "properties": {
     "jsonrpc": {
      "const": "2.0"
     },
     "id": {},
     "method": {
      "type": "string"
     },
     "params": {
      "type": "array"
     }
    }
   },
   "RpcResponse": {
    "type": "object",
    "properties": {
     "jsonrpc": {
      "type": "string"
     },
     "id": {},
     "result": {},
     "error": {
      "type": [
       "object",
       "null"
      ],
      "properties": {
       "code": {
        "type": "integer"
       },
       "message": {
        "type": "string"
       }
      }
     }
    }
   },
   "Congestion": {
    "type": [
     "object",
     "null"
    ],
    "description": "Plain-language network pressure, descriptive only (never changes a recommendation). Bitcoin: from the next projected block (room left; median >= 2 sat/vB busy, >= 10 congested). EVM: base fee rise over the fee history (~20 blocks): +25% busy, doubled congested (block fill is reported in inputs, not judged).",
    "properties": {
     "level": {
      "type": "string",
      "enum": [
       "normal",
       "busy",
       "congested"
      ]
     },
     "reason": {
      "type": "string"
     },
     "inputs": {
      "type": "object",
      "additionalProperties": {
       "type": "number"
      }
     }
    }
   }
  }
 }
}