{
  "openapi": "3.1.0",
  "info": {
    "title": "LION Trend Intent MCP",
    "version": "2.0.0",
    "description": "LION exposes two paid x402 v2 routes (JSON and CSV variants of the same hardware-wallet buyer-intent + self-custody onboarding-friction dataset) and free discovery metadata (catalog + well-known + this OpenAPI). Paid routes return HTTP 402 with a base64-encoded PAYMENT-REQUIRED header until the buyer retries with a valid PAYMENT-SIGNATURE on Base mainnet USDC.",
    "x-guidance": "x402scan / Bazaar / AgentCash discovery should submit only the absolute paid resource URLs under /api/x402/trend-intent-raw-signal-*. Never submit /api/x402/catalog or any /.well-known/* file as a paid resource."
  },
  "servers": [
    { "url": "https://gleaming-cassata-d41682.netlify.app" }
  ],
  "tags": [
    { "name": "paid", "description": "x402 v2 payment-gated routes" },
    { "name": "discovery", "description": "Free discovery metadata. Never payment-gated." }
  ],
  "components": {
    "securitySchemes": {
      "x402PaymentSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "x402 v2 primary request header carrying a base64-encoded EIP-712 TransferWithAuthorization signature + payment payload. Retry the unpaid 402 with this header set."
      },
      "x402PaymentLegacy": {
        "type": "apiKey",
        "in": "header",
        "name": "X-PAYMENT",
        "description": "x402 v1 legacy alias for PAYMENT-SIGNATURE. Accepted for backward compatibility only."
      }
    },
    "headers": {
      "PaymentRequired": {
        "description": "Base64-encoded JSON of the x402 v2 PaymentRequired object. Crawlers can read this header without parsing the body.",
        "schema": { "type": "string", "format": "base64" }
      },
      "PaymentResponse": {
        "description": "Base64-encoded JSON settlement envelope (txHash, network, asset, payTo, confirmations).",
        "schema": { "type": "string", "format": "base64" }
      },
      "XPaymentResponse": {
        "description": "Legacy alias of PAYMENT-RESPONSE. Identical value.",
        "schema": { "type": "string", "format": "base64" }
      }
    },
    "schemas": {
      "PaymentRequiredBody": {
        "type": "object",
        "required": ["x402Version", "error", "resource", "accepts", "extensions"],
        "properties": {
          "x402Version": { "type": "integer", "const": 2 },
          "error": { "type": "string" },
          "resource": {
            "type": "object",
            "required": ["url", "description", "mimeType", "serviceName", "tags"],
            "properties": {
              "url": { "type": "string", "format": "uri" },
              "description": { "type": "string" },
              "mimeType": { "type": "string" },
              "serviceName": { "type": "string" },
              "tags": { "type": "array", "items": { "type": "string" } }
            }
          },
          "accepts": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": ["scheme", "network", "amount", "asset", "payTo", "maxTimeoutSeconds", "extra"],
              "properties": {
                "scheme": { "type": "string", "const": "exact" },
                "network": { "type": "string", "const": "eip155:8453" },
                "amount": { "type": "string", "const": "10000" },
                "asset": { "type": "string", "const": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" },
                "payTo": { "type": "string", "const": "0x84c2e2ec19a4b467D89fE3F008591DEEA884d9Ac" },
                "maxTimeoutSeconds": { "type": "integer", "const": 60 },
                "extra": {
                  "type": "object",
                  "properties": {
                    "name": { "type": "string", "const": "USDC" },
                    "version": { "type": "string", "const": "2" }
                  }
                }
              }
            }
          },
          "extensions": { "type": "object" }
        }
      },
      "EmptyInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {},
        "description": "No request parameters are required. Send an empty JSON object or no body."
      },
      "TrendIntentJsonBody": {
        "type": "object",
        "required": ["asset_id", "row_count", "schema", "records"],
        "properties": {
          "asset_id": { "type": "string" },
          "row_count": { "type": "integer" },
          "schema": { "type": "array", "items": { "type": "string" } },
          "records": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "CatalogBody": {
        "type": "object",
        "required": ["product_id", "endpoint_kind", "payment_gated", "paid_resource_urls", "openapi_url"],
        "properties": {
          "product_id": { "type": "string", "const": "TREND_INTENT_RAW_SIGNAL_001" },
          "endpoint_kind": { "type": "string", "const": "free_discovery_metadata" },
          "payment_gated": { "type": "boolean", "const": false },
          "paid_resource_urls": { "type": "array", "items": { "type": "string", "format": "uri" } },
          "openapi_url": { "type": "string", "format": "uri" },
          "well_known_openapi_url": { "type": "string", "format": "uri" }
        }
      },
      "WellKnownX402Body": {
        "type": "object",
        "required": ["x402Version", "site", "payment_gated", "paid_resource_urls", "openapi_url"],
        "properties": {
          "x402Version": { "type": "integer", "const": 2 },
          "site": { "type": "string", "format": "uri" },
          "payment_gated": { "type": "boolean", "const": false },
          "paid_resource_urls": { "type": "array", "items": { "type": "string", "format": "uri" } },
          "openapi_url": { "type": "string", "format": "uri" },
          "well_known_openapi_url": { "type": "string", "format": "uri" }
        }
      }
    }
  },
  "paths": {
    "/api/x402/trend-intent-raw-signal-json": {
      "get": {
        "tags": ["paid"],
        "summary": "Paid x402 v2 route - JSON",
        "description": "Returns hardware-wallet buyer-intent + self-custody onboarding-friction signals as JSON. Takes no required query parameters and no required request body. Returns 402 with Payment-Required header until the buyer retries with a valid Payment-Signature header.",
        "operationId": "getTrendIntentJson",
        "security": [
          { "x402PaymentSignature": [] },
          { "x402PaymentLegacy": [] }
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.010000"
          },
          "protocols": [
            { "x402": {} }
          ]
        },
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": true,
            "example": "json",
            "schema": { "type": "string", "enum": ["json"], "default": "json" },
            "description": "Output format selector. Single-value enum; route is JSON-only. Endpoint ignores actual value; declared required so x402scan can probe deterministically."
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Buyers MUST send an empty JSON object {}. The endpoint ignores the body at runtime; declared required + inlined here so x402scan can parse the input contract without resolving $ref.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {},
                "description": "Empty input object. No request parameters are required."
              },
              "example": {}
            }
          }
        },
        "responses": {
          "402": {
            "description": "Payment required",
            "headers": {
              "Payment-Required": {
                "description": "Base64-encoded x402 v2 PaymentRequired object",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PaymentRequiredBody" }
              }
            }
          },
          "200": {
            "description": "Paid response. Body is the JSON dataset; Payment-Response header carries settlement evidence.",
            "headers": {
              "Payment-Response": { "$ref": "#/components/headers/PaymentResponse" },
              "X-Payment-Response": { "$ref": "#/components/headers/XPaymentResponse" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TrendIntentJsonBody" }
              }
            }
          },
          "503": {
            "description": "Facilitator or RPC unavailable; fail closed. Retry later."
          }
        }
      }
    },
    "/api/x402/trend-intent-raw-signal-csv": {
      "get": {
        "tags": ["paid"],
        "summary": "Paid x402 v2 route - CSV",
        "description": "Same dataset as the JSON variant, returned as text/csv. Takes no required query parameters and no required request body. Returns 402 with Payment-Required header until the buyer retries with a valid Payment-Signature.",
        "operationId": "getTrendIntentCsv",
        "security": [
          { "x402PaymentSignature": [] },
          { "x402PaymentLegacy": [] }
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.010000"
          },
          "protocols": [
            { "x402": {} }
          ]
        },
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": true,
            "example": "csv",
            "schema": { "type": "string", "enum": ["csv"], "default": "csv" },
            "description": "Output format selector. Single-value enum; route is CSV-only. Endpoint ignores actual value; declared required so x402scan can probe deterministically."
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Buyers MUST send an empty JSON object {}. The endpoint ignores the body at runtime; declared required + inlined here so x402scan can parse the input contract without resolving $ref.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {},
                "description": "Empty input object. No request parameters are required."
              },
              "example": {}
            }
          }
        },
        "responses": {
          "402": {
            "description": "Payment required",
            "headers": {
              "Payment-Required": {
                "description": "Base64-encoded x402 v2 PaymentRequired object",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PaymentRequiredBody" }
              }
            }
          },
          "200": {
            "description": "Paid response. Body is text/csv with hardware-wallet buyer-intent signal rows. Payment-Response header carries settlement evidence.",
            "headers": {
              "Payment-Response": { "$ref": "#/components/headers/PaymentResponse" },
              "X-Payment-Response": { "$ref": "#/components/headers/XPaymentResponse" }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string",
                  "description": "CSV body with hardware-wallet buyer-intent signal rows."
                }
              }
            }
          },
          "503": {
            "description": "Facilitator or RPC unavailable; fail closed. Retry later."
          }
        }
      }
    },
    "/api/x402/catalog": {
      "get": {
        "tags": ["discovery"],
        "summary": "Free catalog of paid x402 routes",
        "description": "Free discovery metadata. Returns HTTP 200 with JSON describing the paid routes, pricing, settlement policy, and the OpenAPI pointer. NOT payment-gated.",
        "operationId": "getCatalog",
        "security": [],
        "responses": {
          "200": {
            "description": "Catalog JSON",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CatalogBody" }
              }
            }
          }
        }
      }
    },
    "/.well-known/x402.json": {
      "get": {
        "tags": ["discovery"],
        "summary": "Well-known x402 site descriptor",
        "description": "Free well-known site descriptor. Returns HTTP 200 with JSON describing x402Version, paid_resource_urls, and the openapi_url. NOT payment-gated.",
        "operationId": "getWellKnownX402",
        "security": [],
        "responses": {
          "200": {
            "description": "Well-known x402 JSON",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WellKnownX402Body" }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "tags": ["discovery"],
        "summary": "OpenAPI 3.1 document (root)",
        "description": "Self-referential pointer at the site root. Returns HTTP 200 with this OpenAPI document. NOT payment-gated.",
        "operationId": "getOpenapi",
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 JSON document",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    },
    "/.well-known/openapi.json": {
      "get": {
        "tags": ["discovery"],
        "summary": "OpenAPI 3.1 document (well-known)",
        "description": "Self-referential pointer at the well-known path. Returns HTTP 200 with this OpenAPI document. NOT payment-gated.",
        "operationId": "getWellKnownOpenapi",
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 JSON document",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    }
  }
}
