{
  "openapi": "3.1.0",
  "info": {
    "title": "Xicae API & MCP Server",
    "version": "2027.1.0",
    "description": "Deterministic developer utilities, mathematical calculation, astronomy ephemeris, code formatting, table transformations, and Model Context Protocol (MCP) server for developers and AI agents. Includes 5 free daily requests per IP and optional x402 micropayments on Base USDC.",
    "contact": {
      "name": "Xicae Atelier",
      "url": "https://xicae.org",
      "email": "care@xicae.com"
    },
    "license": {
      "name": "MIT / Client-Edge Execution",
      "url": "https://xicae.dev/terms"
    }
  },
  "servers": [
    {
      "url": "https://api.xicae.dev",
      "description": "Primary Production API & MCP Server"
    },
    {
      "url": "https://xicae.dev",
      "description": "Static Discovery & Metadata Mirror"
    }
  ],
  "paths": {
    "/v1/prayer-times": {
      "get": {
        "summary": "Calculate Astronomical Islamic Prayer Times",
        "operationId": "getPrayerTimes",
        "tags": [
          "Miqat - Astronomy"
        ],
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90,
              "default": 28.6139
            },
            "required": true
          },
          {
            "name": "lon",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180,
              "default": 77.209
            },
            "required": true
          },
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "required": false
          },
          {
            "name": "method",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "UmmAlQura",
                "MuslimWorldLeague",
                "ISNA",
                "Egyptian",
                "Karachi",
                "Tehran"
              ]
            },
            "required": false
          },
          {
            "name": "asr",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "Shafi",
                "Hanafi"
              ]
            },
            "required": false
          },
          {
            "name": "tz",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Prayer times schedule and solar ephemeris data"
          }
        }
      }
    },
    "/v1/qibla": {
      "get": {
        "summary": "Calculate Geodesic Qibla Vector to Kaaba",
        "operationId": "getQibla",
        "tags": [
          "Miqat - Astronomy"
        ],
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "schema": {
              "type": "number",
              "default": 28.6139
            },
            "required": true
          },
          {
            "name": "lon",
            "in": "query",
            "schema": {
              "type": "number",
              "default": 77.209
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Bearing degrees and distance in km"
          }
        }
      }
    },
    "/v1/hijri-date": {
      "get": {
        "summary": "Gregorian to Umm al-Qura Hijri Calendar Conversion",
        "operationId": "getHijriDate",
        "tags": [
          "Miqat - Astronomy"
        ],
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": -2,
              "maximum": 2
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Hijri date details, moon phase, and holiday detection"
          }
        }
      }
    },
    "/v1/moon-phase": {
      "get": {
        "summary": "Get Current Moon Phase and Illumination",
        "operationId": "getMoonPhase",
        "tags": [
          "Miqat - Astronomy"
        ],
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Moon phase index, symbol, and percentage illumination"
          }
        }
      }
    },
    "/v1/transcode-plan": {
      "post": {
        "summary": "Calculate Video Transcode Plan & Rate-Distortion Profile",
        "operationId": "calculateTranscodePlan",
        "tags": [
          "Compress - Media"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "inputFormat": {
                    "type": "string",
                    "example": "mov"
                  },
                  "outputFormat": {
                    "type": "string",
                    "example": "mp4"
                  },
                  "durationSeconds": {
                    "type": "number",
                    "example": 45
                  },
                  "useCasePreset": {
                    "type": "string",
                    "enum": [
                      "whatsapp_video",
                      "gmail_attachment",
                      "web_hero_image",
                      "discord_nitro_free"
                    ]
                  }
                },
                "required": [
                  "inputFormat",
                  "outputFormat"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculated metrics, FFmpeg CLI command, and WASM worker URL"
          }
        }
      }
    },
    "/v1/inspect": {
      "post": {
        "summary": "Inspect Media Container & Codec Capabilities",
        "operationId": "inspectMedia",
        "tags": [
          "Compress - Media"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fileName": {
                    "type": "string",
                    "example": "photo.heic"
                  },
                  "mimeType": {
                    "type": "string",
                    "example": "image/heic"
                  },
                  "fileSizeBytes": {
                    "type": "number",
                    "example": 5242880
                  }
                },
                "required": [
                  "fileName",
                  "mimeType",
                  "fileSizeBytes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Container analysis and browser support flags"
          }
        }
      }
    },
    "/v1/pdf-plan": {
      "post": {
        "summary": "Generate PDF Downsampling & Compression Recipe",
        "operationId": "generatePdfPlan",
        "tags": [
          "Compress - Media"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "currentSizeBytes": {
                    "type": "number",
                    "example": 10485760
                  },
                  "profile": {
                    "type": "string",
                    "enum": [
                      "screen_72dpi",
                      "ebook_150dpi",
                      "printer_300dpi"
                    ]
                  },
                  "convertToGrayscale": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "currentSizeBytes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ghostscript CLI and in-browser WASM canvas downsampling recipe"
          }
        }
      }
    },
    "/v1/optimize-svg": {
      "post": {
        "summary": "In-Worker Lossless SVG Minifier & Sanitizer",
        "operationId": "optimizeSvg",
        "tags": [
          "Compress - Media"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "svgContent": {
                    "type": "string",
                    "description": "Raw SVG text"
                  }
                },
                "required": [
                  "svgContent"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Minified SVG string, bytes saved, and sanitization confirmation"
          }
        }
      }
    },
    "/v1/format": {
      "post": {
        "summary": "Format Source Code Across Multi-Language Syntaxes",
        "operationId": "formatSourceCode",
        "tags": [
          "WebCode - Developer Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "example": "{\"key\":\"value\"}"
                  },
                  "language": {
                    "type": "string",
                    "enum": [
                      "json",
                      "javascript",
                      "typescript",
                      "python",
                      "html",
                      "css"
                    ]
                  }
                },
                "required": [
                  "code",
                  "language"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Beautified code string and syntax validity report"
          }
        }
      }
    },
    "/v1/workspace-bundle": {
      "post": {
        "summary": "Generate Virtual Workspace Project Manifest",
        "operationId": "generateWorkspaceManifest",
        "tags": [
          "WebCode - Developer Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectName": {
                    "type": "string",
                    "example": "my-project"
                  },
                  "template": {
                    "type": "string",
                    "enum": [
                      "vanilla-js",
                      "python-cli",
                      "static-html"
                    ]
                  }
                },
                "required": [
                  "projectName"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Virtual filesystem files manifest, tree, and runner commands"
          }
        }
      }
    },
    "/v1/lint": {
      "post": {
        "summary": "Static Code Structure & Import Extraction",
        "operationId": "analyzeCodeStructure",
        "tags": [
          "WebCode - Developer Tools"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "codeSnippet": {
                    "type": "string",
                    "example": "import React from \"react\";"
                  },
                  "language": {
                    "type": "string",
                    "enum": [
                      "javascript",
                      "typescript",
                      "html",
                      "css",
                      "json"
                    ]
                  }
                },
                "required": [
                  "codeSnippet"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Extracted dependencies and syntax balance check"
          }
        }
      }
    },
    "/v1/evaluate-formula": {
      "post": {
        "summary": "Evaluate Spreadsheet Formula (60+ Functions Supported)",
        "operationId": "evaluateFormula",
        "tags": [
          "WebOffice - Productivity"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "formula": {
                    "type": "string",
                    "example": "=SUM(A1:A5)"
                  },
                  "gridContext": {
                    "type": "object"
                  }
                },
                "required": [
                  "formula"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculated formula result and explanation"
          }
        }
      }
    },
    "/v1/parse-table": {
      "post": {
        "summary": "Parse Raw CSV/TSV Table to Typed Schema & Stats",
        "operationId": "parseTable",
        "tags": [
          "WebOffice - Productivity"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rawTableString": {
                    "type": "string",
                    "example": "Name,Role,Score\nAlice,Engineer,94"
                  },
                  "delimiter": {
                    "type": "string",
                    "enum": [
                      ",",
                      "\t",
                      "|",
                      ";"
                    ]
                  },
                  "hasHeaderRow": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "rawTableString"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parsed row matrix, detected column types, and column statistics"
          }
        }
      }
    },
    "/v1/convert-schema": {
      "post": {
        "summary": "Generate Document Recipe for Word, Excel, or Slides",
        "operationId": "generateDocumentRecipe",
        "tags": [
          "WebOffice - Productivity"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "documentType": {
                    "type": "string",
                    "enum": [
                      "word_docx",
                      "spreadsheet_xlsx",
                      "slides_pptx",
                      "pdf"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "example": "Executive Summary"
                  }
                },
                "required": [
                  "documentType",
                  "title"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured OpenXML manifest for in-browser client compilation"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "summary": "Model Context Protocol (MCP) Streamable HTTP Endpoint",
        "operationId": "callMcp",
        "tags": [
          "Model Context Protocol"
        ],
        "description": "Unified Model Context Protocol JSON-RPC streamable endpoint hosting all 11 deterministic tools. Subject to 5 free requests/day, followed by 0.002 Base USDC settlement.",
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "EVM cryptographic proof fulfilling the x402 payment challenge issued upon 402 responses"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "example": "2.0"
                  },
                  "method": {
                    "type": "string",
                    "example": "tools/call"
                  },
                  "id": {
                    "type": "number",
                    "example": 1
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC result stream in text/event-stream or application/json"
          },
          "402": {
            "description": "Payment Required - Challenge payload containing Base USDC recipient"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "x402": {
        "type": "apiKey",
        "name": "PAYMENT-SIGNATURE",
        "in": "header",
        "description": "EVM cryptographic proof fulfilling the x402 Base (eip155:8453) USDC payment challenge."
      }
    }
  }
}