MyanLex
SDKs and examples

TypeScript SDK

A typed, server-side HTTP client with explicit error handling.

Installation

Preview availability

The registry command below is planned and does not work yet. Inside a MyanLex workspace checkout, add "@myanlex/sdk": "workspace:*" to your consumer and run pnpm --filter @myanlex/sdk... build. Outside that workspace, use the JavaScript HTTP example without installing an SDK.

Registry installation
npm install @myanlex/sdk

First request

Set MYANLEX_API_KEY and MYANLEX_API_URL in a trusted server environment. The URL includes /v1. The client uses native fetch and ESM.

server.ts
import { MyanLex, MyanLexApiError } from '@myanlex/sdk';

const client = new MyanLex({
  apiKey: process.env.MYANLEX_API_KEY!,
  baseUrl: process.env.MYANLEX_API_URL!,
  timeoutMs: 30_000,
});

try {
  const result = await client.syllabify({ text: 'က😀' });
  console.log(result.segments);
} catch (error) {
  if (error instanceof MyanLexApiError) {
    console.error(error.status, error.code, error.requestId);
  } else {
    throw error;
  }
}

Operations and lifecycle

Methods: health, detect, normalize, convert, syllabify, validateOrthography, transliterate, tokenize, batchSyllabify, and batchTransliterate. Directions and schemes are explicit. Text is serialized unchanged; this is not a local linguistic engine.

Methods accept { signal } as the second argument. Deadlines include response body reading. MyanLexApiError preserves HTTP status, optional problem fields and retryAfterSeconds. MyanLexRequestError.kind distinguishes aborted, timeout, transport_failure, and invalid_response. There are no automatic retries. Successful batch responses can contain item failures.

HTTPS is required except on loopback; redirects are disabled and cookies omitted. Injected fetch implementations must honor cancellation and those options. Types describe the response contract; the SDK checks the JSON envelope, not every nested field at runtime. Use code-point offsets, not JavaScript string indexes.

On this page