{
  "openapi": "3.1.0",
  "info": {
    "title": "Clustell Data API",
    "version": "1.0",
    "description": "Structured crypto sentiment, KOL Conviction vs. Fear & Greed divergence, token risk telemetry, and noise-filtered daily market wire.",
    "contact": {
      "name": "Clustell",
      "url": "https://www.clustell.xyz/developers",
      "email": "clustellapp@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://www.clustell.xyz/api/v1",
      "description": "Production API v1"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    },
    {
      "ApiKeyHeader": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key (clst_live_...)"
      },
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "meta": {
            "type": "object",
            "properties": {
              "api_version": {
                "type": "string",
                "example": "1.0"
              }
            }
          }
        }
      },
      "DivergenceAssessment": {
        "type": "object",
        "properties": {
          "spread": {
            "type": [
              "integer",
              "null"
            ],
            "example": 26
          },
          "formula": {
            "type": "string",
            "example": "kol_conviction.score - fear_and_greed.score"
          },
          "regime": {
            "type": "string",
            "enum": [
              "bullish_divergence",
              "distribution_warning",
              "aligned_bullish",
              "aligned_fear",
              "quiet_accumulation",
              "cautious_drift",
              "neutral",
              "insufficient_data"
            ]
          },
          "regime_label": {
            "type": "string",
            "example": "Bullish Divergence"
          },
          "tension_level": {
            "type": "string",
            "enum": [
              "low",
              "moderate",
              "high"
            ]
          },
          "summary": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/index/current": {
      "get": {
        "operationId": "getConvictionIndexCurrent",
        "summary": "Get current Clustell Conviction Index, Fear & Greed, and Divergence Regime",
        "description": "Returns the latest KOL Conviction score (0-100), market Fear & Greed reference, calculated divergence spread, regime classification, voice counts, and (for partner/builder/pro/enterprise tiers) sector breakdowns. Supports conditional requests via ETag / If-None-Match (304 Not Modified).",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Pass the previous ETag header to receive 304 Not Modified when unchanged."
          }
        ],
        "responses": {
          "200": {
            "description": "Current conviction index and divergence regime."
          },
          "304": {
            "description": "Unchanged since previous ETag."
          },
          "401": {
            "description": "Missing, invalid, or revoked API key."
          },
          "403": {
            "description": "Insufficient scope or browser_client_disallowed (server-to-server keys cannot be called from client browsers)."
          },
          "429": {
            "description": "Global RPM rate limit or monthly quota exceeded."
          }
        }
      }
    },
    "/index/history": {
      "get": {
        "operationId": "getConvictionIndexHistory",
        "summary": "Get historical daily series of KOL Conviction, Fear & Greed, and Divergence",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 2,
              "maximum": 90,
              "default": 30
            },
            "description": "Number of daily points to return (max 30 on free tier, 90 on partner/builder/pro/enterprise)."
          }
        ],
        "responses": {
          "200": {
            "description": "Daily time series sorted ascending by UTC date."
          },
          "304": {
            "description": "Unchanged since previous ETag."
          },
          "400": {
            "description": "Invalid days parameter."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "Insufficient scope or browser_client_disallowed."
          },
          "429": {
            "description": "Rate limit exceeded."
          }
        }
      }
    },
    "/tokens/signal": {
      "get": {
        "operationId": "getTokenSignal",
        "summary": "Get structured Watch Score, risk labels, thesis status, and Echo Chamber pulse for a token",
        "description": "Subject to per-key daily unique token quotas (X-Daily-Tokens-Limit / X-Daily-Tokens-Remaining). Repeating lookups for the same canonical token (by slug, ticker, or contract) does not consume extra daily slots.",
        "parameters": [
          {
            "name": "slug",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Clustell canonical slug (e.g. 'solana', 'bitcoin')."
          },
          {
            "name": "ticker",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Token ticker symbol (e.g. 'SOL', 'ETH')."
          },
          {
            "name": "contract",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "On-chain token contract or DEX LP pair address (Solana, Base, Ethereum, BSC, etc.)."
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional chain hint when querying by contract (e.g. 'solana', 'base', 'ethereum')."
          }
        ],
        "responses": {
          "200": {
            "description": "Structured token signal. Always check data.coverage ('analyzed' vs 'unscored') before reading watch_score. Includes X-Daily-Tokens-Limit and X-Daily-Tokens-Remaining headers."
          },
          "400": {
            "description": "Missing lookup parameter or invalid contract."
          },
          "401": {
            "description": "Missing, invalid, or revoked API key."
          },
          "403": {
            "description": "Insufficient scope or browser_client_disallowed."
          },
          "404": {
            "description": "Token not found in catalog."
          },
          "429": {
            "description": "Global RPM limit (rate_limited), daily unique token cap (daily_token_quota_exceeded), or unmatched-token spam throttle (lookup_miss_rate_limited, max 15 misses/min)."
          }
        }
      }
    },
    "/wire/today": {
      "get": {
        "operationId": "getDailyWire",
        "summary": "Get noise-filtered daily crypto market wire items",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "UTC date (YYYY-MM-DD). Defaults to the latest available date."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional category filter (case-insensitive)."
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered daily wire items sorted by relevance."
          },
          "400": {
            "description": "Invalid date or limit parameter."
          },
          "401": {
            "description": "Missing, invalid, or revoked API key."
          },
          "403": {
            "description": "Insufficient scope or browser_client_disallowed."
          },
          "429": {
            "description": "Rate limit or monthly quota exceeded."
          }
        }
      }
    }
  }
}