{
  "openapi": "3.1.0",
  "info": {
    "title": "Breslevpedia API",
    "version": "1.0.0",
    "description": "Read-only public API of Breslevpedia, the Hebrew encyclopedia of Breslov Chassidut. No authentication or API key is required; an optional OAuth bearer token (scope read) is accepted. Versioning: the version is in the URL path (/api/v1/). Breaking changes ship only under a new path version (/api/v2/); a superseded version keeps working for at least 6 months and its responses then carry Deprecation and Sunset headers (RFC 9745, RFC 8594). Every response carries an API-Version header. Errors use RFC 9457 application/problem+json with a machine-readable code. Rate limit: 120 requests per 60 seconds per client, reported in RateLimit headers; a 429 response includes Retry-After.",
    "contact": {
      "name": "Breslevpedia",
      "url": "https://breslevpedia.com/developers",
      "email": "info@breslevpedia.com"
    }
  },
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://breslevpedia.com/developers"
  },
  "servers": [
    {
      "url": "https://breslevpedia.com/api/v1",
      "description": "Version 1"
    }
  ],
  "paths": {
    "/search": {
      "get": {
        "operationId": "searchEntries",
        "summary": "Search encyclopedia entries",
        "description": "Search Breslevpedia entries by title, alias, category and summary. Query text is usually Hebrew.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Search text, usually Hebrew, e.g. התבודדות"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            },
            "description": "Maximum number of results"
          }
        ],
        "responses": {
          "200": {
            "description": "Matching entries",
            "headers": {
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntryList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/entries": {
      "get": {
        "operationId": "listEntries",
        "summary": "List all encyclopedia entries",
        "description": "Return every encyclopedia entry with its title, type, URL, summary, categories and aliases.",
        "responses": {
          "200": {
            "description": "All entries",
            "headers": {
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntryList"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Entry": {
        "type": "object",
        "required": [
          "title",
          "type",
          "url"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "Entry title (Hebrew)"
          },
          "type": {
            "type": "string",
            "enum": [
              "concepts",
              "people",
              "niggunim",
              "books",
              "bibliography"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "summary": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "EntryList": {
        "type": "object",
        "required": [
          "count",
          "items"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Entry"
            }
          }
        }
      },
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "enum": [
              "missing_query",
              "invalid_limit",
              "not_found",
              "method_not_allowed",
              "rate_limited",
              "server_error"
            ],
            "description": "Machine-readable error code"
          },
          "detail": {
            "type": "string",
            "description": "Human-readable explanation and how to fix the request"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    },
    "headers": {
      "RateLimitPolicy": {
        "description": "Quota policy, e.g. 120;w=60",
        "schema": {
          "type": "string"
        }
      },
      "RateLimit": {
        "description": "Current limit, remaining requests and seconds until reset",
        "schema": {
          "type": "string"
        }
      },
      "ApiVersion": {
        "description": "API version that served the request",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid parameters",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "NotFound": {
        "description": "Unknown endpoint",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "MethodNotAllowed": {
        "description": "The API is read-only",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limit exceeded",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "ServerError": {
        "description": "Unexpected server error",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    }
  }
}