{
  "openapi": "3.1.0",
  "info": {
    "title": "Brick Broker read-only commerce API",
    "version": "1.0.0",
    "description": "Public listings only. No authentication required. 60 requests/minute per caller/lane where trusted IP is available; otherwise shared quota. Read-only; no payment, order or hold operations. Cached 30 seconds with ETags; availability uncached."
  },
  "servers": [
    {
      "url": "https://brick.broker/api/public/v1"
    }
  ],
  "paths": {
    "/products": {
      "get": {
        "summary": "List and search public sets",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search set number, title or theme",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "all, new, used or coming-soon",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page starting at 1",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1\u201350 results, default 20",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "theme",
            "in": "query",
            "required": false,
            "description": "Exact theme",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "condition",
            "in": "query",
            "required": false,
            "description": "new or used",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "min",
            "in": "query",
            "required": false,
            "description": "Minimum USD price",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "max",
            "in": "query",
            "required": false,
            "description": "Maximum USD price",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "newest, price_asc, price_desc, pieces, released_asc or released_desc",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public shop data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "products": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      }
                    },
                    "page": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "ETag unchanged (except availability)"
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Not a public listing"
          },
          "429": {
            "description": "Rate limited; Retry-After: 60"
          },
          "503": {
            "description": "Data unavailable"
          }
        }
      }
    },
    "/products/{id}": {
      "get": {
        "summary": "Read a unique public item",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Inventory UUID or current product slug",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public shop data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "304": {
            "description": "ETag unchanged (except availability)"
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Not a public listing"
          },
          "429": {
            "description": "Rate limited; Retry-After: 60"
          },
          "503": {
            "description": "Data unavailable"
          }
        }
      }
    },
    "/products/{id}/availability": {
      "get": {
        "summary": "Uncached availability and price",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Inventory UUID or current product slug",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public shop data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "availability": {
                      "type": "string"
                    },
                    "price": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "currency": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "checkedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "ETag unchanged (except availability)"
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Not a public listing"
          },
          "429": {
            "description": "Rate limited; Retry-After: 60"
          },
          "503": {
            "description": "Data unavailable"
          }
        }
      }
    },
    "/shipping": {
      "get": {
        "summary": "Non-mutating quote of published US shipping",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "description": "Inventory UUID or current product slug",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "Two-letter destination; default US",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public shop data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "quoted",
                        "unavailable",
                        "unsupported_destination"
                      ]
                    },
                    "shipping": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "currency": {
                      "type": "string"
                    },
                    "country": {
                      "type": "string"
                    },
                    "productPrice": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "mutatesInventory": {
                      "const": false
                    },
                    "taxIncluded": {
                      "const": false
                    },
                    "service": {
                      "type": "string"
                    },
                    "policyUrl": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "ETag unchanged (except availability)"
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Not a public listing"
          },
          "429": {
            "description": "Rate limited; Retry-After: 60"
          },
          "503": {
            "description": "Data unavailable"
          }
        }
      }
    },
    "/policies": {
      "get": {
        "summary": "Read public shop policies",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Public shop data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "304": {
            "description": "ETag unchanged (except availability)"
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Not a public listing"
          },
          "429": {
            "description": "Rate limited; Retry-After: 60"
          },
          "503": {
            "description": "Data unavailable"
          }
        }
      }
    },
    "/checkout": {
      "post": {
        "summary": "Request a buyer checkout link (disabled unless the shop owner enables it)",
        "description": "Returns 403 while disabled. Never send payment details; the buyer pays on the Stripe-hosted page. Holds the set 30 minutes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "itemId",
                  "buyerConfirmed"
                ],
                "properties": {
                  "itemId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "buyerConfirmed": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "requires_buyer_action with checkoutUrl"
          },
          "400": {
            "description": "Invalid body"
          },
          "403": {
            "description": "Agent checkout disabled"
          },
          "409": {
            "description": "Not available"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "setNumber": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "theme": {
            "type": "string"
          },
          "condition": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "availability": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "verifiedComplete": {
            "type": "boolean"
          },
          "shippingIncluded": {
            "type": "boolean"
          },
          "taxIncluded": {
            "type": "boolean"
          },
          "listedAt": {
            "type": "string"
          },
          "policyUrl": {
            "type": "string"
          },
          "price": {
            "type": [
              "number",
              "null"
            ]
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "conditionDetails": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "verification": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          },
          "pieces": {
            "type": [
              "integer",
              "null"
            ]
          },
          "minifigures": {
            "type": [
              "integer",
              "null"
            ]
          },
          "releaseYear": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      }
    }
  }
}