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.2.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.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: latindictionary_io-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 32d50586aa9fe54d6665f0fbd5ff1b475c90ec90446ce0c95924e7811f8b352e
MD5 66c9086c7d190693349d2d4558178d73
BLAKE2b-256 ae29d49c20456344f419155f9af22657d33d6b2a5c1b94ae0a04f8078772b15f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for latindictionary_io-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b363fe037aeab2ecda73229354380f9d84f318969efff5db44a2c24c891d6be3
MD5 f74670170199ef4ae8aede23ce9a2dee
BLAKE2b-256 bd698f7da3ccad0f96864e8934cd082a1b5a37a997b2d923a0434a5c768ef533

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