{
  "openapi": "3.1.0",
  "info": {
    "title": "EB2026 Knowledge API",
    "version": "2026-10-30",
    "description": "Cite source_url and quote from content. authoritative is true only for the original language of that book — for Establishments Code Volume II that is Sinhala, not English. If authoritative is false the text is a machine translation; say so when you quote it. If a question is not covered by the corpus, say the corpus is silent; do not infer an answer.",
    "contact": {
      "url": "https://eb2026.telegram365books.stream"
    },
    "license": {
      "name": "Sri Lanka Intellectual Property Act No. 36 of 2003, Section 8 (public domain)"
    }
  },
  "servers": [
    {
      "url": "https://eb2026.telegram365books.stream"
    }
  ],
  "paths": {
    "/kb/books.json": {
      "get": {
        "operationId": "getCatalogue",
        "summary": "Books, editions, part counts and the corpus version",
        "responses": {
          "200": {
            "description": "Catalogue",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "corpus_version": "2026-10-30",
                  "books": [
                    {
                      "slug": "financial-regulations",
                      "title": "Financial Regulations 1992",
                      "year": "1992",
                      "authoritative_lang": "en",
                      "editions": [
                        {
                          "lang": "en",
                          "records": 589
                        }
                      ],
                      "parts": [
                        {
                          "part": "chapter-02",
                          "clauses": 24
                        }
                      ]
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/kb/all.ndjson": {
      "get": {
        "operationId": "streamCorpus",
        "summary": "Every record of all 12 editions, one JSON object per line (a gzip copy is served at /kb/all.ndjson.gz)",
        "responses": {
          "200": {
            "description": "NDJSON corpus",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                },
                "example": "{\"clause_id\":\"fr-105\",\"lang\":\"en\",\"authoritative\":true,\"source_url\":\"https://eb2026.telegram365books.stream/books/financial-regulations/en/chapter-02.html\"}"
              }
            }
          }
        }
      }
    },
    "/kb/clause/{clauseId}.json": {
      "get": {
        "operationId": "getClause",
        "summary": "One canonical clause document, with translation pointers",
        "parameters": [
          {
            "name": "clauseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "fr-105"
          }
        ],
        "responses": {
          "200": {
            "description": "Clause document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "clause_id": "fr-105",
                  "canonical_lang": "en",
                  "authoritative": true,
                  "content": "…",
                  "printed_folio": "61-63",
                  "source_url": "https://eb2026.telegram365books.stream/books/financial-regulations/en/chapter-02.html",
                  "translations": [
                    {
                      "lang": "si",
                      "authoritative": false,
                      "chars": 501,
                      "source_url": "https://eb2026.telegram365books.stream/books/financial-regulations/si/chapter-02.html"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No clause with that id",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "error": "not found",
                  "clause_id": "fr-99999"
                }
              }
            }
          }
        }
      }
    },
    "/kb/{book}/{lang}/{part}.json": {
      "get": {
        "operationId": "getPart",
        "summary": "One part of one edition with the full text of every clause in it",
        "parameters": [
          {
            "name": "book",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "financial-regulations"
          },
          {
            "name": "lang",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "si",
                "ta"
              ]
            },
            "example": "en"
          },
          {
            "name": "part",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "chapter-02"
          }
        ],
        "responses": {
          "200": {
            "description": "Part document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "book": "financial-regulations",
                  "lang": "en",
                  "part": "chapter-02",
                  "authoritative": true,
                  "clause_ids": [
                    "fr-105",
                    "fr-106"
                  ],
                  "records": []
                }
              }
            }
          }
        }
      }
    },
    "/kb/topics.json": {
      "get": {
        "operationId": "getTopics",
        "summary": "Nine-topic taxonomy with member clause ids",
        "responses": {
          "200": {
            "description": "Topics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "corpus_version": "2026-10-30",
                  "topics": [
                    {
                      "id": "procurement",
                      "label": "Procurement and tender",
                      "exam_weight": 3,
                      "keywords": [
                        "tender"
                      ],
                      "clause_ids": [
                        "fr-105"
                      ]
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/kb/questions.json": {
      "get": {
        "operationId": "getQuestions",
        "summary": "Exam questions mapped to source clauses (never answer prose)",
        "responses": {
          "200": {
            "description": "Questions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "note": "Questions map to source clauses. The answer is the quoted clause text; this file contains no answers.",
                  "questions": [
                    {
                      "question": "…",
                      "citation": "FR 31–45",
                      "book": "financial-regulations",
                      "part": "chapter-02",
                      "clause_ids": [
                        "fr-31"
                      ]
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/kb/lookup.json": {
      "get": {
        "operationId": "lookupCitation",
        "summary": "Resolve a printed citation such as FR 105 to a clause id",
        "responses": {
          "200": {
            "description": "Resolver",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "clauses": {
                    "FR 105": "fr-105",
                    "FR105": "fr-105",
                    "f.r.105": "fr-105"
                  },
                  "parts": {
                    "ec1 chapter 16": "chapter-16"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/kb/graph.json": {
      "get": {
        "operationId": "getGraph",
        "summary": "Whole-graph nodes and edges (books, parts, clauses, topics)",
        "responses": {
          "200": {
            "description": "Graph",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "corpus_version": "2026-10-30",
                  "nodes": [
                    {
                      "id": "clause:fr-105",
                      "type": "Clause"
                    }
                  ],
                  "edges": [
                    {
                      "from": "clause:fr-105",
                      "to": "topic:procurement",
                      "type": "governs"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/kb/analytics/{name}.json": {
      "get": {
        "operationId": "getAnalytics",
        "summary": "Precomputed analyses",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "topic-overlap",
                "clauses-frequency",
                "exam-weights",
                "centrality"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Analysis",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "corpus_version": "2026-10-30",
                  "pairs": []
                }
              }
            }
          }
        }
      }
    },
    "/kb/index/{lang}.json": {
      "get": {
        "operationId": "getIndex",
        "summary": "Inverted index for client-side search",
        "parameters": [
          {
            "name": "lang",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "si",
                "ta"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Index",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "lang": "en",
                  "term_count": 1,
                  "postings": {
                    "gift": "fr-151 fr-152"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/kb/{book}/{lang}.json": {
      "get": {
        "operationId": "getEdition",
        "summary": "One whole edition, every part in a single array of records",
        "parameters": [
          {
            "name": "book",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "financial-regulations",
                "public-officer-guidelines",
                "establishments-code-vol1",
                "establishments-code-vol2"
              ]
            }
          },
          {
            "name": "lang",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "si",
                "ta"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Edition records",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "book": "financial-regulations",
                  "lang": "en",
                  "authoritative": true,
                  "record_count": 589,
                  "records": []
                }
              }
            }
          }
        }
      }
    },
    "/kb/topic/{topicId}.json": {
      "get": {
        "operationId": "getTopic",
        "summary": "One topic: member clauses, exam weight and neighbouring topics (English)",
        "parameters": [
          {
            "name": "topicId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "procurement",
                "leave",
                "disciplinary",
                "recruitment",
                "finance",
                "delegations",
                "appointments",
                "salaries",
                "pensions"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Topic slice",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "topic": "procurement",
                  "label": "Procurement and tender",
                  "exam_weight": 3,
                  "clause_count": 49,
                  "clause_ids": [
                    "fr-105",
                    "fr-106"
                  ],
                  "overlaps_with": [
                    {
                      "topic": "delegations",
                      "jaccard": 0.041,
                      "shared": 6
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Unknown topic id"
          }
        }
      }
    },
    "/kb/all.md": {
      "get": {
        "operationId": "getAllMarkdown",
        "summary": "The English corpus as one Markdown document, for a single context-window paste",
        "responses": {
          "200": {
            "description": "Markdown, one section per clause with its source locator",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "url": "https://eb2026.telegram365books.stream/llms.txt"
  }
}
