Skip to main content

translatarr-client

A typed Python client for the Translatarr API — synchronous and asynchronous, with pydantic response models generated from the server's OpenAPI spec.

Install

pip install translatarr-client

Published to PyPI for each v* tag (the version matches the app's tag). The same wheel + sdist are also attached to the corresponding GitHub Release, and you can install straight from this repo:

# from a published GitHub Release (version matches the app's v* tag)
pip install https://github.com/joshrmcdaniel/translatarr/releases/download/v1.2.3/translatarr_client-1.2.3-py3-none-any.whl

# or straight from this repo
pip install -e clients/python

Requires Python 3.10+.

Authentication

Mint a personal API key in the web UI under Settings → API keys (tokens are prefixed tra_ and shown only once). Pass it as token:

from translatarr import TranslatarrClient

with TranslatarrClient("https://translatarr.example", token="tra_…") as tra:
    result = tra.translate("Good morning", source_lang="en", target_lang="ja")
    best = result.translations[0]
    print(best.text, best.romanization)

A browser session cookie works too, via session_cookie="…" instead of token.

Async

AsyncTranslatarrClient mirrors the sync client method-for-method:

import asyncio
from translatarr import AsyncTranslatarrClient

async def main() -> None:
    async with AsyncTranslatarrClient("https://translatarr.example", token="tra_…") as tra:
        result = await tra.translate("Bonjour", source_lang="auto", target_lang="en")
        print(result.detected_source_language, result.translations[0].text)

asyncio.run(main())

What you can do

Area Methods
Translate translate
Chats list_chats, create_chat, get_chat, rename_chat, clear_chat, delete_chat
Turns add_turn, list_turns, select_option, retranslate_turn, switch_branch
Speech transcribe, synthesize
API keys list_keys, create_key, revoke_key

Persisting a chat without paying for a second translation

translate does not store anything; add_turn translates and persists. To avoid a duplicate LLM call, pass the result you already have:

chat = tra.create_chat(source_lang="en", target_lang="ja")
preview = tra.translate("Let's ship it", source_lang="en", target_lang="ja", chat_id=chat.id)
chat = tra.add_turn(chat.id, "Let's ship it", source_lang="en", target_lang="ja", result=preview)

Errors

Failures raise a subclass of translatarr.APIError, each carrying status_code, the server's code (when present), and the raw response:

Exception Status
InvalidRequestError 400
AuthenticationError 401
ForbiddenError 403
NotFoundError 404
ConflictError 409
MalformedResponseError 422
ProviderError 502
from translatarr import NotFoundError

try:
    tra.get_chat("does-not-exist")
except NotFoundError:
    ...

Development

The response models in src/translatarr/_models.py are generated from the server's OpenAPI document — do not edit them by hand. To regenerate after the API schema changes:

# one-time tooling install
python -m venv clients/python/.venv
clients/python/.venv/bin/pip install -e 'clients/python[codegen]'

# regenerate openapi.json + _models.py
clients/python/scripts/regenerate.sh

The script dumps the spec via bun scripts/dump-openapi.ts (the same document served at /api/docs/openapi.json) and runs datamodel-codegen over it. Only _models.py is committed, so the client builds and installs without a running server; openapi.json is a regenerated, gitignored artifact.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

translatarr_client-0.2.2.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

translatarr_client-0.2.2-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file translatarr_client-0.2.2.tar.gz.

File metadata

  • Download URL: translatarr_client-0.2.2.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for translatarr_client-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6d7568a00fa2af367d6899f11c7332d4595892ceacb70e46168fb80020db9b0a
MD5 7de1ac700007fa9528d121e379fcf72c
BLAKE2b-256 75c83bc71ea64fcbc7fd34d32c0d46f2c20ee09a88e68c0d1d19b9cca5a8133a

See more details on using hashes here.

Provenance

The following attestation bundles were made for translatarr_client-0.2.2.tar.gz:

Publisher: publish-python.yml on joshrmcdaniel/translatarr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file translatarr_client-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for translatarr_client-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 47a5ed9082046224c16835754d9eaf40c5b8b89af14572866ca15b5543d93e1b
MD5 24ea346773fe50cbbb3439795af1e58b
BLAKE2b-256 1f9bfc3a6a4f204e3a84461d9560072b0c5f276a9a1d9246e6e1cc8ceb44e771

See more details on using hashes here.

Provenance

The following attestation bundles were made for translatarr_client-0.2.2-py3-none-any.whl:

Publisher: publish-python.yml on joshrmcdaniel/translatarr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page