# Knowledge Sea API — Examples

> **Status:** CURRENT
> **Last verified:** 2026-11-28

Base URL: `https://api.telegram365books.stream`

The API is served by `sea-api.service` on Google `ebstudy-vm` at
`127.0.0.1:8092`, exposed through Cloudflare. For local development against
this API, replace the base URL with `http://127.0.0.1:8092`. Port 8093 belongs
to Eddy, not to this API.

All examples use `curl`. The response bodies below are dated observations from read-only live requests, not invented fixtures. Use [/v1/topics](https://api.telegram365books.stream/v1/topics) and the [published corpus](https://eb2026.telegram365books.stream/kb/all.ndjson) for current IDs and content rather than copying counts into clients.

The live [OpenAPI document](https://api.telegram365books.stream/openapi.json) describes the public operations and intended schemas, but it can lag observed behavior. When they disagree, the observed response establishes current client behavior and the mismatch should be reported; the two are not simultaneously authoritative. In particular, topic detail currently omits the `clause_ids` advertised by the specification.

## 1. Health check

```bash
curl -s https://api.telegram365books.stream/health
```

Response observed at verification (`uptime_seconds` is dynamic):

```json
{
  "ok": true,
  "service": "Knowledge Sea Public API",
  "version": "1.0.0",
  "corpus_available": true,
  "corpus_error": null,
  "uptime_seconds": 277138.9
}
```

## 2. Discover topics

```bash
curl -s https://api.telegram365books.stream/v1/topics
```

Response (truncated; values are dated examples from the live service):

```json
{
  "topics": [
    {
      "id": "financial-regulations-front",
      "label": "Financial Regulations 1992 — Front matter",
      "exam_weight": 0,
      "keywords": [],
      "clause_count": 21
    },
    {
      "id": "financial-regulations-chapter-01",
      "label": "Financial Regulations 1992 — Chapter 1 — Estimates Of Expenditure And Revenue",
      "exam_weight": 0,
      "keywords": [],
      "clause_count": 172
    }
  ]
}
```

## 3. Get one topic's metadata

```bash
curl -s https://api.telegram365books.stream/v1/topics/financial-regulations-front
```

Response observed at verification:

```json
{
  "id": "financial-regulations-front",
  "label": "Financial Regulations 1992 — Front matter",
  "exam_weight": 0,
  "keywords": [],
  "clause_count": 21
}
```

This response contains no `clause_ids`; `clause_count` is metadata, not a clause list. Use the topic label and keywords to form `/v1/search` queries. The checked-in OpenAPI copy and the live OpenAPI document both still describe `clause_ids` for this route, so that schema is known to lag the observed response.

## 4. Full-text search

```bash
curl -s "https://api.telegram365books.stream/v1/search?q=loss%20reporting&limit=5"
```

Response observed at verification:

```json
{
  "query": "loss reporting",
  "hits": 5,
  "clauses": [
    {
      "clause_id": "fr-104",
      "book": "financial-regulations",
      "part_title": "Chapter 2 — Authorities For Expenditure, Refunds, Write-Offs,Etc.",
      "heading": "F.R.104 — F.R.104. (1) Inquiry and fixing of responsibility**. (a) As soon as a loss or damage occurs, inquiries should be instituted to ascertain the extent an",
      "snippet": "**F.R.104. (1) Inquiry and fixing of responsibility**. (a) As soon as a loss or damage occurs, inquiries should be instituted to ascertain the extent and causes of the loss, and to fix responsibility. (b) In the case of a loss or damage as"
    },
    {
      "clause_id": "pog-gp-0021",
      "book": "public-officer-guidelines",
      "part_title": "Section (01) — Documents that should be provided by a new appointee when reporting to duty and updated maintenance of a Personal File",
      "heading": "Documents that should be provided by a new appointee when reporting to duty and",
      "snippet": "## \uD83D\uDFE1 Section (01) — Documents that should be provided by a new appointee when reporting to duty and updated maintenance of a Personal File"
    },
    {
      "clause_id": "pog-gp-0021",
      "book": "public-officer-guidelines",
      "part_title": "1.1 புதிதாக நியமிக்கப்பட்ட ஓர் அதிகாரி தனது கடமைகளை ஏற்கும் போது திணைக்களத் தலைவரால் பெறப்பட வேண்டிய ஆவணங்கள்",
      "heading": "Documents that should be provided by a new appointee when reporting to duty and",
      "snippet": "> > ## \uD83D\uDFE1 Section (01) — Documents that should be provided by a new appointee when reporting to duty and updated maintenance of a Personal File > >"
    },
    {
      "clause_id": "fr-101",
      "book": "financial-regulations",
      "part_title": "Chapter 2 — Authorities For Expenditure, Refunds, Write-Offs,Etc.",
      "heading": "F.R.101 — F.R.101. The Basic Rules.** (1) The basic rules relating to responsibility for losses are indicated in F.R.156 (1). A loss suffered by the Government ",
      "snippet": "**F.R.101. The Basic Rules.** (1) The basic rules relating to responsibility for losses are indicated in F.R.156 (1). A loss suffered by the Government may fall within the definition of F.R.102, or arise from the need to abandon or cancel d"
    },
    {
      "clause_id": "fr-102",
      "book": "financial-regulations",
      "part_title": "Chapter 2 — Authorities For Expenditure, Refunds, Write-Offs,Etc.",
      "heading": "F.R.102 — F.R.102 Losses** (1)Losses dealt with under F.RR102 to 112 include:-",
      "snippet": "**F.R.102 Losses** (1)Losses dealt with under F.RR102 to 112 include:- (a) physical loss of Government property, including money, stamps, stores, livestock, crops, plants, tickets, etc. (b) loss of or damage to property of monetary value,"
    }
  ]
}
```

`hits` is the number of returned rows, not the total number of matching clauses. The same clause ID can appear more than once for different language or part variants, as `pog-gp-0021` does here; deduplicate IDs before clause retrieval.

## 5. Retrieve an exact clause

```bash
curl -s https://api.telegram365books.stream/v1/clause/fr-103
```

Response observed at verification:

```json
{
  "clause_id": "fr-103",
  "book": "Financial Regulations 1992",
  "canonical_lang": "ta",
  "authoritative": false,
  "part_title": "அத்தியாயம் 2 — செலவினங்கள், திருப்பிச் செலுத்துதல்கள், ரத்து செய்தல் (Write-Offs) போன்றவற்றுக்கான அதிகாரங்கள்.",
  "heading": "F.R.103 — F.R.103 (1) இழப்புகள் ஏற்படும் போது எடுக்கப்பட வேண்டிய நடவடிக்கைகளின் சுருக்கம்:",
  "content": "## F.R.103 (1) இழப்புகள் ஏற்படும் போது எடுக்கப்பட வேண்டிய நடவடிக்கைகளின் சுருக்கம்:\n\n(a) இழப்பு குறித்து, தேவைப்படும் இடங்களில் உரிய அதிகாரிகளுக்குத் தெரிவிக்கப்பட வேண்டும் – F.R.104.\n\n(b) சில வகையான இழப்புகள் – எ.கா., திருட்டு, மோசடிகள், விபத்துக்கள் போன்றவற்றின் போது காவல்துறைக்குத் தெரிவிக்க வேண்டும்.\n\n(c) விசாரணைகள் நடத்தப்பட்டு பொறுப்பு நிர்ணயிக்கப்பட வேண்டும் – F.R.104 (d) சம்பந்தப்பட்ட புத்தகங்கள், பதிவேடுகள் (records) போன்றவற்றிற்குப் போதுமான பாதுகாப்பு ஏற்பாடுகள் செய்யப்பட வேண்டும்.\n\n(e) இழப்பு சம்பந்தப்பட்ட இழப்புப் பதிவேட்டில் (Register of Losses) பதிவு செய்யப்பட வேண்டும் – F.R.110.\n\n(f) பொறுப்பான அதிகாரிகள் ஈடுகட்ட வேண்டிய தொகையை நிர்ணயித்து, அதை வசூலிக்க நடவடிக்கை எடுக்க வேண்டும் – F.R.105.\n\n(g) இழப்பு மீண்டும் நிகிலாதவாறு போதுமான நடவடிக்கைகள் எடுக்கப்பட வேண்டும்.\n\n(h) தேவைப்படும் இடங்களில், ஒழுங்கு நடவடிக்கை (Disciplinary action) சுதந்திரமாக எடுக்கப்பட வேண்டும் – F.R.105(4)\n\n(i) பொருத்தமான இடங்களில் வங்கி, காப்பீட்டு நிறுவனம், உத்தரவாததாரர் (Guarantor) போன்றவர்களிடம் கோரிக்கை (claim) முன்வைத்தல்.\n\n(j) பொருந்தும் இடங்களில், F.RR.106 மற்றும் 107-ன் கீழ் கணக்கியல் நடைமுறை (Accounting procedure) பின்பற்றப்பட வேண்டும். கூடுதல் விதிகள் தேவைப்படலாம்.\n\n## (k) write-off (கணக்கிலிருந்து நீக்குதல்) ஆணை (F.R.109 (1) பிறப்பிக்கப்பட வேண்டும்.\n\n(l) (f)-ன் கீழ் முழுத் தொகையையும் வசூலிக்க முடியாதபோது, தள்ளுபடி (waiver) ஆணை பிறப்பிக்கப்பட வேண்டும். F.R.109 (2)\n\n(2) அரசாங்கத்திற்குச் சொந்தமில்லாத சொத்து. – அரசாங்கத்திற்குச் சொந்தமில்லாத சொத்து இழப்பு ஏற்பட்டால், அதனை மாற்றுதல், கணக்கியல் முறை போன்ற வழிமுறைகளை கருவூலத்திலிருந்து (பொது நிதித்துறை) பெற வேண்டும்.\n\n(3) மேலே перечисொட்டுள்ள ஒவ்வொரு அம்சத்தின் கீழும் எடுக்கப்பட வேண்டிய நடவடிக்கைகள் மற்றும் அதன் மீது உத்தரவுகளை பிறப்பிக்க அதிகாரம் பெற்ற அதிகாரிகள் குறித்த விவரங்கள், பின்வரும் விதிகளில் விளக்கப்பட்டுள்ளன.",
  "source_url": "https://eb2026.telegram365books.stream/books/financial-regulations/ta/chapter-02.html",
  "cites": [],
  "cited_by": []
}
```

This static `GET` record is Tamil, non-authoritative, and has empty relation arrays. During the same verification, dynamic `POST /v1/quote-check` and `POST /v1/tools/get_clause` responses used an English, authoritative `fr-103` record; the generic tool response listed `cites` as `["fr-104", "fr-110", "fr-105", "fr-109"]`. This is an observed cross-endpoint corpus-variant discrepancy. Do not combine the static and dynamic records or assume their language metadata and relations are interchangeable.

## 6. Verify a quotation

```bash
curl -s -X POST https://api.telegram365books.stream/v1/quote-check \
  -H "Content-Type: application/json" \
  -d '{"clause_id": "fr-103", "quote": "The loss should be reported, where necessary to the appropriate authorities"}'
```

Response observed at verification:

```json
{
  "clause_id": "fr-103",
  "verified": true,
  "language": "en",
  "note": "verbatim in the canonical text"
}
```

Response to the same clause with a quote that is not present:

```bash
curl -s -X POST https://api.telegram365books.stream/v1/quote-check \
  -H "Content-Type: application/json" \
  -d '{"clause_id": "fr-103", "quote": "Every loss of public property shall be reported immediately"}'
```

```json
{
  "clause_id": "fr-103",
  "verified": false,
  "canonical_lang": "en",
  "note": "not verbatim in the canonical text"
}
```

These quote-check responses are from the dynamic English record, not the Tamil static clause record shown in section 5. A successful result confirms the quote against the record used by quote-check; it does not resolve the cross-endpoint variant discrepancy documented above.

## 7. Get related clauses

```bash
curl -s https://api.telegram365books.stream/v1/related/fr-103
```

Response observed at verification:

```json
{
  "clause_id": "fr-103",
  "cites": [],
  "cited_by": []
}
```

The empty arrays are the actual static related-record response; no cross-references were returned for this record.

## 8. Generic tool execution

```bash
curl -s -X POST https://api.telegram365books.stream/v1/tools/get_clause \
  -H "Content-Type: application/json" \
  -d '{"arguments": {"clause_id": "fr-103"}}'
```

## 9. OpenAPI specification

```bash
curl -s https://api.telegram365books.stream/openapi.json
```

At verification, the live document and checked-in `tech/openapi.json` were byte-identical. The published document still advertises `http://127.0.0.1:8093` for local development even though the API listens on `8092`, and it still advertises `clause_ids` for topic detail even though the live response omits them. Use the topology guidance above and observed responses for those two points; the published schema has not caught up with current behavior.

## 10. Error examples

Invalid clause path (observed HTTP 404):

```bash
curl -s https://api.telegram365books.stream/v1/clause/bad-id
```

```json
{
  "error": "not_found",
  "detail": "no such static file: v1/clause/bad-id.json"
}
```

Clause not found (observed HTTP 404):

```bash
curl -s https://api.telegram365books.stream/v1/clause/fr-99999
```

```json
{
  "error": "not_found",
  "detail": "no such static file: v1/clause/fr-99999.json"
}
```

Missing search query (observed HTTP 400):

```bash
curl -s "https://api.telegram365books.stream/v1/search"
```

```json
{
  "error": "missing_query",
  "detail": "provide a non-empty 'q' parameter"
}
```

Rate limiting is documented as HTTP 429 with an `error` field and optional `detail`. No 429 response was induced for this verification, so no service-specific detail text is presented as observed data.

## Citation format

Always cite clauses as `[fr-103]`, `[ec1-c15]`, `[pog-gp-0169]` — square
brackets, lowercase, hyphen-separated. Include the book name and heading when
quoting.

If a clause is authoritative in Sinhala (Establishments Code Vol II), the
quote-check result includes a caveat. Include the label
`[English translation - not authoritative]` beside any English quotation from
such a clause.
