Metadata-Version: 2.4
Name: polylingo
Version: 0.1.0
Summary: Official Python SDK for the PolyLingo translation API
Project-URL: Homepage, https://usepolylingo.com
Project-URL: Documentation, https://usepolylingo.com/en/docs/sdk/python
Project-URL: Repository, https://github.com/UsePolyLingo/polylingo-python
Project-URL: Issues, https://github.com/UsePolyLingo/polylingo-python/issues
Author: PolyLingo
License-Expression: MIT
Keywords: api,i18n,markdown,polylingo,translation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Provides-Extra: dev
Requires-Dist: httpx>=0.24; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# polylingo (Python)

Official Python SDK for the [PolyLingo](https://usepolylingo.com) translation API.

**Requirements:** Python 3.9+

## Install

```bash
pip install polylingo
```

## Sync usage

```python
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:

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

## Async usage

```python
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](https://usepolylingo.com/en/docs/sdk/python) (when deployed).

## Repository

[UsePolyLingo/polylingo-python](https://github.com/UsePolyLingo/polylingo-python)

## License

MIT
