{
  "openapi": "3.1.0",
  "info": {
    "title": "Ivayla.BG public catalog",
    "version": "1.2.0",
    "description": "Read-only product discovery. Resolve a requested size via the parent variations list, then fetch the selected variation ID and quote its current price with the size. A parent minimum may be a sample price.",
    "contact": {
      "email": "info@ivayla.bg"
    }
  },
  "servers": [
    {
      "url": "https://promo.ivayla.bg"
    }
  ],
  "security": [],
  "paths": {
    "/wp-json/wc/store/v1/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "Search public products and discover size variations",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "slug",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current public products. A search can return several similar names; verify the product ID and permalink.",
            "headers": {
              "X-WP-Total": {
                "description": "Total matching products",
                "schema": {
                  "type": "integer"
                }
              },
              "X-WP-TotalPages": {
                "description": "Total result pages",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Product"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rate limited. Respect Retry-After when present; otherwise use bounded exponential backoff. Do not hammer or bypass the limit."
          }
        }
      }
    },
    "/wp-json/wc/store/v1/products/{id}": {
      "get": {
        "operationId": "getProductOrVariation",
        "summary": "Read a product or the selected variation with its current price and stock",
        "description": "For a size choice, use the ID from parent.variations whose attributes match the requested size. Variation responses can have an empty attributes array; retain the selected label from the parent and verify parent ID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current product or variation. Quote name, selected size, amount and currency together.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "404": {
            "description": "Product or variation not publicly available. Do not substitute a price.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limited. Respect Retry-After when present; otherwise use bounded exponential backoff. Do not hammer or bypass the limit."
          }
        }
      }
    },
    "/api/pages.json": {
      "get": {
        "operationId": "listPages",
        "summary": "Business pages and product categories with their role and Markdown version",
        "description": "Returns every business page (about, contact, terms, delivery and returns, authenticity, privacy, FAQ, reviews, shop, home) with its schema.org type and the address of its Markdown version (page URL + .md), and every product category with its product count and Markdown version. Read-only, no authentication.",
        "responses": {
          "200": {
            "description": "Index of pages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "site": {
                      "type": "string",
                      "format": "uri"
                    },
                    "version": {
                      "type": "string"
                    },
                    "generated": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "pages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "role": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "markdown": {
                            "type": "string",
                            "format": "uri"
                          },
                          "updated": {
                            "type": "string",
                            "format": "date"
                          }
                        }
                      }
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "name": {
                            "type": "string"
                          },
                          "parent": {
                            "type": "integer"
                          },
                          "products": {
                            "type": "integer"
                          },
                          "url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "markdown": {
                            "type": "string",
                            "format": "uri"
                          }
                        }
                      }
                    },
                    "products": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PriceRange": {
        "type": "object",
        "properties": {
          "min_amount": {
            "type": "string",
            "description": "Integer minor-unit amount as a string. Divide by 10 ** currency_minor_unit; never assume two decimal places."
          },
          "max_amount": {
            "type": "string",
            "description": "Integer minor-unit amount as a string. Divide by 10 ** currency_minor_unit; never assume two decimal places."
          }
        },
        "required": [
          "min_amount",
          "max_amount"
        ]
      },
      "Prices": {
        "type": "object",
        "properties": {
          "price": {
            "type": "string",
            "description": "Integer minor-unit amount as a string. Divide by 10 ** currency_minor_unit; never assume two decimal places."
          },
          "regular_price": {
            "type": "string",
            "description": "Integer minor-unit amount as a string. Divide by 10 ** currency_minor_unit; never assume two decimal places."
          },
          "sale_price": {
            "type": "string",
            "description": "Integer minor-unit amount as a string. Divide by 10 ** currency_minor_unit; never assume two decimal places."
          },
          "price_range": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PriceRange"
              },
              {
                "type": "null"
              }
            ]
          },
          "currency_code": {
            "type": "string",
            "description": "Currency from this response, for example EUR."
          },
          "currency_minor_unit": {
            "type": "integer",
            "minimum": 0,
            "description": "Decimal exponent for all amounts."
          },
          "currency_symbol": {
            "type": "string"
          }
        },
        "required": [
          "price",
          "currency_code",
          "currency_minor_unit"
        ],
        "description": "For a variable parent, price may be the cheapest sample. Select a variation and read that variation before quoting a size-specific price."
      },
      "VariationAttribute": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "value"
        ]
      },
      "VariationReference": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VariationAttribute"
            }
          }
        },
        "required": [
          "id",
          "attributes"
        ]
      },
      "AttributeTerm": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          }
        }
      },
      "ProductAttribute": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "taxonomy": {
            "type": [
              "string",
              "null"
            ]
          },
          "has_variations": {
            "type": "boolean"
          },
          "terms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttributeTerm"
            }
          }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1
          },
          "parent": {
            "type": "integer",
            "description": "Parent product ID on a variation response."
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "For example simple, variable or variation."
          },
          "sku": {
            "type": "string"
          },
          "permalink": {
            "type": "string",
            "format": "uri"
          },
          "prices": {
            "$ref": "#/components/schemas/Prices"
          },
          "is_in_stock": {
            "type": "boolean"
          },
          "is_purchasable": {
            "type": "boolean"
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductAttribute"
            }
          },
          "variations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VariationReference"
            }
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "permalink",
          "prices",
          "is_in_stock",
          "is_purchasable"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object"
          }
        }
      }
    }
  }
}
