{
  "openapi": "3.0.3",
  "info": {
    "title": "NodeCache EVM API",
    "version": "1.0.0",
    "description": "NodeCache is an EVM RPC caching layer for read-only JSON-RPC calls on Ethereum mainnet. It accepts only the six read-only methods listed below; any other method, including state-changing ones such as eth_sendRawTransaction, is rejected with 400. Responses are cached per method and parameters for a short, fixed time: one hour for eth_chainId and a few seconds for every other supported method. Cache lifetimes cannot be configured.\n\nAuthentication: send your API key in the `x-api-key` header. Get a key by signing up on https://oculix.io/docs/nodecache/. Each successful call uses 1 credit from your quota, including answers served from the cache; when the quota is used up the API returns 402.",
    "contact": {
      "name": "Oculix LLC",
      "url": "https://oculix.io",
      "email": "info@oculix.net"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://oculix.io/legal/terms/"
    }
  },
  "servers": [
    {
      "url": "https://api.nodecache.dev",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Documentation and live widget",
    "url": "https://oculix.io/docs/nodecache/"
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "supportedMethods": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "error"
        ]
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/v1/rpc-edge": {
      "post": {
        "summary": "Send a read-only JSON-RPC request through the cache",
        "operationId": "rpcEdge",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "method"
                ],
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "example": "2.0"
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "eth_call",
                      "eth_getBalance",
                      "eth_getCode",
                      "eth_getLogs",
                      "eth_blockNumber",
                      "eth_chainId"
                    ]
                  },
                  "params": {
                    "type": "array",
                    "items": {},
                    "description": "Standard JSON-RPC params for the method."
                  },
                  "id": {
                    "description": "Echoed back in the response.",
                    "oneOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "string"
                      }
                    ]
                  }
                }
              },
              "example": {
                "jsonrpc": "2.0",
                "method": "eth_blockNumber",
                "params": [],
                "id": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The JSON-RPC response from the upstream node (or the cache), with a `cached` flag. A JSON-RPC `error` object from the node is passed through as returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jsonrpc": {
                      "type": "string"
                    },
                    "id": {},
                    "result": {},
                    "error": {
                      "type": "object"
                    },
                    "cached": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing x-api-key or method, or an unsupported method",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported": {
                    "value": {
                      "error": "Unsupported method",
                      "detail": "NodeCache only supports read-only methods on Ethereum mainnet",
                      "supportedMethods": [
                        "eth_call",
                        "eth_getBalance",
                        "eth_getCode",
                        "eth_getLogs",
                        "eth_blockNumber",
                        "eth_chainId"
                      ]
                    }
                  },
                  "missing": {
                    "value": {
                      "error": "Missing x-api-key or method"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unknown or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized"
                }
              }
            }
          },
          "402": {
            "description": "Quota depleted: the key has no credits left",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Quota Depleted"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "string"
                }
              }
            }
          },
          "502": {
            "description": "The upstream node request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Upstream RPC request failed",
                  "detail": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "summary": "Remaining quota and call counts",
        "description": "Served by the auth service, not the product API. Returns the remaining credit quota for the key and a call-count breakdown.",
        "operationId": "getUsage",
        "servers": [
          {
            "url": "https://auth.nodecache.dev"
          }
        ],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Quota and usage",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tenantId": {
                      "type": "string"
                    },
                    "product": {
                      "type": "string"
                    },
                    "remainingCreditQuota": {
                      "type": "integer"
                    },
                    "includedQuota": {
                      "type": "integer"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "totalCalls": {
                          "type": "integer"
                        },
                        "callsLast30Days": {
                          "type": "integer"
                        },
                        "lastCallAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "byEndpoint": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing x-api-key header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Missing x-api-key header"
                }
              }
            }
          },
          "401": {
            "description": "Unknown key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
