{
  "openapi": "3.1.0",
  "info": {
    "title": "Apex Tatva Public API",
    "version": "1.0.0",
    "description": "Read-only access to the Apex Tatva remedy library, health-goal index and vetted product catalog. Educational information only, not medical advice."
  },
  "servers": [
    {
      "url": "https://www.apex-tat-va.store"
    }
  ],
  "components": {
    "securitySchemes": {
      "proKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Optional Pro key (atv_live_…). Without it the free limit applies."
      }
    }
  },
  "paths": {
    "/api/public/v1/provenance": {
      "get": {
        "operationId": "searchProvenance",
        "summary": "4-tier provenance records (manuscript source, research status, cautions, disagreements) with a SHA-256 seal. Not medical advice.",
        "security": [
          {},
          {
            "proKey": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 80
            },
            "description": "Herb, category or traditional use."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10,
              "default": 3
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Records"
          },
          "401": {
            "description": "Invalid or inactive key"
          },
          "429": {
            "description": "Hourly limit reached"
          }
        }
      }
    },
    "/api/public/v1/canon": {
      "get": {
        "operationId": "searchCanon",
        "summary": "The 150-text canonical corpus behind the provenance records — title, author, era, tradition or pillar, synopsis, defining line, topics.",
        "security": [
          {},
          {
            "proKey": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 80
            },
            "description": "Text title, author, tradition, pillar or topic."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Canon entries"
          },
          "401": {
            "description": "Invalid or inactive key"
          },
          "429": {
            "description": "Hourly limit reached"
          }
        }
      }
    },
    "/api/public/v1/seal-check": {
      "get": {
        "operationId": "checkSeal",
        "summary": "Recompute a record's seal and compare it with a stored hash.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hash",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-fA-F0-9]{64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Match result"
          }
        }
      }
    },
    "/api/public/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "List vetted natural products, optionally filtered by health goal or herb.",
        "parameters": [
          {
            "name": "goal",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Health goal key, e.g. sleep."
          },
          {
            "name": "herb",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Product list"
          }
        }
      }
    },
    "/api/public/goals": {
      "get": {
        "operationId": "listHealthGoals",
        "summary": "List the health goals the library is indexed by.",
        "responses": {
          "200": {
            "description": "Goal list"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Service status, active vendors and member count.",
        "responses": {
          "200": {
            "description": "Status"
          }
        }
      }
    }
  }
}