{
  "openapi": "3.1.0",
  "info": {
    "title": "Film des Tages – Public Data API",
    "version": "1.0.0",
    "description": "Öffentliche, unauthentifizierte Lese-Endpunkte von filmdestages.de für Agenten und Integrationen. Liefert den täglichen Apple-TV-Deal (Film des Tages), Filmdetails, Trailer und Suche. Schreib-/Cron-Endpunkte sind nicht Teil dieser API.",
    "contact": { "name": "Film des Tages", "url": "https://www.filmdestages.de" }
  },
  "servers": [{ "url": "https://www.filmdestages.de" }],
  "paths": {
    "/api/film-data": {
      "get": {
        "operationId": "getFilmData",
        "summary": "Film des Tages (aktueller Tagesdeal) oder Film per Datum/ID",
        "parameters": [
          {
            "name": "strategy",
            "in": "query",
            "required": false,
            "description": "Auswahlstrategie. Standard: active (aktueller Film des Tages).",
            "schema": { "type": "string", "enum": ["active", "by_date", "by_id"], "default": "active" }
          },
          {
            "name": "filmId",
            "in": "query",
            "required": false,
            "description": "Film-ID (erforderlich bei strategy=by_id).",
            "schema": { "type": "string" }
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Datum im Format YYYY-MM-DD (erforderlich bei strategy=by_date).",
            "schema": { "type": "string", "format": "date" }
          }
        ],
        "responses": {
          "200": {
            "description": "Film gefunden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["film"],
                  "properties": { "film": { "$ref": "#/components/schemas/StandardizedFilm" } }
                }
              }
            }
          },
          "500": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/film-details": {
      "get": {
        "operationId": "getFilmDetails",
        "summary": "Detaildaten eines Films",
        "parameters": [
          {
            "name": "filmId",
            "in": "query",
            "required": true,
            "description": "Film-ID.",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Filmdetails",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["film"],
                  "properties": { "film": { "$ref": "#/components/schemas/FilmDetails" } }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/Error" },
          "500": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/trailer-data": {
      "get": {
        "operationId": "getTrailerData",
        "summary": "Artwork- und Trailer-URL eines Films",
        "parameters": [
          {
            "name": "filmId",
            "in": "query",
            "required": true,
            "description": "Film-ID.",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Trailer-Daten",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["trailer"],
                  "properties": {
                    "trailer": {
                      "type": "object",
                      "properties": {
                        "artwork_url": { "type": ["string", "null"] },
                        "trailer_url": { "type": ["string", "null"] }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/Error" },
          "500": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/search": {
      "get": {
        "operationId": "searchFilms",
        "summary": "Filmsuche nach Titel (nur vorhandene Filme, keine externen Aufrufe)",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Suchbegriff (mind. 2 Zeichen; kürzere Eingaben liefern eine leere Liste).",
            "schema": { "type": "string", "minLength": 2 }
          }
        ],
        "responses": {
          "200": {
            "description": "Suchergebnisse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["results"],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/FilmSearchResult" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/about-data": {
      "get": {
        "operationId": "getAboutData",
        "summary": "Statischer Projektbeschreibungstext",
        "responses": {
          "200": {
            "description": "Über-Text",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "title": { "type": "string" },
                    "content": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/health/db": {
      "get": {
        "operationId": "getDbHealth",
        "summary": "Datenbank-Health-Check (Statusendpunkt)",
        "responses": {
          "200": {
            "description": "Datenbank erreichbar",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "enum": ["ok", "error"] },
                    "timestamp": { "type": "string", "format": "date-time" }
                  }
                }
              }
            }
          },
          "503": { "$ref": "#/components/responses/Error" },
          "500": { "$ref": "#/components/responses/Error" }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Error": {
        "description": "Fehler",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": { "error": { "type": "string" } }
            }
          }
        }
      }
    },
    "schemas": {
      "StandardizedFilm": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "slug": { "type": "string" },
          "title": { "type": "string" },
          "release_year": { "type": "integer" },
          "movie_length": { "type": "integer", "description": "Laufzeit in Minuten" },
          "genres": { "type": ["array", "null"], "items": { "type": "string" } },
          "artwork_url": { "type": "string" },
          "track_view_url": { "type": "string", "description": "Apple-TV-Kauflink" },
          "trailer_url": { "type": ["string", "null"] },
          "imdb_rating": { "type": ["number", "null"] },
          "imdb_id": { "type": ["string", "null"] },
          "imdb_url": { "type": ["string", "null"] },
          "description": { "type": ["string", "null"] },
          "price": {
            "type": "object",
            "properties": {
              "current": { "type": ["number", "null"] },
              "previous": { "type": ["number", "null"] },
              "discount": { "type": "number" },
              "discount_absolute": { "type": "number" },
              "discount_text": { "type": "string" }
            }
          },
          "metadata": {
            "type": "object",
            "properties": {
              "status": { "type": "string", "description": "z. B. active, inactive, expired" },
              "feature_date": { "type": ["string", "null"], "format": "date" },
              "last_updated": { "type": "string", "format": "date-time" }
            }
          }
        }
      },
      "FilmDetails": {
        "type": "object",
        "properties": {
          "title": { "type": "string" },
          "release_year": { "type": "integer" },
          "movie_length": { "type": "integer", "description": "Laufzeit in Minuten" },
          "genres": { "type": ["array", "null"], "items": { "type": "string" } },
          "artwork_url": { "type": ["string", "null"] },
          "imdb_rating": { "type": ["number", "null"] },
          "imdb_id": { "type": ["string", "null"] },
          "description": { "type": ["string", "null"] },
          "track_view_url": { "type": ["string", "null"] },
          "trailer_url": { "type": ["string", "null"] }
        }
      },
      "FilmSearchResult": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "title": { "type": "string" },
          "release_year": { "type": "integer" },
          "slug": { "type": "string" }
        }
      }
    }
  }
}
