Metadata-Version: 2.4
Name: ollang-sdk
Version: 0.2.0
Summary: Official Python SDK for the Ollang API - Translation, Transcription, Dubbing, Closed Captioning, and I18n Management
Author: Ollang
License: MIT
Project-URL: Homepage, https://github.com/ollang/sdk
Project-URL: Documentation, https://api-docs.ollang.com
Project-URL: Repository, https://github.com/ollang/sdk
Project-URL: Bug Tracker, https://github.com/ollang/sdk/issues
Keywords: ollang,translation,transcription,dubbing,closed-captioning,subtitles,localization,sdk,api
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.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25.0

# Ollang Python SDK

Official Python SDK for the [Ollang API](https://api-docs.ollang.com) — translation, transcription, dubbing, closed captioning, and i18n management.

## Installation

```bash
pip install ollang-sdk
```

Requires Python 3.8+.

## Quick Start

```python
from ollang import Ollang

client = Ollang(api_key="your-api-key")

# Upload a file (creates a project)
upload = client.uploads.direct(
    "./video.mp4",
    name="My Video",
    source_language="en",
)

# Create an order
orders = client.orders.create(
    order_type="cc",
    level=1,
    project_id=upload["projectId"],
    target_language_configs=[
        {"language": "fr", "isRush": False},
        {"language": "de", "isRush": False},
    ],
)

# Check order status
status = client.orders.get(orders[0]["orderId"])
print(status)
```

Get your API key from your project settings at [Olabs](https://lab.ollang.com).

## Resources

| Resource                     | Description                                        |
| ---------------------------- | -------------------------------------------------- |
| `client.projects`            | Create, read and list projects                     |
| `client.uploads`             | Upload files, or register remote ones by URL       |
| `client.orders`              | Create, track, review and export orders            |
| `client.folders`             | Browse folders and act on all their orders at once |
| `client.revisions`           | Request revisions on completed orders              |
| `client.memories`            | Translation memories and their items               |
| `client.custom_instructions` | Set custom translation instructions                |
| `client.content`             | Import and export translation units                |
| `client.billing`             | Credit wallet and consumption history              |
| `client.locales`             | Resolve and validate language codes                |
| `client.figma`               | Import Figma files and track their orders          |

All methods return the parsed JSON response as plain dicts/lists. Non-2xx
responses raise `ollang.OllangAPIError`, which carries `status_code` and the
parsed error `body`.

## Examples

```python
# List orders with pagination and filters
page = client.orders.list(page=1, take=20, status="completed")
for order in page["data"]:
    print(order["id"], order.get("status"))

# Request a revision on an order
client.revisions.create(
    order_id="ORDER_ID",
    type="wrongSubtitle",
    time="00:01:23",
    description="Fix the terminology in this segment",
)

# Custom instructions
client.custom_instructions.create(
    key="tone",
    value="Formal, brand-safe tone for all marketing content",
)

# Resolve a language code before using it
matches = client.locales.search("portu")
check = client.locales.validate("pt-PT")

# Translation memories
memory = client.memories.create("Brand terms")
job = client.memories.import_items(
    memory["id"],
    [
        {
            "sourceLanguage": "en",
            "targetLanguage": "fr",
            "sourceText": "Sign in",
            "targetText": "Se connecter",
        }
    ],
)
print(client.memories.get_import_job(job["jobId"])["status"])

# Assign a translator to every French order in a folder
client.folders.assign_translator("FOLDER_ID", translator_id="TRANSLATOR_ID", target_language="fr")

# Credit balance and recent consumption
wallet = client.billing.credits()
usage = client.billing.consumption(page=1, take=20, from_="2026-01-01")

# Import a large remote file without streaming it through your process
project = client.projects.create_by_url(
    url="https://example.com/video.mp4",
    name="Launch video",
    source_language="en",
)

# Endpoints not wrapped yet? Use the underlying HTTP client:
raw = client.client.get("/integration/orders")
```

### Binary exports

The XLSX endpoints return raw `bytes` rather than JSON. Each has a
`..._to_file` companion that writes the workbook to a path, creating parent
directories as needed:

```python
data = client.orders.export_xlsx("ORDER_ID")

client.orders.export_xlsx_to_file("ORDER_ID", "out/order.xlsx")
client.folders.export_xlsx_to_file(["FOLDER_ID"], ["fr", "de"], "out/folders.xlsx")
```

## Configuration

```python
client = Ollang(
    api_key="your-api-key",
    base_url="https://api-integration.ollang.com",  # optional override
    timeout=60.0,                                    # seconds
)
```

## Development

```bash
cd python
pip install -e . requests
python -m unittest discover tests -v
```

## Documentation

Full API documentation: **[https://api-docs.ollang.com](https://api-docs.ollang.com)**

## License

MIT
