{
  "openapi": "3.1.0",
  "info": {
    "title": "Quickbrew.io API",
    "description": "Machine-to-machine data extraction and compression endpoints for autonomous AI agents using the x402 micro-payment protocol on Base Mainnet (USDC).",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.quickbrew.io",
      "description": "Production Edge Server"
    }
  ],
  "components": {
    "securitySchemes": {
      "x402_Payment_Signature": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "Base64-encoded EIP-712 ReceiveWithAuthorization payload signing USDC micro-payment to 0x63419c2d5d06795fec77c5d124e4779fdf279b16 on Base (Chain ID 8453). Unsigned requests return 402 Payment Required."
      }
    },
    "schemas": {
      "ScrapeResponse": {
        "type": "object",
        "required": ["text", "url"],
        "properties": {
          "text": {
            "type": "string",
            "description": "Clean, DOM-stripped Markdown text extracted from target URL."
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "CondenseResponse": {
        "type": "object",
        "required": ["condensed_text"],
        "properties": {
          "condensed_text": {
            "type": "string",
            "description": "Fact-dense summary and key bullet points produced by OpenAI OSS 20B."
          }
        }
      },
      "SentimentResponse": {
        "type": "object",
        "description": "EXPERIMENTAL: Operational tone and brand claim analysis.",
        "properties": {
          "tone": {
            "type": "string",
            "example": "commercial"
          },
          "bias": {
            "type": "object",
            "properties": {
              "direction": { "type": "string" },
              "confidence": { "type": "number", "format": "float" }
            }
          },
          "claims": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": { "type": "string" }
              }
            }
          }
        }
      },
      "PaymentRequiredError": {
        "type": "object",
        "properties": {
          "error": { "type": "string", "example": "Payment Required" },
          "priceUsdc": { "type": "string", "example": "0.001" },
          "priceAtomic": { "type": "string", "example": "1000" },
          "merchant": { "type": "string", "example": "0x63419c2d5d06795fec77c5d124e4779fdf279b16" },
          "chainId": { "type": "integer", "example": 8453 }
        }
      },
      "ApiError": {
        "type": "object",
        "properties": {
          "error": { "type": "string", "example": "ERR_BAD_URL" },
          "message": { "type": "string", "example": "Target URL is unreachable or returned an invalid status code." }
        }
      }
    }
  },
  "security": [
    {
      "x402_Payment_Signature": []
    }
  ],
  "paths": {
    "/scrape": {
      "get": {
        "summary": "Clean Markdown Scraper",
        "description": "Strips HTML/CSS and returns raw Markdown text. Engine: DOM parser (No LLM). Price: 0.001 USDC.",
        "operationId": "scrapeUrl",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "format": "uri" },
            "description": "Target URL to scrape."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful extraction",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ScrapeResponse" }
              }
            }
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PaymentRequiredError" }
              }
            }
          },
          "400": {
            "description": "Bad Request / Scraping Error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        }
      }
    },
    "/condense": {
      "get": {
        "summary": "Context Condenser",
        "description": "Compresses page text into dense bullet points using OpenAI OSS 20B (@cf/openai/gpt-oss-20b). Price: 0.005 USDC.",
        "operationId": "condenseUrl",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "format": "uri" },
            "description": "Target URL to condense."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful condensation",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CondenseResponse" }
              }
            }
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PaymentRequiredError" }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        }
      }
    },
    "/sentiment": {
      "get": {
        "summary": "Live Sentiment API [EXPERIMENTAL]",
        "description": "Extracts operational tone and brand claims using OpenAI OSS 20B (@cf/openai/gpt-oss-20b). Price: 0.002 USDC.",
        "operationId": "analyzeSentiment",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "format": "uri" },
            "description": "Target URL for sentiment analysis."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful sentiment extraction",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SentimentResponse" }
              }
            }
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PaymentRequiredError" }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        }
      }
    }
  }
}