{
  "openapi": "3.0.3",
  "info": {
    "title": "ChainLedgerAI API",
    "version": "1.0.0",
    "description": "ChainLedgerAI answers an on-demand query for an Ethereum address and returns a snapshot of its on-chain activity as of the moment queried, from Google's public Ethereum dataset. Ethereum only. It does not watch or monitor addresses, does not push alerts, and never returns a risk score, compliance flag or AML/sanctions judgment.\n\nAuthentication: send your API key in the `X-API-Key` header. Get a key by signing up on https://oculix.io/docs/chainledger/. Each successful call uses 1 credit from your quota; 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.chainledgerai.io",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Documentation and live widget",
    "url": "https://oculix.io/docs/chainledger/"
  },
  "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"
        ]
      },
      "DetailError": {
        "type": "object",
        "properties": {
          "detail": {
            "type": "string"
          }
        },
        "required": [
          "detail"
        ]
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/v1/chainledger/address-metrics": {
      "post": {
        "summary": "Activity snapshot for one Ethereum address",
        "operationId": "addressMetrics",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "address"
                ],
                "properties": {
                  "address": {
                    "type": "string",
                    "description": "An Ethereum address.",
                    "example": "0x0000000000000000000000000000000000000000"
                  },
                  "lookback_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 365,
                    "default": 30
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Snapshot as of the moment of the query",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "address": {
                      "type": "string"
                    },
                    "tx_count_in": {
                      "type": "integer"
                    },
                    "tx_count_out": {
                      "type": "integer"
                    },
                    "total_value_in_wei": {
                      "type": "string",
                      "description": "Decimal string, in wei."
                    },
                    "total_value_out_wei": {
                      "type": "string",
                      "description": "Decimal string, in wei."
                    },
                    "unique_counterparties": {
                      "type": "integer"
                    },
                    "first_seen": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    },
                    "last_seen": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    },
                    "label": {
                      "type": "string",
                      "description": "Activity-frequency label."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid address or parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetailError"
                },
                "example": {
                  "detail": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown X-API-Key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetailError"
                },
                "example": {
                  "detail": "Unauthorized"
                }
              }
            }
          },
          "402": {
            "description": "Quota depleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetailError"
                },
                "example": {
                  "detail": "Quota Depleted"
                }
              }
            }
          }
        }
      }
    },
    "/v1/chainledger/summarize": {
      "post": {
        "summary": "Two-sentence plain-English summary of the same snapshot",
        "description": "A separate call that uses its own credit. The summary describes volume and frequency only.",
        "operationId": "summarize",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "address"
                ],
                "properties": {
                  "address": {
                    "type": "string",
                    "description": "An Ethereum address.",
                    "example": "0x0000000000000000000000000000000000000000"
                  },
                  "lookback_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 365,
                    "default": 30
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "address": {
                      "type": "string"
                    },
                    "summary": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid address or parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetailError"
                },
                "example": {
                  "detail": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown X-API-Key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetailError"
                },
                "example": {
                  "detail": "Unauthorized"
                }
              }
            }
          },
          "402": {
            "description": "Quota depleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetailError"
                },
                "example": {
                  "detail": "Quota Depleted"
                }
              }
            }
          },
          "502": {
            "description": "The generated summary failed the neutral-language guardrail, so none is returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetailError"
                },
                "example": {
                  "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.chainledgerai.io"
          }
        ],
        "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"
                }
              }
            }
          }
        }
      }
    }
  }
}
