Python SDK
Package
resilientlang(placeholder name), Python 3.9+, standard library only, typed. Not published to PyPI; no default API URL. See the SDK overview for status and shared behaviour.
pip install ./sdks/python # from the repository; optional: pip install './sdks/python[fast-crypto]'
import resilientlang as rl
client = rl.Client("https://api.example.com", "rl_sec_live_...") # base URL: no default
site = client.sites.create("My shop", "en", ["fr", "de"], allowed_origins=["https://shop.example"])
keys = client.strings.submit_all(site["id"], [{"text": "Add to basket"}, {"text": "Checkout", "context": "button"}])
job = client.translate(site["id"], langs=["fr", "de"])["jobs"][0] # one job per language
client.jobs.wait(job["id"], timeout=600)
published = client.jobs.wait(client.publish(site["id"])["id"])
print(published["state"]) # succeeded | failed | canceled
for t in client.translations.list_all(site["id"], lang="fr"): # follows nextCursor
print(t["key"], t["status"], t["text"])
export = client.export(site["id"], "xliff2", ["fr", "de"]) # bytes + filename (a .zip for several languages)
client.import_file(site["id"], open("fr.po", "rb").read(), "fr.po", lang="fr", dry_run=True)
print(client.quota()) # plan allowance; 404 not-found when quotas are off
Read the key from an environment variable or a secret store in real code, never from source.
Options#
Client(base_url, api_key, timeout=30, max_retries=2, max_retry_delay=10, allow_insecure_http=False, transport=None). transport(method, url, headers, body, timeout) -> (status, headers, bytes) replaces urllib (for example to use requests or httpx); it must not follow redirects. Pass idempotency_key="..." on any write to use your own key.
Where next#
Error handling, verify webhooks (rl.construct_event) and verify a published bundle (rl.parse_verified_manifest). Ed25519 uses cryptography when it is installed, otherwise a built-in pure-Python verifier that the author checked against RFC 8032 and the shared vectors.