{
  "openapi": "3.0.3",
  "info": {
    "title": "安提阿圣经经文 API",
    "version": "1.0.0",
    "description": "公开 GET API，无需认证。经文引用推荐 format=plain。译本与完整书卷编号表见 /llms.txt。"
  },
  "servers": [
    {
      "url": "https://bible.jeshurun.top"
    }
  ],
  "externalDocs": {
    "description": "API 使用说明和书卷编号表",
    "url": "https://bible.jeshurun.top/llms.txt"
  },
  "paths": {
    "/api/bible": {
      "get": {
        "operationId": "getChapter",
        "summary": "按书卷和章获取经文",
        "parameters": [
          {
            "name": "bookNum",
            "in": "query",
            "required": false,
            "description": "书卷编号 1–66；完整编号表见 /llms.txt。",
            "schema": {
              "type": "string",
              "default": "1"
            }
          },
          {
            "name": "chNum",
            "in": "query",
            "required": false,
            "description": "章号，正整数。",
            "schema": {
              "type": "string",
              "default": "1"
            }
          },
          {
            "name": "versions",
            "in": "query",
            "required": false,
            "description": "逗号分隔：ckjv2（钦定本）、ckjv3（公认文本）、cuv（和合本）、kjv（英文 KJV）；按请求顺序返回。",
            "schema": {
              "type": "string",
              "default": "ckjv2"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "plain 移除人名、地名 <ref> 标签，保留文字；省略时保留标记。",
            "schema": {
              "type": "string",
              "enum": [
                "plain"
              ]
            }
          },
          {
            "name": "useOldNames",
            "in": "query",
            "required": false,
            "description": "仅 ckjv3 使用传统译名，先替换译名再应用 format=plain。",
            "schema": {
              "type": "string",
              "default": "false",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "整章经文；不存在时 verses 为空。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/Verse"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "数据库查询失败",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/bible/verses": {
      "get": {
        "operationId": "getVerses",
        "summary": "获取同一章内指定节，适合引用",
        "parameters": [
          {
            "name": "bookNum",
            "in": "query",
            "required": true,
            "description": "书卷编号 1–66；约翰福音为 43。完整编号表见 /llms.txt。",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chNum",
            "in": "query",
            "required": true,
            "description": "章号，正整数。",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "verseNums",
            "in": "query",
            "required": true,
            "description": "正整数节号，逗号分隔，最多 200 项，例如 16,17,18。",
            "schema": {
              "type": "string"
            },
            "example": "16,17,18"
          },
          {
            "name": "versions",
            "in": "query",
            "required": false,
            "description": "逗号分隔：ckjv2（钦定本）、ckjv3（公认文本）、cuv（和合本）、kjv（英文 KJV）；按请求顺序返回。",
            "schema": {
              "type": "string",
              "default": "ckjv2"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "plain 移除人名、地名 <ref> 标签，保留文字；省略时保留标记。",
            "schema": {
              "type": "string",
              "enum": [
                "plain"
              ]
            }
          },
          {
            "name": "useOldNames",
            "in": "query",
            "required": false,
            "description": "仅 ckjv3 使用传统译名，先替换译名再应用 format=plain。",
            "schema": {
              "type": "string",
              "default": "false",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "经文与缺失节号；每节可能只含部分请求译本。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/Verse"
                        }
                      }
                    },
                    "missingVerseNums": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      },
                      "description": "所有请求译本都不存在的节号。"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "bookNum、chNum、verseNums 或 versions 无效。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "请求的节全部不存在。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "数据库查询失败",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "批量获取同一章最多 200 项节号，可同时选择多个译本。跨章或跨书卷请按 (bookNum, chNum) 分组请求，节范围须展开为逗号列表。完整批量调用示例见 /llms.txt。"
      }
    },
    "/api/bible/search": {
      "get": {
        "operationId": "searchVerses",
        "summary": "搜索经文；word 已是纯文本",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "description": "搜索词；空值时返回 error 和空 results。",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "versions",
            "in": "query",
            "required": false,
            "description": "逗号分隔译本代码；不传则搜索所有译本。",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "books",
            "in": "query",
            "required": false,
            "description": "逗号分隔书卷编号 1–66。",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "exact",
            "in": "query",
            "required": false,
            "description": "true 表示连续短语匹配。",
            "schema": {
              "type": "string",
              "default": "false",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "搜索结果（默认最多 200 条，无分页）；引用使用 word。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "word_id": {
                            "type": "integer"
                          },
                          "word": {
                            "type": "string",
                            "nullable": true
                          },
                          "book_num": {
                            "type": "integer"
                          },
                          "ch_num": {
                            "type": "integer"
                          },
                          "verse_num": {
                            "type": "integer"
                          },
                          "version": {
                            "type": "string"
                          },
                          "_formatted": {
                            "type": "object",
                            "properties": {
                              "word": {
                                "type": "string",
                                "description": "带 strong 高亮标签，仅用于展示。"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "数据库查询失败",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Verse": {
        "type": "object",
        "properties": {
          "word_id": {
            "type": "integer"
          },
          "word": {
            "type": "string",
            "nullable": true
          },
          "book_num": {
            "type": "integer"
          },
          "ch_num": {
            "type": "integer"
          },
          "verse_num": {
            "type": "integer"
          },
          "version": {
            "type": "string"
          },
          "version_zh": {
            "type": "string"
          }
        }
      }
    }
  }
}
