Skip to main content

Official Python SDK for the PolyLingo translation API

Project description

polylingo (Python)

Official Python SDK for the PolyLingo translation API.

Requirements: Python 3.9+

Install

pip install polylingo

Sync usage

import os
import polylingo

client = polylingo.PolyLingo(
    api_key=os.environ["POLYLINGO_API_KEY"],
    # base_url="https://api.polylingo.io/v1",
    # timeout=120.0,
)

result = client.translate(content="# Hello", targets=["es", "fr"], format="markdown")
print(result["translations"]["es"])
client.close()

Context manager:

with polylingo.PolyLingo(api_key="...") as client:
    print(client.languages())

Async usage

import polylingo

async with polylingo.AsyncPolyLingo(api_key="...") as client:
    r = await client.translate(content="Hi", targets=["de"])

API

  • health() / await health()
  • languages()
  • translate(content=..., targets=..., format=..., source=..., model=...)
  • batch(items=..., targets=..., source=..., model=...)
  • usage()
  • jobs.create(...) — returns 202 payload
  • jobs.get(job_id)
  • jobs.translate(..., poll_interval=5.0, timeout=1200.0, on_progress=...)

Exceptions

  • PolyLingoError — base (status, error, args[0] message)
  • AuthError — 401
  • RateLimitError — 429 (retry_after)
  • JobFailedError — failed job (job_id)

Docs

Python SDK reference (when deployed).

Repository

UsePolyLingo/polylingo-python

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

polylingo-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

polylingo-0.1.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file polylingo-0.1.0.tar.gz.

File metadata

  • Download URL: polylingo-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for polylingo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5da091d7dbcfd358b515f0c25c70eaa1c5bc507f956a86f8cfe076178ae0a04
MD5 cc2f2afd6c38683c60cc56d02e1aa0e0
BLAKE2b-256 652dc7307a22085152fa9cb172a3bb74340953c956d543e5ab0508c10e04a04a

See more details on using hashes here.

Provenance

The following attestation bundles were made for polylingo-0.1.0.tar.gz:

Publisher: publish.yml on UsePolyLingo/polylingo-python

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

File details

Details for the file polylingo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polylingo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for polylingo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa741673f87762097dd08054e4b152f614260f1a8cfd76c6b3f4c5a1753efebd
MD5 ea246ce168e815d0f28a758048a3d890
BLAKE2b-256 be588a52ccc31a83c5d046c880ae4027da76edc2a19dd8edfb187beaa5f66794

See more details on using hashes here.

Provenance

The following attestation bundles were made for polylingo-0.1.0-py3-none-any.whl:

Publisher: publish.yml on UsePolyLingo/polylingo-python

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

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