{
  "openapi": "3.0.3",
  "info": {
    "title": "Alpha Signal API",
    "description": "Signaux listings MEXC, whale moves et news normalises. Plans Free / Pro 99 EUR / Business 499 EUR.",
    "version": "1.0.0",
    "contact": { "name": "Constellation Crypto", "url": "https://alpha-signal.example.com" }
  },
  "servers": [{ "url": "https://alpha-signal.example.com", "description": "Production" }],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object" } } } }
        }
      }
    },
    "/v1/signals": {
      "get": {
        "summary": "Recent normalized signals",
        "security": [{ "BearerAuth": [] }, { "ApiKeyAuth": [] }],
        "parameters": [
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 50, "maximum": 200 } }
        ],
        "responses": {
          "200": { "description": "Signal list with tenant lag applied" },
          "401": { "description": "Missing or invalid API key" },
          "429": { "description": "Quota exceeded" }
        }
      }
    },
    "/v1/checkout": {
      "post": {
        "summary": "Create Stripe checkout session",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": { "type": "string", "format": "email" },
                  "plan": { "type": "string", "enum": ["free", "pro", "business"] }
                }
              }
            }
          }
        },
        "responses": { "200": { "description": "Checkout URL" } }
      }
    },
    "/v1/hook/{provider}": {
      "post": {
        "summary": "Inbound webhook (HMAC signed)",
        "parameters": [{ "name": "provider", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "202": { "description": "Accepted" }, "401": { "description": "Bad signature" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "API key" },
      "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "x-api-key" }
    },
    "schemas": {
      "Signal": {
        "type": "object",
        "properties": {
          "type": { "type": "string", "enum": ["listing", "whale", "news"] },
          "symbol": { "type": "string" },
          "source": { "type": "string" },
          "ts_ms": { "type": "integer" },
          "summary": { "type": "string" },
          "notional_usd": { "type": "number" }
        }
      }
    }
  }
}
