{
  "openapi": "3.1.0",
  "info": {
    "title": "Funk Community Library Public API",
    "version": "1.0.0",
    "description": "Anonymous read-only access to approved Borderlands 4 community folders. No API key. Browser CORS is allowed without cookies. Serial case, order and duplicates are significant. Codes are format-checked, not guaranteed safe or legitimate. Folder contents can change or be withdrawn; imports should be independent copies. All errors return ok:false and message. Do not retry 4xx responses automatically; wait at least 60 seconds after 429."
  },
  "servers": [
    {
      "url": "https://msbt-community-library.screename53.workers.dev/api/v1"
    }
  ],
  "paths": {
    "/folders": {
      "get": {
        "operationId": "listFolders",
        "summary": "Search approved folders",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Case-insensitive title or creator search."
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum folders returned. Omit for the compatible default of 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Up to 25 folders. Follow next until null; ordering may change while paging.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "folders",
                    "next"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "folders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Metadata"
                      }
                    },
                    "next": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/folders/{id}": {
      "get": {
        "operationId": "getFolder",
        "summary": "Download one approved folder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "UUID v4 returned by listFolders."
          }
        ],
        "responses": {
          "200": {
            "description": "Folder with canonical content digest. SHA-256 is over UTF-8 JSON.stringify(folder), with key order preserved. The digest is an integrity check, not proof of author identity.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Metadata"
                    },
                    {
                      "type": "object",
                      "required": [
                        "ok",
                        "folder"
                      ],
                      "properties": {
                        "ok": {
                          "const": true
                        },
                        "folder": {
                          "$ref": "#/components/schemas/Folder"
                        },
                        "images": {
                          "type": "array",
                          "description": "Uploaded screenshots, keyed by SHA-256 of exact UTF-8 item serial.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "serial_hash": {
                                "type": "string"
                              },
                              "content_hash": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "item_details": {
                          "type": "object",
                          "description": "Optional presentation metadata keyed by SHA-256 of the complete case-sensitive serial. Uploaded image takes priority; GZO title and fallback image require an exact match. Excluded from canonical folder digest.",
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "title": {
                                "type": "string"
                              },
                              "title_source": {
                                "type": "string"
                              },
                              "creator": {
                                "type": "string"
                              },
                              "source_url": {
                                "type": "string"
                              },
                              "image_url": {
                                "type": "string"
                              },
                              "image_source": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Error": {
        "description": "Request failed; message describes the failure. 404 includes private, withdrawn, rejected and missing folders.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "ok",
                "message"
              ],
              "properties": {
                "ok": {
                  "const": false
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Metadata": {
        "type": "object",
        "required": [
          "id",
          "title",
          "creator",
          "description",
          "item_count",
          "digest",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "creator": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "item_count": {
            "type": "integer"
          },
          "oversized_count": {
            "type": "integer"
          },
          "digest": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "status": {
            "const": "approved"
          },
          "created_at": {
            "type": "string"
          },
          "reviewed_at": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Folder": {
        "type": "object",
        "required": [
          "version",
          "title",
          "creator",
          "description",
          "folders",
          "items"
        ],
        "properties": {
          "version": {
            "const": 1
          },
          "title": {
            "type": "string"
          },
          "creator": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "folders": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Relative subfolder paths, including empty folders. These are labels, not filesystem paths."
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "name",
                "folder",
                "serial"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "folder": {
                  "type": "string"
                },
                "serial": {
                  "type": "string",
                  "description": "Exact case-sensitive @U serial. Preserve order and duplicates."
                }
              }
            }
          }
        }
      }
    }
  }
}
