Skip to main content

Python client for the latindictionary.io API — Latin↔English translation, word inspection, inflection tables, and more.

Project description

latindictionary-io

Python client for the latindictionary.io REST API — Latin-English translation, auto-detection, AI parsing, and inflection tables.

  • Sync + asyncClient (httpx) and AsyncClient (httpx.AsyncClient)
  • Typed — full type hints, Pydantic v2 response models, py.typed
  • Resilient — automatic retries with exponential backoff + jitter
  • Python 3.10+

Installation

pip install latindictionary-io

Quick start

from latindictionary_io import Client

with Client() as client:
    # Latin → English
    result = client.latin_to_english("canis")
    print(result)

    # English → Latin
    result = client.english_to_latin("dog")
    print(result)

Async

import asyncio
from latindictionary_io import AsyncClient

async def main():
    async with AsyncClient() as client:
        result = await client.latin_to_english("canis")
        print(result)

asyncio.run(main())

API reference

Both Client and AsyncClient expose the same methods (async versions are awaited).

Constructor

Client(
    base_url="https://api.latindictionary.io/api/v1",
    timeout=30.0,
    max_retries=3,
)
Parameter Default Description
base_url https://api.latindictionary.io/api/v1 REST API base URL
timeout 30.0 Request timeout in seconds
max_retries 3 Max retry attempts (with exponential backoff)

Translation endpoints

latin_to_english(word)

Look up a Latin word and get English definitions.

result = client.latin_to_english("canis")
Parameter Type Description
word str The Latin word to look up

english_to_latin(word)

Look up an English word and get Latin equivalents.

result = client.english_to_latin("dog")
Parameter Type Description
word str The English word to look up

auto_detect(text)

Auto-detect the language and translate.

result = client.auto_detect("amor")
Parameter Type Description
text str The text to translate

Parsing endpoints

latin_parse(text, *, model=None, max_candidates_per_token=None, max_alternates=None, allow_fallback=None)

AI-powered Latin text parsing.

result = client.latin_parse("Gallia est omnis divisa in partes tres")
Parameter Type Description
text str The Latin text to parse
model str | None Optional model identifier
max_candidates_per_token int | None Max candidates per token
max_alternates int | None Max alternate parses
allow_fallback bool | None Allow fallback parsing

inflection_table(lemma, *, entry_id=None, max_entries=None, include_periphrastic=None)

Get the inflection table for a Latin word.

table = client.inflection_table("amo")
Parameter Type Description
lemma str The dictionary form of the word
entry_id str | None Optional entry ID for disambiguation
max_entries int | None Maximum number of entries
include_periphrastic bool | None Include periphrastic forms

Response models

Pydantic v2 models are available for response validation. All use extra="allow" so additional API fields are preserved.

Model Used by
TranslationResponse latin_to_english(), english_to_latin()
AutoDetectResponse auto_detect()
LatinParseResponse latin_parse()
InflectionTableResponse inflection_table()

Exceptions

All exceptions inherit from LatinDictionaryError.

Exception Description
LatinDictionaryError Base exception
APIError Non-success HTTP status (has .status_code, .body)
RateLimitError HTTP 429 — extends APIError
ConnectionError Cannot connect to API
TimeoutError Request timed out
InputValidationError Local input validation failed

Development

pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

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

Source Distribution

latindictionary_io-1.0.3.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

latindictionary_io-1.0.3-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file latindictionary_io-1.0.3.tar.gz.

File metadata

  • Download URL: latindictionary_io-1.0.3.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for latindictionary_io-1.0.3.tar.gz
Algorithm Hash digest
SHA256 72c3520583260a565ada97fea89caa14c109381dbb47514811f91d7432146b20
MD5 b21844dca8ec98315ae40b056ac1a354
BLAKE2b-256 8aafd36e3eab0257837d30cb25a734c04c2049e5de81b0d18fffaee9ca8014a1

See more details on using hashes here.

File details

Details for the file latindictionary_io-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for latindictionary_io-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 89a23850628f16ff8993b60dc846f0072a901a3b169be26333657802713b3978
MD5 b0e00ef81ec16a9519218dc0ef5ad597
BLAKE2b-256 6c032ae73140420c7ebdfc0f41732f12681b73c2578b4abb1e8d7406b65f220f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page