{
  "openapi": "3.1.0",
  "info": {
    "title": "patternfetch",
    "version": "0.1.0",
    "description": "Agent-first API: crypto ticker + timeframe -> token-compact market-state brief. Impersonal market data, not investment advice."
  },
  "servers": [{ "url": "https://patternfetch.com" }],
  "security": [{ "bearerAuth": [] }],
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer" }
    },
    "schemas": {
      "Query": {
        "type": "object",
        "required": ["ticker", "timeframe"],
        "properties": {
          "ticker": { "type": "string", "example": "BTC/USDT" },
          "timeframe": { "type": "string", "enum": ["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w"] },
          "limit": { "type": "integer", "minimum": 20, "maximum": 1000 }
        }
      }
    }
  },
  "paths": {
    "/v1/brief": {
      "post": {
        "operationId": "getBrief",
        "summary": "Token-compact market-state brief for a crypto ticker + timeframe",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Query" } } } },
        "responses": { "200": { "description": "Brief" }, "401": { "description": "Unauthorized" }, "402": { "description": "Payment required" } }
      }
    },
    "/v1/delta": {
      "post": {
        "operationId": "getDelta",
        "summary": "Only what changed since your last brief (token-minimal for polling)",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Query" } } } },
        "responses": { "200": { "description": "Delta" } }
      }
    },
    "/v1/candles": {
      "post": {
        "operationId": "getCandles",
        "summary": "Compact candle codec (rows + SAX shape signature)",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Query" } } } },
        "responses": { "200": { "description": "Codec output" } }
      }
    },
    "/v1/analogs": {
      "post": {
        "operationId": "getAnalogs",
        "summary": "Historical analogs as a full outcome distribution (not a prediction)",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Query" } } } },
        "responses": { "200": { "description": "Outcome distribution" } }
      }
    },
    "/v1/keys": {
      "post": {
        "operationId": "createKey",
        "summary": "Self-serve API key + free credit",
        "security": [],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["email"], "properties": { "email": { "type": "string" } } } } } },
        "responses": { "200": { "description": "API key" } }
      }
    },
    "/v1/platforms": {
      "get": { "operationId": "getPlatforms", "summary": "Capabilities matrix", "security": [], "responses": { "200": { "description": "Capabilities" } } }
    },
    "/healthz": {
      "get": { "operationId": "getHealth", "summary": "Health check", "security": [], "responses": { "200": { "description": "OK" } } }
    }
  }
}
