{
  "openapi": "3.1.0",
  "info": {
    "title": "Craftwork Products Catalog API",
    "version": "1.0.0",
    "description": "Public read-only access to product cards published in the Craftwork marketplace."
  },
  "servers": [
    {
      "url": "https://craftwork.design"
    }
  ],
  "externalDocs": {
    "description": "Products API documentation",
    "url": "https://craftwork.design/.well-known/api-docs/products.md"
  },
  "paths": {
    "/api/products/catalog": {
      "get": {
        "operationId": "listProducts",
        "summary": "List published products",
        "description": "Returns public product cards using offset-based pagination.",
        "parameters": [
          {
            "name": "offset",
            "in": "query",
            "description": "Number of products to skip.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of products to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 30
            }
          },
          {
            "name": "sortByPrice",
            "in": "query",
            "description": "Filter products by price.",
            "schema": {
              "type": "string",
              "enum": ["free", "paid", "paid_free"],
              "default": "free"
            }
          },
          {
            "name": "sortByUpdated",
            "in": "query",
            "description": "Select the catalog ordering.",
            "schema": {
              "type": "string",
              "enum": ["trending", "popular", "recent"],
              "default": "trending"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of public product cards.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductCatalogResponse"
                }
              }
            }
          },
          "500": {
            "description": "The catalog could not be loaded."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProductCatalogResponse": {
        "type": "object",
        "required": ["products", "total", "hasMore"],
        "properties": {
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductCard"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      },
      "ProductCard": {
        "type": "object",
        "description": "Public marketplace metadata and previews for one product.",
        "additionalProperties": true
      }
    }
  }
}
