{
  "openapi": "3.0.3",
  "info": {
    "title": "Qkat Public Marketplace Discovery API",
    "version": "1.1.0",
    "description": "Read-only public Qkat marketplace discovery. Only published eligible products, services and merchants; private data is never exposed."
  },
  "servers": [
    {
      "url": "https://qkat.app/api",
      "description": "Marketplace-facing public API"
    },
    {
      "url": "https://business.qkat.app/api",
      "description": "Existing backend public API"
    }
  ],
  "paths": {
    "/public/v1": {
      "get": {
        "summary": "Public API capabilities",
        "responses": {
          "200": {
            "description": "Public API routes"
          }
        },
        "operationId": "getMarketplaceCapabilities"
      }
    },
    "/public/v1/search": {
      "get": {
        "summary": "Search live eligible products, services and merchants",
        "parameters": [
          {
            "name": "mode",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "products",
                "services"
              ]
            },
            "example": "products"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "water tank"
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "Water Tanks"
          },
          {
            "name": "origin_area",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "Westlands"
          },
          {
            "name": "origin_city",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "Nairobi"
          },
          {
            "name": "latitude",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "example": -1.2833
          },
          {
            "name": "longitude",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "example": 36.8167
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "example": 0
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            },
            "example": 25
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Temporarily unavailable"
          }
        },
        "operationId": "searchMarketplace"
      }
    },
    "/public/v1/categories": {
      "get": {
        "summary": "Published category tree",
        "responses": {
          "200": {
            "description": "Successful public response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryTree"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Temporarily unavailable"
          }
        },
        "operationId": "listMarketplaceCategories"
      }
    },
    "/public/v1/products/{id}": {
      "get": {
        "summary": "Product detail (redirects to authoritative customer API)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "307": {
            "description": "Redirect to customer product detail"
          }
        },
        "operationId": "getMarketplaceProduct"
      }
    },
    "/public/v1/services/{id}": {
      "get": {
        "summary": "Service detail (redirects to authoritative customer API)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Numeric service ID or UUID"
            },
            "example": "106"
          }
        ],
        "responses": {
          "307": {
            "description": "Redirect to customer service detail"
          }
        },
        "operationId": "getMarketplaceService"
      }
    },
    "/public/v1/merchants": {
      "get": {
        "operationId": "listPublicMerchants",
        "summary": "Paginate all eligible published merchants without walking product pages",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "example": 0
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "example": 50
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MerchantPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Temporarily unavailable"
          }
        }
      }
    },
    "/public/v1/stores/{id}": {
      "get": {
        "operationId": "getMarketplaceStore",
        "summary": "Read eligible public stores details via the customer API",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "307": {
            "description": "Redirect to authoritative public business detail"
          }
        }
      }
    },
    "/public/v1/providers/{id}": {
      "get": {
        "operationId": "getMarketplaceProvider",
        "summary": "Read eligible public providers details via the customer API",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "307": {
            "description": "Redirect to authoritative public business detail"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PublicMerchant": {
        "type": "object",
        "required": [
          "id",
          "name",
          "url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "area": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "provider_url": {
            "type": "string",
            "format": "uri"
          },
          "image_url": {
            "type": "string",
            "nullable": true
          },
          "products": {
            "type": "boolean"
          },
          "services": {
            "type": "boolean"
          },
          "product_categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "service_categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PublicProduct": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "selling_price": {
            "type": "number",
            "nullable": true
          },
          "pricing_mode": {
            "type": "string",
            "example": "FIXED"
          },
          "category": {
            "type": "string"
          },
          "image_url": {
            "type": "string",
            "format": "uri"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "details_api": {
            "type": "string"
          }
        }
      },
      "PublicService": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Numeric legacy ID or UUID",
            "example": "106"
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "price": {
            "type": "number",
            "nullable": true
          },
          "pricing_mode": {
            "type": "string",
            "example": "REQUEST_QUOTE"
          },
          "image_url": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "details_api": {
            "type": "string"
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "properties": {
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicProduct"
            }
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicService"
            }
          },
          "merchants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicMerchant"
            }
          },
          "page": {
            "type": "integer"
          },
          "next": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "MerchantPage": {
        "type": "object",
        "properties": {
          "merchants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicMerchant"
            }
          },
          "page": {
            "type": "integer"
          },
          "next": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "CategoryTree": {
        "type": "object",
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "products",
                    "services"
                  ]
                },
                "name": {
                  "type": "string"
                },
                "parent_id": {
                  "type": "string",
                  "nullable": true
                },
                "discovery_url": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          }
        }
      }
    }
  }
}
