{
  "openapi": "3.1.0",
  "info": {
    "title": "F.R. GRANARIA Public Content API",
    "version": "1.0.0",
    "description": "Lesender öffentlicher Katalog für Bücher, aktuelle Artikel, offene Praxislabore und Übersichten. Keine Anmeldung, keine Schreiboperationen. Bücher und Plus-Inhalte liefern nur öffentliche Beschreibungen; persönliche Konten, Lernstände und Verwaltungsdaten sind nicht Bestandteil der API. Autoren eigener Werke heißen Dr.Jo,pac; andere Autoren bleiben erhalten."
  },
  "servers": [
    {
      "url": "https://granaria.ac"
    }
  ],
  "security": [],
  "paths": {
    "/api/v1/catalog.php": {
      "get": {
        "operationId": "searchPublicCatalog",
        "summary": "Öffentliche Inhalte suchen und paginieren",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Freie Suche in Titel, Kurzbeschreibung, Autoren, Inhalts-ID und Bereich sowie den Lerntexten der offenen Praxislabore; maximal 200 Zeichen.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "book",
                "article",
                "course",
                "role"
              ]
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "site",
                "books",
                "academy",
                "health",
                "wealth",
                "mindset"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 999999,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolgreiche öffentliche Leseanfrage. ETag und Cache-Control unterstützen wiederholte Abfragen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "schema_version",
                    "site",
                    "updated_at",
                    "total",
                    "count",
                    "limit",
                    "offset",
                    "items",
                    "links"
                  ],
                  "properties": {
                    "schema_version": {
                      "type": "string"
                    },
                    "site": {
                      "type": "string",
                      "format": "uri"
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "count": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "limit": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 100
                    },
                    "offset": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Record"
                      }
                    },
                    "links": {
                      "type": "object",
                      "properties": {
                        "self": {
                          "type": "string",
                          "format": "uri"
                        },
                        "next": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uri"
                        },
                        "previous": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uri"
                        }
                      }
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "304": {
            "description": "ETag unverändert"
          },
          "400": {
            "description": "Ungültige Parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Eintrag nicht vorhanden oder nicht mehr aktuell",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Nur GET, HEAD und OPTIONS erlaubt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "head": {
        "operationId": "headPublicCatalog",
        "summary": "Status und Cache-Metadaten ohne Antwortkörper lesen",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Freie Suche in Titel, Kurzbeschreibung, Autoren, Inhalts-ID und Bereich sowie den Lerntexten der offenen Praxislabore; maximal 200 Zeichen.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "page",
                "book",
                "article",
                "course",
                "role"
              ]
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "site",
                "books",
                "academy",
                "health",
                "wealth",
                "mindset"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 999999,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Header der Katalogantwort"
          },
          "304": {
            "description": "ETag unverändert"
          },
          "400": {
            "description": "Ungültige Parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Eintrag nicht vorhanden oder nicht mehr aktuell",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Nur GET, HEAD und OPTIONS erlaubt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/item.php": {
      "get": {
        "operationId": "getPublicContent",
        "summary": "Öffentlichen Datensatz und zugehörige Markdown-Textfassung lesen",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_-]{0,119}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Erfolgreiche öffentliche Leseanfrage. ETag und Cache-Control unterstützen wiederholte Abfragen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "schema_version",
                    "updated_at",
                    "item",
                    "content_markdown"
                  ],
                  "properties": {
                    "schema_version": {
                      "type": "string"
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "item": {
                      "$ref": "#/components/schemas/Record"
                    },
                    "content_markdown": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "ETag unverändert"
          },
          "400": {
            "description": "Ungültige Parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Eintrag nicht vorhanden oder nicht mehr aktuell",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Nur GET, HEAD und OPTIONS erlaubt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "head": {
        "operationId": "headPublicContent",
        "summary": "Status und Cache-Metadaten eines Eintrags lesen",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_-]{0,119}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Header der Einzelantwort"
          },
          "304": {
            "description": "ETag unverändert"
          },
          "400": {
            "description": "Ungültige Parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Eintrag nicht vorhanden oder nicht mehr aktuell",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Nur GET, HEAD und OPTIONS erlaubt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Record": {
        "type": "object",
        "required": [
          "id",
          "type",
          "title",
          "summary",
          "category",
          "authors",
          "access",
          "url",
          "source_url",
          "json_url",
          "markdown_url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{0,119}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "page",
              "book",
              "article",
              "course",
              "role"
            ]
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "site",
              "books",
              "academy",
              "health",
              "wealth",
              "mindset"
            ]
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "access": {
            "type": "string",
            "enum": [
              "public",
              "plus"
            ]
          },
          "publication_status": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "published",
              "announced",
              null
            ],
            "description": "Veröffentlichungsstatus aus dem bestehenden Katalog; ein verstrichener Plantermin ändert diesen Wert nicht."
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "source_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "json_url": {
            "type": "string",
            "format": "uri"
          },
          "markdown_url": {
            "type": "string",
            "format": "uri"
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "subtitle": {
            "type": "string"
          },
          "translator": {
            "type": "string"
          },
          "declared_formats": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ausgabebezeichnungen aus dem Katalog; eine Bezeichnung bestätigt keinen Produktlink."
          },
          "formats": {
            "type": "array",
            "description": "Ausschließlich vorhandene bestätigte ASIN-Links.",
            "items": {
              "type": "object",
              "required": [
                "label",
                "asin",
                "url"
              ],
              "properties": {
                "label": {
                  "type": "string"
                },
                "asin": {
                  "type": "string",
                  "pattern": "^[A-Z0-9]{10}$"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "published_label": {
            "type": "string",
            "description": "Unveränderte redaktionelle Datumsangabe; nicht zwingend ein vollständiges Publikationsdatum."
          },
          "text_available": {
            "type": "boolean",
            "description": "Öffentlicher Extraktionsstand vorhanden. Vor Textausgabe wird sein Quell-SHA-256 gegen das aktuelle PDF geprüft."
          },
          "duration_minutes": {
            "type": "integer",
            "minimum": 0
          },
          "learning_materials": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "certificate": {
            "type": "boolean"
          },
          "course_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_-]{0,119}$"
            }
          }
        },
        "additionalProperties": true
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Agentenübersicht und Beispiele",
    "url": "https://granaria.ac/agents/"
  }
}
