{
  "openapi": "3.1.0",
  "info": {
    "title": "Legacy Piece Codes public lookup API",
    "version": "1.0.0",
    "description": "Read-only access to the Legacy Piece (Roblox) redeem-code list published on legacypiececodes.com. No authentication is required and no write operations exist.",
    "contact": {
      "url": "https://legacypiececodes.com/contact.html"
    },
    "license": {
      "name": "Content may be quoted with attribution to the source page",
      "url": "https://legacypiececodes.com/privacy.html"
    }
  },
  "servers": [
    {
      "url": "https://legacypiececodes.com"
    }
  ],
  "security": [],
  "paths": {
    "/api/agent/codes": {
      "get": {
        "operationId": "listCodes",
        "summary": "List redeem codes with their rewards and conditions",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "listed_active",
                "weakly_attested",
                "any"
              ],
              "default": "any"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Case-insensitive substring match on code, reward or conditions",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "min_sources",
            "in": "query",
            "description": "Minimum number of independent lists attesting the code (1-4)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching codes, newest-attested first"
          }
        }
      }
    },
    "/api/agent/code": {
      "get": {
        "operationId": "getCode",
        "summary": "Fetch a single code by exact string",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The matching code"
          },
          "404": {
            "description": "No such code is published on the site. Not a transient error: the code is unknown."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Code": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "reward": {
            "type": "string"
          },
          "conditions": {
            "type": "string"
          },
          "source_list_count": {
            "type": "integer",
            "nullable": true
          },
          "tier": {
            "type": "string",
            "enum": [
              "primary",
              "secondary"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "listed_active",
              "weakly_attested"
            ]
          },
          "source_url": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  }
}