{
  "openapi": "3.0.3",
  "info": {
    "title": "M3terstate Indexer API",
    "version": "1.2.0",
    "description": "Indexed routes read the configured M3tering stream from PostgreSQL. /v1/etherscan/events is a raw Etherscan proxy with overridable query defaults and bounded caching. Indexed event decoding is unchanged."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "tags": [
    {
      "name": "Indexer"
    },
    {
      "name": "Operations"
    }
  ],
  "paths": {
    "/live": {
      "get": {
        "operationId": "getLiveness",
        "summary": "Process liveness",
        "description": "",
        "tags": [
          "Operations"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/ready": {
      "get": {
        "operationId": "getReadiness",
        "summary": "Database and indexing freshness readiness",
        "description": "503 until a successful poll; also 503 on last poll failure or a successful poll older than max(3*POLL_INTERVAL,1h).",
        "tags": [
          "Operations"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/status": {
      "get": {
        "operationId": "getIndexerStatus",
        "summary": "Durable stream progress",
        "description": "",
        "tags": [
          "Operations"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/events": {
      "get": {
        "operationId": "listEvents",
        "summary": "List indexed events with decoded meter state",
        "description": "Results come exclusively from PostgreSQL. Blocks and numeric quantities are decimal strings. Stable ordering uses block number then block-wide log index. No API key, module, or action parameters are accepted. Each event includes words[].meters[] with meterId, cumulative accountWh, and nonce, matching the single-event endpoint. Accounts are whole watt-hours, not milliwatt-hours.",
        "tags": [
          "Indexer"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/fromBlock"
          },
          {
            "$ref": "#/components/parameters/toBlock"
          },
          {
            "$ref": "#/components/parameters/chainid"
          },
          {
            "$ref": "#/components/parameters/address"
          },
          {
            "$ref": "#/components/parameters/topic0"
          },
          {
            "$ref": "#/components/parameters/topic1"
          },
          {
            "$ref": "#/components/parameters/topic2"
          },
          {
            "$ref": "#/components/parameters/topic3"
          },
          {
            "$ref": "#/components/parameters/topic0_1_opr"
          },
          {
            "$ref": "#/components/parameters/topic0_2_opr"
          },
          {
            "$ref": "#/components/parameters/topic0_3_opr"
          },
          {
            "$ref": "#/components/parameters/topic1_2_opr"
          },
          {
            "$ref": "#/components/parameters/topic1_3_opr"
          },
          {
            "$ref": "#/components/parameters/topic2_3_opr"
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/offset"
          },
          {
            "$ref": "#/components/parameters/sort"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/events/{transactionHash}/{logIndex}": {
      "get": {
        "operationId": "getEvent",
        "summary": "Get a commit and its decoded word replacements",
        "description": "",
        "tags": [
          "Indexer"
        ],
        "parameters": [
          {
            "name": "transactionHash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{64}$"
            },
            "description": "Transaction hash"
          },
          {
            "name": "logIndex",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^([0-9]+|0x[0-9a-fA-F]+)$"
            },
            "description": "Block-wide log index"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventDetail"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/meters": {
      "get": {
        "operationId": "listMeters",
        "summary": "List materialized current meters",
        "description": "Filters apply to the event that last replaced the current meter. toBlock does not reconstruct historical state. All four lanes of changed words are materialized, including zero lanes.",
        "tags": [
          "Indexer"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/fromBlock"
          },
          {
            "$ref": "#/components/parameters/toBlock"
          },
          {
            "$ref": "#/components/parameters/chainid"
          },
          {
            "$ref": "#/components/parameters/address"
          },
          {
            "$ref": "#/components/parameters/topic0"
          },
          {
            "$ref": "#/components/parameters/topic1"
          },
          {
            "$ref": "#/components/parameters/topic2"
          },
          {
            "$ref": "#/components/parameters/topic3"
          },
          {
            "$ref": "#/components/parameters/topic0_1_opr"
          },
          {
            "$ref": "#/components/parameters/topic0_2_opr"
          },
          {
            "$ref": "#/components/parameters/topic0_3_opr"
          },
          {
            "$ref": "#/components/parameters/topic1_2_opr"
          },
          {
            "$ref": "#/components/parameters/topic1_3_opr"
          },
          {
            "$ref": "#/components/parameters/topic2_3_opr"
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/offset"
          },
          {
            "$ref": "#/components/parameters/sort"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/meters/{meterId}": {
      "get": {
        "operationId": "getMeter",
        "summary": "Get a materialized current meter",
        "description": "404 means no indexed word replacement exists for this meter; after a complete replay of a fresh deployment its implicit state is zero.",
        "tags": [
          "Indexer"
        ],
        "parameters": [
          {
            "name": "meterId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^([0-9]+|0x[0-9a-fA-F]+)$"
            },
            "description": "Meter ID, 0 through 17179869183"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentMeter"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/meters/{meterId}/history": {
      "get": {
        "operationId": "listMeterHistory",
        "summary": "List meter snapshots at word replacements",
        "description": "Includes unchanged lanes when another lane in the same word changed. Does not expose individual signed actions.",
        "tags": [
          "Indexer"
        ],
        "parameters": [
          {
            "name": "meterId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^([0-9]+|0x[0-9a-fA-F]+)$"
            },
            "description": "Meter ID, 0 through 17179869183"
          },
          {
            "$ref": "#/components/parameters/fromBlock"
          },
          {
            "$ref": "#/components/parameters/toBlock"
          },
          {
            "$ref": "#/components/parameters/chainid"
          },
          {
            "$ref": "#/components/parameters/address"
          },
          {
            "$ref": "#/components/parameters/topic0"
          },
          {
            "$ref": "#/components/parameters/topic1"
          },
          {
            "$ref": "#/components/parameters/topic2"
          },
          {
            "$ref": "#/components/parameters/topic3"
          },
          {
            "$ref": "#/components/parameters/topic0_1_opr"
          },
          {
            "$ref": "#/components/parameters/topic0_2_opr"
          },
          {
            "$ref": "#/components/parameters/topic0_3_opr"
          },
          {
            "$ref": "#/components/parameters/topic1_2_opr"
          },
          {
            "$ref": "#/components/parameters/topic1_3_opr"
          },
          {
            "$ref": "#/components/parameters/topic2_3_opr"
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/offset"
          },
          {
            "$ref": "#/components/parameters/sort"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/words/{slot}": {
      "get": {
        "operationId": "getWord",
        "summary": "Get a materialized current packed word",
        "description": "",
        "tags": [
          "Indexer"
        ],
        "parameters": [
          {
            "name": "slot",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^([0-9]+|0x[0-9a-fA-F]+)$"
            },
            "description": "Slot ID, 0 through 4294967295"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentWord"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or path parameter",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No indexed record",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Indexer not ready",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "504": {
            "description": "Database query timeout",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/etherscan/events": {
      "get": {
        "operationId": "listLiveEvents",
        "summary": "Proxy raw Etherscan responses with overridable query defaults",
        "tags": [
          "Etherscan"
        ],
        "description": "Supplied query parameters override defaults and are forwarded to ETHERSCAN_URL without stream matching, ABI validation, numeric normalization, or value checks. Additional parameters, empty values, and repeated values pass through. Defaults: module=logs, action=getLogs, configured chainid/address/topic0/fromBlock/apikey, toBlock=latest, page=1, offset=100. The upstream origin is fixed in server configuration. Returns upstream HTTP status and body unchanged, including status=0/NOTOK and HTTP errors. Preserves Content-Type and Retry-After. No head lookup, retries, extra pagination, decoding, DB writes, or cursor changes. Successful/empty getLogs responses are cached using the complete effective query; other actions and errors are not cached. Response body limit: 16 MiB. Local transport/capacity/configuration errors use problem JSON.",
        "parameters": [
          {
            "name": "chainid",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Defaults to server configuration when absent. Any supplied value overrides it; no configured-stream matching."
          },
          {
            "name": "address",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Defaults to server configuration when absent. Any supplied value overrides it; no configured-stream matching."
          },
          {
            "name": "topic0",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Defaults to server configuration when absent. Any supplied value overrides it; no configured-stream matching."
          },
          {
            "name": "fromBlock",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Defaults to server configuration when absent. Any supplied value overrides it; no configured-stream matching."
          },
          {
            "name": "toBlock",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string",
              "default": "latest"
            },
            "description": "Passed unchanged to Etherscan, which validates the value. Used only when absent; explicit empty values override the default."
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string",
              "default": "1"
            },
            "description": "Passed unchanged to Etherscan, which validates the value. Used only when absent; explicit empty values override the default."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string",
              "default": "100"
            },
            "description": "Passed unchanged to Etherscan, which validates the value. Used only when absent; explicit empty values override the default."
          },
          {
            "name": "topic1",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic2",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic3",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic0_1_opr",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic0_2_opr",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic0_3_opr",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic1_2_opr",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic1_3_opr",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "topic2_3_opr",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Passed unchanged to Etherscan, which validates the value."
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Forwarded unchanged when supplied; interpretation/support is decided by Etherscan."
          },
          {
            "name": "module",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string",
              "default": "logs"
            },
            "description": "Passed unchanged to Etherscan, which validates the value. Used only when absent; explicit empty values override the default."
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string",
              "default": "getLogs"
            },
            "description": "Passed unchanged to Etherscan, which validates the value. Used only when absent; explicit empty values override the default."
          },
          {
            "name": "apikey",
            "in": "query",
            "required": false,
            "allowEmptyValue": true,
            "schema": {
              "type": "string"
            },
            "description": "Overrides the server API_KEY when supplied; otherwise uses API_KEY. All effective parameters, including credentials, participate in the hashed cache key."
          }
        ],
        "responses": {
          "200": {
            "description": "Original upstream response, including HTTP-200 Etherscan error envelopes",
            "headers": {
              "X-Cache": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "HIT",
                    "MISS",
                    "SHARED"
                  ]
                },
                "description": "HIT: cached body; MISS: started fetch; SHARED: joined in-flight fetch."
              },
              "Age": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "Whole seconds since the upstream response was fetched."
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                },
                "description": "Browser/proxy storage disabled; application TTL controls caching."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EtherscanResponse"
                }
              },
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Malformed URL query encoding (local error); Etherscan can also return HTTP 400 with its own body",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              },
              "application/json": {
                "schema": {}
              },
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "Local transport/read failure or response exceeds 16 MiB; upstream HTTP 502 bodies also pass through",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              },
              "application/json": {
                "schema": {}
              },
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Local disabled/shutdown/capacity error; upstream HTTP 503 bodies also pass through",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              },
              "application/json": {
                "schema": {}
              },
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Local capacity rejection uses 1 second. An upstream Retry-After is passed through verbatim (seconds or HTTP date)."
              }
            }
          },
          "504": {
            "description": "Local proxy deadline exceeded; upstream HTTP 504 bodies also pass through",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              },
              "application/json": {
                "schema": {}
              },
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Upstream HTTP status and body are passed through, including errors and rate limits.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Forwarded from Etherscan if provided."
              }
            },
            "content": {
              "application/json": {
                "schema": {}
              },
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Meter": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "meterId": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Meter ID, 0 through 17179869183."
          },
          "accountWh": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Cumulative whole watt-hours, maximum 1099511627775."
          },
          "nonce": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Last accepted nonce, maximum 16777215."
          }
        },
        "required": [
          "meterId",
          "accountWh",
          "nonce"
        ]
      },
      "Word": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "slot": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "word": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "meters": {
            "type": "array",
            "minItems": 4,
            "maxItems": 4,
            "items": {
              "$ref": "#/components/schemas/Meter"
            }
          }
        },
        "required": [
          "slot",
          "word",
          "meters"
        ]
      },
      "Event": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "chainId": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "address": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{40}$"
          },
          "topics": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1,
            "items": {
              "type": "string",
              "pattern": "^0x[0-9a-f]{64}$"
            }
          },
          "data": {
            "type": "string",
            "pattern": "^0x([0-9a-fA-F]{2})*$",
            "description": "Full ABI-encoded event data."
          },
          "updates": {
            "type": "string",
            "pattern": "^0x([0-9a-fA-F]{2})*$",
            "description": "Unwrapped concatenated 36-byte replacements."
          },
          "blockNumber": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "blockHash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "timestamp": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Block Unix timestamp in seconds."
          },
          "transactionHash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "transactionIndex": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "logIndex": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "words": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/Word"
            },
            "description": "Sparse replacement words with all four decoded meter lanes, including unchanged and zero lanes."
          }
        },
        "required": [
          "chainId",
          "address",
          "topics",
          "data",
          "updates",
          "blockNumber",
          "blockHash",
          "timestamp",
          "transactionHash",
          "transactionIndex",
          "logIndex",
          "words"
        ]
      },
      "EventDetail": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "chainId": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "address": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{40}$"
          },
          "topics": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1,
            "items": {
              "type": "string",
              "pattern": "^0x[0-9a-f]{64}$"
            }
          },
          "data": {
            "type": "string",
            "pattern": "^0x([0-9a-fA-F]{2})*$",
            "description": "Full ABI-encoded event data."
          },
          "updates": {
            "type": "string",
            "pattern": "^0x([0-9a-fA-F]{2})*$",
            "description": "Unwrapped concatenated 36-byte replacements."
          },
          "blockNumber": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "blockHash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "timestamp": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Block Unix timestamp in seconds."
          },
          "transactionHash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "transactionIndex": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "logIndex": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "words": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/Word"
            },
            "description": "Sparse replacement words with all four decoded meter lanes, including unchanged and zero lanes."
          }
        },
        "required": [
          "chainId",
          "address",
          "topics",
          "data",
          "updates",
          "blockNumber",
          "blockHash",
          "timestamp",
          "transactionHash",
          "transactionIndex",
          "logIndex",
          "words"
        ]
      },
      "CurrentMeter": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "meterId": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Meter ID, 0 through 17179869183."
          },
          "accountWh": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Cumulative whole watt-hours, maximum 1099511627775."
          },
          "nonce": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Last accepted nonce, maximum 16777215."
          },
          "blockNumber": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "transactionHash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "logIndex": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          }
        },
        "required": [
          "meterId",
          "accountWh",
          "nonce",
          "blockNumber",
          "transactionHash",
          "logIndex"
        ]
      },
      "CurrentWord": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "slot": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "word": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "blockNumber": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "transactionHash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "logIndex": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          }
        },
        "required": [
          "slot",
          "word",
          "blockNumber",
          "transactionHash",
          "logIndex"
        ]
      },
      "Status": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "chainId": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "address": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{40}$"
          },
          "topic0": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "fromBlock": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "nextBlock": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string."
          },
          "scannedThrough": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string.",
            "nullable": true
          },
          "lastBlockHash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$",
            "nullable": true
          },
          "observedHead": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Unsigned decimal integer encoded as a string.",
            "nullable": true
          },
          "lastSuccessfulPoll": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "lastError": {
            "type": "string",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "chainId",
          "address",
          "topic0",
          "fromBlock",
          "nextBlock",
          "scannedThrough",
          "lastBlockHash",
          "observedHead",
          "lastSuccessfulPoll",
          "lastError",
          "updatedAt"
        ]
      },
      "Problem": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "detail",
          "requestId"
        ]
      },
      "Health": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "ready"
            ]
          }
        },
        "required": [
          "status"
        ]
      },
      "EventPage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "offset": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "data",
          "page",
          "offset",
          "hasMore"
        ]
      },
      "MeterPage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CurrentMeter"
            }
          },
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "offset": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "data",
          "page",
          "offset",
          "hasMore"
        ]
      },
      "EtherscanResponse": {
        "type": "object",
        "additionalProperties": true,
        "description": "Unmodified upstream JSON envelope. For logs, status=0 can mean either no records or a provider error. Additional fields and raw log values are preserved.",
        "properties": {
          "status": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "result": {
            "description": "Exactly the upstream result, usually an array of raw logs or an error string. No ABI decoding or quantity normalization."
          }
        }
      }
    },
    "parameters": {
      "fromBlock": {
        "name": "fromBlock",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^([0-9]+|0x[0-9a-fA-F]+)$"
        },
        "description": "Inclusive lower block bound; decimal or hex."
      },
      "toBlock": {
        "name": "toBlock",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^([0-9]+|0x[0-9a-fA-F]+|latest)$"
        },
        "description": "Inclusive upper block bound. latest means the database scanned-through watermark, not the live chain head."
      },
      "chainid": {
        "name": "chainid",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^([0-9]+|0x[0-9a-fA-F]+)$"
        },
        "description": "Filter within the configured chain. A different chain returns an empty list."
      },
      "address": {
        "name": "address",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$"
        },
        "description": "Case-insensitive emitting address within the indexed stream."
      },
      "topic0": {
        "name": "topic0",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{64}$"
        },
        "description": "Exact positional topic 0; StateCommitted has no topics 1-3."
      },
      "topic1": {
        "name": "topic1",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{64}$"
        },
        "description": "Exact positional topic 1; StateCommitted has no topics 1-3."
      },
      "topic2": {
        "name": "topic2",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{64}$"
        },
        "description": "Exact positional topic 2; StateCommitted has no topics 1-3."
      },
      "topic3": {
        "name": "topic3",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{64}$"
        },
        "description": "Exact positional topic 3; StateCommitted has no topics 1-3."
      },
      "topic0_1_opr": {
        "name": "topic0_1_opr",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "description": "Combine topic0 and topic1; both must be supplied. Explicit pair clauses are ANDed; uncovered topics are individually ANDed. Without operators all supplied topics are ANDed."
      },
      "topic0_2_opr": {
        "name": "topic0_2_opr",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "description": "Combine topic0 and topic2; both must be supplied. Explicit pair clauses are ANDed; uncovered topics are individually ANDed. Without operators all supplied topics are ANDed."
      },
      "topic0_3_opr": {
        "name": "topic0_3_opr",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "description": "Combine topic0 and topic3; both must be supplied. Explicit pair clauses are ANDed; uncovered topics are individually ANDed. Without operators all supplied topics are ANDed."
      },
      "topic1_2_opr": {
        "name": "topic1_2_opr",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "description": "Combine topic1 and topic2; both must be supplied. Explicit pair clauses are ANDed; uncovered topics are individually ANDed. Without operators all supplied topics are ANDed."
      },
      "topic1_3_opr": {
        "name": "topic1_3_opr",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "description": "Combine topic1 and topic3; both must be supplied. Explicit pair clauses are ANDed; uncovered topics are individually ANDed. Without operators all supplied topics are ANDed."
      },
      "topic2_3_opr": {
        "name": "topic2_3_opr",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "description": "Combine topic2 and topic3; both must be supplied. Explicit pair clauses are ANDed; uncovered topics are individually ANDed. Without operators all supplied topics are ANDed."
      },
      "page": {
        "name": "page",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000000,
          "default": 1
        },
        "description": "One-based page; (page-1)*offset may not exceed 1000000. Use narrower block ranges for deep history."
      },
      "offset": {
        "name": "offset",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "default": 100
        },
        "description": "Records per page; not a SQL row offset."
      },
      "sort": {
        "name": "sort",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "asc",
            "desc"
          ],
          "default": "asc"
        },
        "description": "Extension: event execution order, or meter ID order for current-meter lists."
      }
    }
  }
}
