This release is a pre-release and may not be stable for production use.
MyanLex Python SDK
Unpublished preview, Python 3.10+. The proposed distribution name is
myanlex-python; it is not reserved or available as an official PyPI release.
The hosted API is not launched. Set an explicit base URL for your own server.
From the repository root:
python3 -m venv .cache/python-sdk-venv
.cache/python-sdk-venv/bin/python -m pip install -e 'packages/myanlex_python[dev]'
Consumers can install a supplied wheel without this repository:
python -m pip install ./myanlex_python-0.0.0-py3-none-any.whl.
import os
from myanlex import MyanLex, MyanLexApiError
with MyanLex(
api_key=os.environ["MYANLEX_API_KEY"], base_url=os.environ["MYANLEX_API_URL"]
) as client:
result = client.syllabify(text="က😀")
assert result.segments[-1].end == 2
AsyncMyanLex has the same methods, awaited inside async with:
from myanlex import AsyncMyanLex
async def normalize_text(text: str) -> str:
async with AsyncMyanLex(
api_key=os.environ["MYANLEX_API_KEY"], base_url=os.environ["MYANLEX_API_URL"]
) as client:
return (await client.normalize(text=text)).output
Reuse a client across requests in a service; close it at shutdown. The SDK owns and closes its HTTPX client and any explicitly supplied transport.
Methods and contracts
health()is public and sends no API key.detect(text=...),normalize(text=...),syllabify(text=...),validate_orthography(text=...),tokenize(text=...).convert(text=..., from_encoding='zawgyi', to_encoding='unicode', validate_source=True).transliterate(text=..., scheme='ala-lc-2011').batch_syllabify(items=[BatchItem(id='a', text='က')])andbatch_transliterate(items=..., scheme='ala-lc-2011').
Results are frozen Pydantic models, with immutable tuples for arrays. Full model
types are available under myanlex.models. Python attributes use snake_case;
model_dump(by_alias=True) restores wire names. Unknown response fields are
ignored; profile/code/kind strings remain forward-compatible. Required fields
and field types are checked, not linguistic correctness.
Offsets are half-open Unicode code-point offsets, matching Python string
indexing for valid Unicode. They are not grapheme offsets. A batch can return
HTTP 200 with individual success=False items; inspect each item before using
.result.
Conversion is explicit, not automatic mixed-text repair. validate_source=True
asks the server to reject mixed, mismatched or uncertain sources. Omitting it
retains the unchecked API default; False is forwarded explicitly.
Same-encoding requests remain no-ops. Keep originals and require review of
ambiguous input.
Reliability and security
HTTPS is required except localhost, 127.0.0.1 and ::1. Base URLs cannot contain
credentials, query strings or fragments and should include /v1. Redirects,
automatic retries, environment proxies and cookie replay are disabled. API keys
belong on trusted backends, never in browser bundles.
timeout=30.0 is an HTTPX connect/read/write/pool inactivity timeout, not a
whole-operation deadline. For a total async deadline use asyncio.wait_for.
Task cancellation propagates normally. A timeout or cancellation does not prove
the server stopped processing or that quota was not consumed. See
HTTPX timeout semantics.
MyanLexApiError exposes authoritative HTTP status, optional code,
request_id and retry_after_seconds (delta seconds or HTTP date). Non-JSON
error responses still preserve their status. MyanLexRequestError.kind is
timeout, transport_failure, invalid_response or closed. Error messages
exclude response bodies and submitted text; optional error metadata is
server-controlled. Do not log models, request headers, transport debug data or
traceback locals containing private input or credentials.
Contributor checks
.cache/python-sdk-venv/bin/python -m unittest discover -s packages/myanlex_python/tests -v
.cache/python-sdk-venv/bin/ruff check packages/myanlex_python
.cache/python-sdk-venv/bin/ruff format --check packages/myanlex_python
.cache/python-sdk-venv/bin/mypy --config-file packages/myanlex_python/pyproject.toml packages/myanlex_python/src
.cache/python-sdk-venv/bin/python -m build packages/myanlex_python
MYANLEX_PYTHON="$PWD/.cache/python-sdk-venv/bin/python" pnpm python:sdk:smoke
No registry publishing workflow is configured. Remove the private classifier only as part of an intentional package-release review. This SDK does not change MyanLex's beta linguistic limitations or outstanding independent review.
Release files for myanlex-python 0.1.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| myanlex_python-0.1.0b1.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| myanlex_python-0.1.0b1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / myanlex_python-0.1.0b1.tar.gz
| Download URL | myanlex_python-0.1.0b1.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
721802ad244fb635abeccacac3a036e30ef83daac30657be538a9d19e46ad4f7
|
|
BLAKE2b-256 checksum How to use checksums |
e371310afac07989fd3c6a35e26e3f55763b4ee396b7048b48489ad831171281
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / myanlex_python-0.1.0b1-py3-none-any.whl
| Download URL | myanlex_python-0.1.0b1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d15180188e496120dda0fbab8a535c105d9e0f94e8e20f6ed76c8af76905ec5
|
|
BLAKE2b-256 checksum How to use checksums |
6e508602fafcc4832c790e1aec0ab24d7c11ae6831048b1caa5c40fb893f012e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|