Build on Coptic Compass public APIs

The public API surface includes the read-only grammar dataset, normalized dictionary search, Shenute AI provider routing, and an OCR proxy for image or document uploads.

Start here

Most integrations should begin with the OpenAPI document, which describes the available public services and their request shapes.

Typical workflow

  • Use /api/openapi.json to inspect contracts for all four public services.
  • Call /api/v1/grammar to discover grammar endpoints and dataset version.
  • Fetch /api/v1/grammar/lessons for the published lesson index.
  • Query /api/v1/dictionary/search for paginated dictionary results.
  • Use /api/v1/dictionary/search-index when a reduced full dictionary index is needed.
  • Send POST /api/shenute requests for Shenute AI responses (default provider: thoth).
  • Send image OCR requests to POST /api/ocr so Coptic Compass forwards them to OCR_SERVICE_URL.

Integration notes

  • Grammar responses are read-only and versioned with schemaVersion, datasetVersion, and generatedAt metadata.
  • The public dataset only exposes published lessons and their related concepts, examples, exercises, footnotes, and sources.
  • The lesson filter accepts either a lesson slug or a canonical lesson id.
  • Dictionary search accepts q, dialect, partOfSpeech, exact, limit, and offset filters.
  • Dictionary payloads are normalized and do not include raw/source-only fields.
  • For browser apps on another origin, a backend proxy is the safest default.
  • Shenute AI supports provider values: thoth, openrouter, gemini, and hf.
  • Image upload and camera capture flows run OCR first and append extracted text under [Image OCR Context] before calling /api/shenute.
  • Set OCR_SERVICE_URL and optionally OCR_UPLOAD_FIELD when your OCR backend requires a specific multipart field name.
  • The /api/ocr endpoint proxies multipart OCR uploads and returns upstream OCR responses to the client.

Example request

A minimal server-side fetch that lists published lesson titles.

const response = await fetch(
  "https://www.copticcompass.com/api/v1/grammar/lessons",
);

const payload = await response.json();
const lessonTitles = payload.data.map((lesson) => lesson.title.en);

Dictionary search example

A paginated dictionary search request scoped to the Bohairic dialect.

const response = await fetch(
  "https://www.copticcompass.com/api/v1/dictionary/search?q=ⲙⲟⲓ&dialect=B&limit=10",
);

const page = await response.json();
const firstEntry = page.entries[0];

Shenute AI request example

A minimal POST request to /api/shenute using THOTH AI as provider.

const response = await fetch("https://www.copticcompass.com/api/shenute", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    inferenceProvider: "thoth",
    messages: [
      {
        id: "u1",
        role: "user",
        parts: [{ type: "text", text: "Translate this Coptic sentence." }],
      },
    ],
  }),
});

const streamOrText = await response.text();

OCR integration notes

Clients can call /api/ocr, and Coptic Compass forwards to OCR_SERVICE_URL then returns the upstream OCR response.

# .env.local
OCR_SERVICE_URL=https://your-ocr-service/upload
# Optional for strict OCR backends:
OCR_UPLOAD_FIELD=file

curl -X POST "https://www.copticcompass.com/api/ocr?lang=cop" \
  -F "file=@/path/to/coptic-image.jpg"

# Proxy OCR flow
# 1) client POSTs to /api/ocr
# 2) server forwards to OCR_SERVICE_URL
# 3) upstream OCR response is returned to the client