{
  "openapi": "3.0.3",
  "info": {
    "title": "MoonMaker API",
    "description": "AI-native crypto trading signals. Pay per call via x402 protocol (USDC on Base L2). No API keys needed.",
    "version": "1.0.0",
    "contact": {
      "name": "MoonMaker",
      "url": "https://moonmaker.cc"
    }
  },
  "servers": [
    {
      "url": "https://api.moonmaker.cc",
      "description": "Production"
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "Service Info",
        "description": "Returns service info, available endpoints, and documentation links.",
        "operationId": "getRoot",
        "responses": {
          "200": {
            "description": "Service information",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceInfo"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health Check",
        "description": "Returns system health status.",
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "System healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/signal/{coin}": {
      "get": {
        "summary": "Trading Signal",
        "description": "Real-time trading signal with 25-indicator voting system. Returns direction, confidence, entry/exit prices, stop-loss, and take-profit levels. Costs $0.05 USDC per call via x402.",
        "operationId": "getSignal",
        "parameters": [
          {
            "name": "coin",
            "in": "path",
            "required": true,
            "description": "Cryptocurrency ticker",
            "schema": {
              "type": "string",
              "enum": ["BTC", "ETH", "SOL"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signal data (after successful x402 payment)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignalResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Includes X-PAYMENT header with payment details.",
            "headers": {
              "X-PAYMENT": {
                "description": "JSON-encoded payment details: amount, recipient, network, facilitator URL",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/market/overview": {
      "get": {
        "summary": "Market Overview",
        "description": "Full market overview including prices, Fear & Greed index, ETF flows, stablecoin flows, derivatives, and macro indicators. Costs $0.10 USDC per call via x402.",
        "operationId": "getMarketOverview",
        "responses": {
          "200": {
            "description": "Market overview data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketOverview"
                }
              }
            }
          },
          "402": {
            "description": "Payment required",
            "headers": {
              "X-PAYMENT": {
                "description": "Payment details for x402 settlement",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/market/etf": {
      "get": {
        "summary": "ETF Flow Data",
        "description": "ETF institutional flow breakdown. Daily/weekly net flows by fund. Costs $0.05 USDC per call via x402.",
        "operationId": "getETFFlows",
        "responses": {
          "200": {
            "description": "ETF flow data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ETFResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required",
            "headers": {
              "X-PAYMENT": {
                "description": "Payment details for x402 settlement",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceInfo": {
        "type": "object",
        "properties": {
          "service": { "type": "string", "example": "MoonMaker API" },
          "description": { "type": "string" },
          "endpoints": { "type": "object" },
          "payment": { "type": "string", "example": "x402 (USDC on Base L2)" },
          "version": { "type": "string" },
          "docs": { "type": "object" }
        }
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "example": "ok" },
          "timestamp": { "type": "string", "format": "date-time" }
        }
      },
      "SignalResponse": {
        "type": "object",
        "properties": {
          "coin": { "type": "string", "example": "BTC" },
          "price": { "type": "number", "example": 70000 },
          "signal": {
            "type": "object",
            "properties": {
              "direction": { "type": "string", "enum": ["STRONG_LONG", "LONG", "LEAN_LONG", "NEUTRAL", "LEAN_SHORT", "SHORT", "STRONG_SHORT"] },
              "confidence": { "type": "number", "example": 0.72 },
              "strength": { "type": "integer", "example": 3 }
            }
          },
          "levels": {
            "type": "object",
            "properties": {
              "entry": { "type": "number" },
              "stop_loss": { "type": "number" },
              "take_profit_1": { "type": "number" },
              "take_profit_2": { "type": "number" },
              "take_profit_3": { "type": "number" }
            }
          },
          "votes": {
            "type": "object",
            "description": "25-indicator voting breakdown",
            "properties": {
              "long": { "type": "integer" },
              "short": { "type": "integer" },
              "neutral": { "type": "integer" }
            }
          },
          "timestamp": { "type": "string", "format": "date-time" }
        }
      },
      "MarketOverview": {
        "type": "object",
        "properties": {
          "prices": { "type": "object" },
          "fear_greed": { "type": "object" },
          "etf_flows": { "type": "object" },
          "stablecoin_flows": { "type": "object" },
          "derivatives": { "type": "object" },
          "timestamp": { "type": "string", "format": "date-time" }
        }
      },
      "ETFResponse": {
        "type": "object",
        "properties": {
          "daily": { "type": "object" },
          "weekly": { "type": "object" },
          "by_fund": { "type": "object" },
          "timestamp": { "type": "string", "format": "date-time" }
        }
      }
    }
  },
  "x-x402": {
    "description": "This API uses x402 protocol for payment. Paid endpoints return HTTP 402 with payment instructions in the X-PAYMENT header. Use an x402-compatible client for automatic payment handling.",
    "network": "Base L2 (EIP-155:8453)",
    "currency": "USDC",
    "facilitator": "https://api.cdp.coinbase.com/platform/v2/x402"
  }
}
