---
title: "Get Sentence Alignment"
method: GET
path: "/api/alignment/sentences/{text_id}/{juan_num}"
tags: ["alignment"]
---

# Get Sentence Alignment

`GET /api/alignment/sentences/{text_id}/{juan_num}`

## Request

- Base URL: `https://fojin.app` (the document declares no server; this is the origin it was published from)
- URL: `https://fojin.app/api/alignment/sentences/{text_id}/{juan_num}`
- Auth: none declared

Get all sentence-level (逐句) parallels for one juan.

Phase 4 Package C read path for the future reader's sentence-by-sentence
parallel view. Thin adapter over
services.alignment_read_model.get_sentence_parallels (the direction-agnostic
read of sentence_alignments lives there); this handler only maps records to
the wire shape and enforces the dark-ship gate.

Frozen response contract (mirrors the chunk endpoints for client.ts):

    {
      "text_id": int, "juan_num": int, "total": int,
      "pairs": [
        {
          "side_a": {"char_start", "char_end", "lang", "text"},   # requested text
          "side_b": {"text_id", "juan_num", "char_start", "char_end",
                     "lang", "title", "text"},                    # counterpart
          "similarity": float,        # averaged cross-lingual cosine
          "align_type": str,          # '1-1' | '1-2' | '2-1'
          "method": str,
          "is_verified": bool
        }
      ]
    }

Ships DARK behind ``settings.enable_sentence_parallels`` (default False): the
flag being off short-circuits to an empty payload WITHOUT touching the DB.
Even with the flag on, an empty sentence_alignments table naturally yields
total=0 / pairs=[] — the endpoint never errors, and self-activates once the
flag is on AND prod's refine_sentence_alignments.py has populated rows.

## Path parameters

- `text_id` integer, required
- `juan_num` integer, required

## Query parameters

- `limit` integer

## Response `200`

Successful Response

- SentenceAlignmentResponse: All sentence-level parallels for one (text_id, juan_num). Frozen frontend contract (client.ts, future 逐句对读 reader view), parallel to JuanAlignmentResponse for the chunk endpoints. Ships DARK: when the ``enable_sentence_parallels`` flag is off — or the sentence_alignments table has no rows for this juan — ``total`` is 0 and ``pairs`` is [] (never an error). Self-activates once the flag is on AND the prod refinement job has populated the table.
  - `text_id` integer, required
  - `juan_num` integer, required
  - `total` integer, required
  - `pairs` SentencePair[], required
    - `side_a` SentenceSideSelf, required: The requested text's side of a sentence pair. No text_id/juan_num — they are the path params echoed on the response envelope. char_start/char_end index into text_contents.content for (response.text_id, response.juan_num, lang), so the reader can highlight the exact sub-paragraph span; ``text`` is the verbatim sentence at those offsets.
      - `char_start` integer, required
      - `char_end` integer, required
      - `lang` string, required
      - `text` string, required
    - `side_b` SentenceSideOther, required: The counterpart text's side of a sentence pair. Carries its own text_id/juan_num (deep-link target) plus char_start/char_end into that text's content and the counterpart display ``title``.
      - `text_id` integer, required
      - `juan_num` integer, required
      - `char_start` integer, required
      - `char_end` integer, required
      - `lang` string, required
      - `title` string
      - `text` string, required
    - `similarity` number, required
    - `align_type` string, required
    - `method` string, required
    - `is_verified` boolean, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/fojin/apis/fojin-api-buddhist-digital-text-platform.md) · [All operations](https://skmtc.dev/fojin/apis/fojin-api-buddhist-digital-text-platform/llms.txt) · [OpenAPI document](https://skmtc.dev/fojin/apis/fojin-api-buddhist-digital-text-platform/revisions/969714238c61?raw)
