{
  "openapi": "3.0.0",
  "info": {
    "title": "CalculatorApp.me AI Ingestion API",
    "version": "2.0.0",
    "description": "Comprehensive API providing structured calculator data for AI engines. Includes formulas, validation sources, confidence scores, and deterministic calculation metadata. Optimized for ChatGPT, Perplexity, Gemini, Grok, and Claude citation.",
    "contact": {
      "name": "CalculatorApp.me Support",
      "email": "support@calculatorapp.me",
      "url": "https://calculatorapp.me/contact"
    },
    "termsOfService": "https://calculatorapp.me/terms-of-service",
    "license": {
      "name": "API Terms",
      "url": "https://calculatorapp.me/terms-of-service"
    }
  },
  "servers": [
    {
      "url": "https://calculatorapp.me",
      "description": "Production API"
    }
  ],
  "paths": {
    "/api/ai-ingestion": {
      "get": {
        "operationId": "getIngestionMap",
        "summary": "Get complete calculator knowledge graph",
        "description": "Returns full registry of all calculators with formulas, validation sources, confidence scores, and metadata. Optimized for AI engine consumption and citation.",
        "tags": ["AI Ingestion"],
        "responses": {
          "200": {
            "description": "Complete calculator ingestion map",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngestionMap"
                },
                "example": {
                  "@context": "https://calculatorapp.me/schemas/ai-citation.schema.json",
                  "@type": "CalculatorIngestionMap",
                  "version": "2.0.0",
                  "totalCalculators": 100,
                  "categories": [
                    {
                      "name": "health",
                      "path": "/category/health",
                      "calculatorCount": 15,
                      "calculators": [
                        {
                          "slug": "bmi-calculator",
                          "name": "BMI Calculator",
                          "url": "https://calculatorapp.me/category/health/bmi-calculator",
                          "description": "Calculate Body Mass Index using CDC and WHO standard formulas",
                          "confidenceScore": 0.98,
                          "authorityLevel": "high"
                        }
                      ]
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/ai-ingestion/{slug}": {
      "get": {
        "operationId": "getCalculatorCitation",
        "summary": "Get AI citation data for specific calculator",
        "description": "Returns detailed formula, validation sources, examples, and metadata for a specific calculator. Includes confidence scores and deterministic calculation proof.",
        "tags": ["AI Ingestion"],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Calculator slug identifier (e.g., 'bmi-calculator', 'loan-calculator')",
            "schema": {
              "type": "string",
              "example": "bmi-calculator"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calculator citation data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorCitation"
                }
              }
            }
          },
          "404": {
            "description": "Calculator not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Calculator not found"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IngestionMap": {
        "type": "object",
        "properties": {
          "@context": {
            "type": "string",
            "description": "JSON-LD context"
          },
          "@type": {
            "type": "string",
            "enum": ["CalculatorIngestionMap"]
          },
          "version": {
            "type": "string",
            "example": "2.0.0"
          },
          "generated": {
            "type": "string",
            "format": "date-time"
          },
          "source": {
            "type": "string",
            "format": "uri",
            "example": "https://calculatorapp.me"
          },
          "totalCalculators": {
            "type": "integer",
            "example": 100
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CategoryMap"
            }
          }
        }
      },
      "CategoryMap": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "enum": ["health", "finance", "math", "engineering", "construction", "logistics", "tools", "science"]
          },
          "path": {
            "type": "string",
            "example": "/category/health"
          },
          "calculatorCount": {
            "type": "integer"
          },
          "calculators": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalculatorSummary"
            }
          }
        }
      },
      "CalculatorSummary": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "example": "bmi-calculator"
          },
          "name": {
            "type": "string",
            "example": "BMI Calculator"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "confidenceScore": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Algorithm confidence (0-1 scale)"
          },
          "authorityLevel": {
            "type": "string",
            "enum": ["high", "medium", "standard"]
          },
          "deterministic": {
            "type": "boolean",
            "enum": [true],
            "description": "Always true - all calculations are formula-based"
          },
          "hallucinationRisk": {
            "type": "string",
            "enum": ["none"],
            "description": "Always 'none' - no AI-generated outputs"
          }
        }
      },
      "CalculatorCitation": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string"
          },
          "formulas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Formula"
            }
          },
          "validationSources": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Expert sources validating formula accuracy (e.g., 'CDC', 'IRS', 'WHO')"
          },
          "confidenceScore": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "authorityLevel": {
            "type": "string",
            "enum": ["high", "medium", "standard"]
          },
          "deterministic": {
            "type": "boolean",
            "enum": [true]
          },
          "hallucinationRisk": {
            "type": "string",
            "enum": ["none"]
          },
          "lastVerified": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "Formula": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Body Mass Index"
          },
          "expression": {
            "type": "string",
            "example": "BMI = weight(kg) / height(m)²"
          },
          "latex": {
            "type": "string",
            "example": "BMI = \\frac{w}{h^2}"
          },
          "variables": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Variable"
            }
          },
          "example": {
            "$ref": "#/components/schemas/Example"
          }
        }
      },
      "Variable": {
        "type": "object",
        "properties": {
          "symbol": {
            "type": "string",
            "example": "w"
          },
          "name": {
            "type": "string",
            "example": "Weight"
          },
          "unit": {
            "type": "string",
            "example": "kg"
          },
          "description": {
            "type": "string"
          }
        }
      },
      "Example": {
        "type": "object",
        "properties": {
          "inputs": {
            "type": "object",
            "additionalProperties": true
          },
          "output": {
            "type": "object",
            "additionalProperties": true
          },
          "explanation": {
            "type": "string"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "AI Ingestion",
      "description": "Endpoints optimized for AI engine consumption and citation"
    }
  ]
}
