{
  "openapi": "3.1.0",
  "info": {
    "title": "TIKKI Public Knowledge Search",
    "version": "1.0.0",
    "description": "Read-only search over public TIKKI knowledge. Existing native-language health Q&A may be searchable after the privacy gate while its source status is still pending; verification fields state that boundary explicitly. Private raw records are never returned by this API."
  },
  "servers": [
    {
      "url": "https://tikki.wiki/api"
    }
  ],
  "paths": {
    "/v1/search": {
      "get": {
        "operationId": "searchKnowledge",
        "summary": "Search published knowledge",
        "description": "Searches canonical public Q&A and returns available sources plus explicit privacy and verification boundaries. An empty sources array means source enrichment is still pending. Queries are not logged by the application.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
          "minLength": 2,
              "maxLength": 256
            }
          },
          {
            "name": "area",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "gesundheit",
                "oele"
              ]
            }
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string",
          "enum": [
            "qa"
          ]
            }
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[a-z]{2,3}(?:-[a-z0-9]{2,8})?$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results",
            "headers": {
              "ETag": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "304": {
            "description": "The cached response is current"
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "head": {
        "operationId": "headSearchKnowledge",
        "summary": "Read search response headers",
        "responses": {
          "200": {
            "description": "Search response headers"
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "options": {
        "operationId": "optionsSearchKnowledge",
        "summary": "Read CORS capabilities",
        "responses": {
          "204": {
            "description": "CORS capabilities"
          }
        }
      }
    },
    "/v1/index": {
      "get": {
        "operationId": "getSearchIndex",
        "summary": "Read public index metadata",
        "responses": {
          "200": {
            "description": "Index metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IndexResponse"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "head": {
        "operationId": "headSearchIndex",
        "summary": "Read index response headers",
        "responses": {
          "200": {
            "description": "Index response headers"
          }
        }
      },
      "options": {
        "operationId": "optionsSearchIndex",
        "summary": "Read CORS capabilities",
        "responses": {
          "204": {
            "description": "CORS capabilities"
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getSearchHealth",
        "summary": "Check the search service and index",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          },
          "503": {
            "description": "The search index is degraded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      },
      "head": {
        "operationId": "headSearchHealth",
        "summary": "Read health response headers",
        "responses": {
          "200": {
            "description": "Health response headers"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "options": {
        "operationId": "optionsSearchHealth",
        "summary": "Read CORS capabilities",
        "responses": {
          "204": {
            "description": "CORS capabilities"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "InvalidRequest": {
        "description": "Invalid query or filter",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unavailable": {
        "description": "The index is temporarily unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "Source": {
        "type": "object",
        "required": [
          "url",
          "title",
          "authority_tier",
          "evidence_quote",
          "quote_exact_match",
          "claim_support_verified"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "authority_tier": {
            "type": "string"
          },
          "evidence_quote": {
            "type": "string"
          },
          "quote_exact_match": {
            "type": "boolean"
          },
          "claim_support_verified": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "Verification": {
        "type": "object",
        "required": [
          "tier",
          "source_identity_verified",
          "claim_support_verified",
          "quote_exact_match",
          "human_reviewed"
        ],
        "properties": {
          "tier": {
            "type": "string",
            "description": "The precise publication tier; source-linked does not imply claim verification."
          },
          "source_identity_verified": {
            "type": "boolean"
          },
          "claim_support_verified": {
            "type": "boolean"
          },
          "quote_exact_match": {
            "type": "boolean"
          },
          "human_reviewed": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "SearchResult": {
        "type": "object",
        "required": [
          "id",
          "canonical_id",
          "area",
          "kind",
          "language",
          "title",
          "question",
          "answer",
          "snippet",
          "publication_status",
          "verification",
          "sources",
          "url",
          "score"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "canonical_id": {
            "type": "string"
          },
          "area": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "question": {
            "type": "string"
          },
          "answer": {
            "type": "string"
          },
          "snippet": {
            "type": "string"
          },
          "publication_status": {
            "type": "string"
          },
          "verification": {
            "$ref": "#/components/schemas/Verification"
          },
          "sources": {
            "type": "array",
            "description": "Available public sources. This may be empty for privacy-screened existing answers whose source enrichment is still pending.",
            "items": {
              "$ref": "#/components/schemas/Source"
            }
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Canonical human-readable HTML page for this public record."
          },
          "score": {
            "type": "number",
            "description": "Relative full-text relevance; larger is better within one response."
          }
        },
        "additionalProperties": false
      },
      "SearchResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "query",
          "index",
          "count",
          "results"
        ],
        "properties": {
          "schema_version": {
            "const": "tikki.search-response.v1"
          },
          "query": {
            "type": "object",
            "required": [
              "q",
              "area",
              "kind",
              "lang",
              "limit",
              "match_mode"
            ],
            "properties": {
              "q": {
                "type": "string"
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "kind": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "lang": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "limit": {
                "type": "integer"
              },
              "match_mode": {
                "type": "string",
                "enum": [
                  "all_terms",
                  "any_term_fallback"
                ]
              }
            },
            "additionalProperties": false
          },
          "index": {
            "type": "object",
            "required": [
              "built_at",
              "revision",
              "public_records"
            ],
            "properties": {
              "built_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "revision": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "public_records": {
                "type": "integer"
              }
            },
            "additionalProperties": false
          },
          "count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchResult"
            }
          }
        },
        "additionalProperties": false
      },
      "IndexResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "index",
          "interfaces",
          "privacy"
        ],
        "properties": {
          "schema_version": {
            "const": "tikki.search-response.v1"
          },
          "index": {
            "type": "object"
          },
          "interfaces": {
            "type": "object"
          },
          "privacy": {
            "type": "object"
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "status",
          "index"
        ],
        "properties": {
          "schema_version": {
            "const": "tikki.search-response.v1"
          },
          "status": {
            "enum": [
              "ok",
              "degraded"
            ]
          },
          "index": {
            "type": "object"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "error"
        ],
        "properties": {
          "schema_version": {
            "const": "tikki.search-response.v1"
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    }
  }
}
